mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
fix: dont set aliases as externals (#671)
This commit is contained in:
parent
302807d655
commit
5f1a6a9e3f
@ -462,6 +462,7 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
const moduleAliases = options.alias
|
||||
? parseMappingArgumentAlias(options.alias)
|
||||
: [];
|
||||
const aliasIds = moduleAliases.map(alias => alias.find);
|
||||
|
||||
const peerDeps = Object.keys(pkg.peerDependencies || {});
|
||||
if (options.external === 'none') {
|
||||
@ -560,6 +561,9 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
if (options.multipleEntries && id === '.') {
|
||||
return true;
|
||||
}
|
||||
if (aliasIds.indexOf(id) >= 0) {
|
||||
return false;
|
||||
}
|
||||
return externalTest(id);
|
||||
},
|
||||
treeshake: {
|
||||
|
||||
@ -43,6 +43,54 @@ exports[`fixtures build alias with microbundle 5`] = `
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build alias-external with microbundle 1`] = `
|
||||
"Used script: microbundle --alias tiny-glob=./colossal-glob.js
|
||||
|
||||
Directory tree:
|
||||
|
||||
alias-external
|
||||
dist
|
||||
alias-external.esm.js
|
||||
alias-external.esm.js.map
|
||||
alias-external.js
|
||||
alias-external.js.map
|
||||
alias-external.umd.js
|
||||
alias-external.umd.js.map
|
||||
package.json
|
||||
src
|
||||
colossal-glob.js
|
||||
index.js
|
||||
|
||||
|
||||
Build \\"aliasExternal\\" to dist:
|
||||
37 B: alias-external.js.gz
|
||||
21 B: alias-external.js.br
|
||||
37 B: alias-external.esm.js.gz
|
||||
21 B: alias-external.esm.js.br
|
||||
93 B: alias-external.umd.js.gz
|
||||
89 B: alias-external.umd.js.br"
|
||||
`;
|
||||
|
||||
exports[`fixtures build alias-external with microbundle 2`] = `6`;
|
||||
|
||||
exports[`fixtures build alias-external with microbundle 3`] = `
|
||||
"console.log(42);
|
||||
//# sourceMappingURL=alias-external.esm.js.map
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build alias-external with microbundle 4`] = `
|
||||
"console.log(42);
|
||||
//# sourceMappingURL=alias-external.js.map
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build alias-external with microbundle 5`] = `
|
||||
"!function(n){\\"function\\"==typeof define&&define.amd?define(n):n()}(function(){console.log(42)});
|
||||
//# sourceMappingURL=alias-external.umd.js.map
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build async-iife-ts with microbundle 1`] = `
|
||||
"Used script: microbundle
|
||||
|
||||
|
||||
10
test/fixtures/alias-external/package.json
vendored
Normal file
10
test/fixtures/alias-external/package.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "alias-external",
|
||||
"scripts": {
|
||||
"build": "microbundle --alias tiny-glob=./colossal-glob.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"tiny-glob": "^0.2.6",
|
||||
"lodash.merge": "^4.6.2"
|
||||
}
|
||||
}
|
||||
1
test/fixtures/alias-external/src/colossal-glob.js
vendored
Normal file
1
test/fixtures/alias-external/src/colossal-glob.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
export default 42;
|
||||
2
test/fixtures/alias-external/src/index.js
vendored
Normal file
2
test/fixtures/alias-external/src/index.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import tinyglob from 'tiny-glob';
|
||||
console.log(tinyglob);
|
||||
Loading…
x
Reference in New Issue
Block a user