Skip to content

Commit

Permalink
Fix #2353 - retain empty manual chunks (#2362)
Browse files Browse the repository at this point in the history
* fixes #2353

* minor refactoring
  • Loading branch information
guybedford authored and lukastaegert committed Aug 7, 2018
1 parent 1620ce9 commit 1db6679
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Graph.ts
Expand Up @@ -445,7 +445,7 @@ export default class Graph {
// exposed as an unresolvable export * (to a graph external export *,
// either as a namespace import reexported or top-level export *)
// should be made to be its own entry point module before chunking
const chunkList: Chunk[] = [];
let chunkList: Chunk[] = [];
if (!preserveModules) {
const chunkModules: { [entryHashSum: string]: Module[] } = {};
for (const module of orderedModules) {
Expand Down Expand Up @@ -482,12 +482,9 @@ export default class Graph {
}

// filter out empty dependencies
for (let i = 0; i < chunkList.length; i++) {
const chunk = chunkList[i];
if (chunk.isEmpty && !chunk.entryModule) {
chunkList.splice(i--, 1);
}
}
chunkList = chunkList.filter(
chunk => !chunk.isEmpty || chunk.entryModule || chunk.isManualChunk
);

// then go over and ensure all entry chunks export their variables
for (const chunk of chunkList) {
Expand Down
10 changes: 10 additions & 0 deletions test/chunking-form/samples/manual-chunks-dynamic/_config.js
@@ -0,0 +1,10 @@
module.exports = {
description: 'manual chunks to an empty dynamic chunk',
_single: true,
options: {
input: ['main.js'],
manualChunks: {
'dynamic': ['dynamic.js']
}
}
};
@@ -0,0 +1,5 @@
define(function () { 'use strict';



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

new Promise(function (resolve, reject) { require(["./dynamic-10698fc3.js"], resolve, reject) });

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

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

Promise.resolve(require("./dynamic-5ab72169.js"));
@@ -0,0 +1 @@

@@ -0,0 +1 @@
import("./dynamic-12dc935a.js");
@@ -0,0 +1,10 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {



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

module.import("./dynamic-e8bd5876.js");

}
};
});
@@ -0,0 +1 @@
export const DYNAMIC_USED_BY_A = 'DYNAMIC_USED_BY_A';
1 change: 1 addition & 0 deletions test/chunking-form/samples/manual-chunks-dynamic/main.js
@@ -0,0 +1 @@
import('./dynamic.js');

0 comments on commit 1db6679

Please sign in to comment.