Skip to content

Commit

Permalink
Include all relevant modules to generate reexports for implicit depen…
Browse files Browse the repository at this point in the history
…dencies (#3688)
  • Loading branch information
lukastaegert committed Jul 22, 2020
1 parent 21cc03d commit 9f84284
Show file tree
Hide file tree
Showing 33 changed files with 202 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -83,7 +83,7 @@
"acorn-walk": "^7.2.0",
"buble": "^0.20.0",
"chokidar": "^3.4.1",
"codecov": "^3.7.1",
"codecov": "^3.7.2",
"colorette": "^1.2.1",
"core-js": "^3.6.5",
"cross-os": "^1.3.0",
Expand Down
7 changes: 6 additions & 1 deletion src/Module.ts
Expand Up @@ -292,7 +292,12 @@ export default class Module {
const additionalSideEffectModules = new Set<Module>();
const possibleDependencies = new Set(this.dependencies);
let dependencyVariables = this.imports;
if (this.isEntryPoint || this.includedDynamicImporters.length > 0 || this.namespace.included) {
if (
this.isEntryPoint ||
this.includedDynamicImporters.length > 0 ||
this.namespace.included ||
this.implicitlyLoadedAfter.size > 0
) {
dependencyVariables = new Set(dependencyVariables);
for (const exportName of [...this.getReexports(), ...this.getExports()]) {
dependencyVariables.add(this.getVariableForExportName(exportName));
Expand Down
@@ -0,0 +1,20 @@
module.exports = {
description: 'handles shared dependencies between implicit chunks without side-effects',
options: {
plugins: {
name: 'test-plugin',
buildStart() {
this.emitFile({
type: 'chunk',
id: 'core.js',
implicitlyLoadedAfterOneOf: ['main']
});
this.emitFile({
type: 'chunk',
id: 'button.js',
implicitlyLoadedAfterOneOf: ['main']
});
}
}
}
};
@@ -0,0 +1,7 @@
define(['exports', './main'], function (exports, main) { 'use strict';

const bar = main.foo + 'bar';

exports.bar = bar;

});
@@ -0,0 +1,7 @@
define(['exports', './main'], function (exports, main) { 'use strict';



exports.foo = main.foo;

});
@@ -0,0 +1,9 @@
define(['exports'], function (exports) { 'use strict';

const foo = 'foo';

exports.foo = foo;

Object.defineProperty(exports, '__esModule', { value: true });

});
@@ -0,0 +1,7 @@
'use strict';

var main = require('./main.js');

const bar = main.foo + 'bar';

exports.bar = bar;
@@ -0,0 +1,7 @@
'use strict';

var main = require('./main.js');



exports.foo = main.foo;
@@ -0,0 +1,7 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const foo = 'foo';

exports.foo = foo;
@@ -0,0 +1,5 @@
import { foo } from './main.js';

const bar = foo + 'bar';

export { bar };
@@ -0,0 +1 @@
export { foo } from './main.js';
@@ -0,0 +1,3 @@
const foo = 'foo';

export { foo };
@@ -0,0 +1,14 @@
System.register(['./main.js'], function (exports) {
'use strict';
var foo;
return {
setters: [function (module) {
foo = module.foo;
}],
execute: function () {

const bar = exports('bar', foo + 'bar');

}
};
});
@@ -0,0 +1,13 @@
System.register(['./main.js'], function (exports) {
'use strict';
return {
setters: [function (module) {
exports('foo', module.foo);
}],
execute: function () {



}
};
});
@@ -0,0 +1,10 @@
System.register([], function (exports) {
'use strict';
return {
execute: function () {

const foo = exports('foo', 'foo');

}
};
});
@@ -0,0 +1 @@
export { bar } from './shared/button';
@@ -0,0 +1 @@
export { foo } from './shared/core.js';
@@ -0,0 +1 @@
export { foo } from './shared/core.js';
@@ -0,0 +1,2 @@
import { foo } from './core.js';
export const bar = foo + 'bar';
@@ -0,0 +1 @@
export const foo = 'foo';
@@ -0,0 +1,15 @@
module.exports = {
description: 'handles shared dependencies when there are only reexports',
options: {
plugins: {
name: 'test-plugin',
buildStart() {
this.emitFile({
type: 'chunk',
id: 'implicit.js',
implicitlyLoadedAfterOneOf: ['main']
});
}
}
}
};
@@ -0,0 +1,7 @@
define(['exports', './main'], function (exports, main) { 'use strict';



exports.foo = main.foo;

});
@@ -0,0 +1,9 @@
define(['exports'], function (exports) { 'use strict';

const foo = 'shared';

exports.foo = foo;

Object.defineProperty(exports, '__esModule', { value: true });

});
@@ -0,0 +1,7 @@
'use strict';

var main = require('./main.js');



exports.foo = main.foo;
@@ -0,0 +1,7 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const foo = 'shared';

exports.foo = foo;
@@ -0,0 +1 @@
export { foo } from './main.js';
@@ -0,0 +1,3 @@
const foo = 'shared';

export { foo };
@@ -0,0 +1,13 @@
System.register(['./main.js'], function (exports) {
'use strict';
return {
setters: [function (module) {
exports('foo', module.foo);
}],
execute: function () {



}
};
});
@@ -0,0 +1,10 @@
System.register([], function (exports) {
'use strict';
return {
execute: function () {

const foo = exports('foo', 'shared');

}
};
});
@@ -0,0 +1 @@
export * from './shared.js';
@@ -0,0 +1 @@
export * from './shared.js';
@@ -0,0 +1 @@
export const foo = 'shared';

0 comments on commit 9f84284

Please sign in to comment.