fix: dont set aliases as externals (#671)

This commit is contained in:
Katja Lutz 2020-06-29 22:45:30 +02:00 committed by GitHub
parent 302807d655
commit 5f1a6a9e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 0 deletions

View File

@ -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: {

View File

@ -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

View 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"
}
}

View File

@ -0,0 +1 @@
export default 42;

View File

@ -0,0 +1,2 @@
import tinyglob from 'tiny-glob';
console.log(tinyglob);