Skip to content

Commit

Permalink
Handle manual chunks where the entry is not part of the module graph (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Mar 24, 2023
1 parent 66eda90 commit b6c4fd8
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ast/nodes/Program.ts
Expand Up @@ -18,6 +18,9 @@ export default class Program extends NodeBase {
private hasLoggedEffect = false;

hasCachedEffects(): boolean {
if (!this.included) {
return false;
}
return this.hasCachedEffect === null
? (this.hasCachedEffect = this.hasEffects(createHasEffectsContext()))
: this.hasCachedEffect;
Expand Down
11 changes: 11 additions & 0 deletions test/chunking-form/samples/manual-chunk-not-included/_config.js
@@ -0,0 +1,11 @@
module.exports = {
description: 'handles manual chunks where the root is not part of the module graph',
options: {
input: ['main.js'],
output: {
manualChunks: {
manual: ['manual-entry.js']
}
}
}
};
@@ -0,0 +1,5 @@
define((function () { 'use strict';

console.log('included');

}));
@@ -0,0 +1,5 @@
define(['./generated-manual'], (function (manual) { 'use strict';

console.log('main');

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

console.log('included');
@@ -0,0 +1,5 @@
'use strict';

require('./generated-manual.js');

console.log('main');
@@ -0,0 +1 @@
console.log('included');
@@ -0,0 +1,3 @@
import './generated-manual.js';

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

console.log('included');

})
};
}));
@@ -0,0 +1,11 @@
System.register(['./generated-manual.js'], (function () {
'use strict';
return {
setters: [null],
execute: (function () {

console.log('main');

})
};
}));
2 changes: 2 additions & 0 deletions test/chunking-form/samples/manual-chunk-not-included/main.js
@@ -0,0 +1,2 @@
import './manual-included';
console.log('main');
@@ -0,0 +1,5 @@
import './manual-included';

function test() {}

test();
@@ -0,0 +1 @@
console.log('included');

0 comments on commit b6c4fd8

Please sign in to comment.