Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle manual chunks where the entry is not part of the module graph #4921

Merged
merged 1 commit into from Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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');