diff --git a/packages/server/__fixtures__/letters-A.js b/packages/server/__fixtures__/letters-A.js new file mode 100644 index 00000000..86cb8c57 --- /dev/null +++ b/packages/server/__fixtures__/letters-A.js @@ -0,0 +1 @@ +module.exports = 'a' \ No newline at end of file diff --git a/packages/server/__fixtures__/letters-B.js b/packages/server/__fixtures__/letters-B.js new file mode 100644 index 00000000..d4e19d71 --- /dev/null +++ b/packages/server/__fixtures__/letters-B.js @@ -0,0 +1 @@ +module.exports = 'b' \ No newline at end of file diff --git a/packages/server/__fixtures__/letters-C.js b/packages/server/__fixtures__/letters-C.js new file mode 100644 index 00000000..0e2e00cb --- /dev/null +++ b/packages/server/__fixtures__/letters-C.js @@ -0,0 +1 @@ +module.exports = 'c' \ No newline at end of file diff --git a/packages/server/__fixtures__/letters-D.js b/packages/server/__fixtures__/letters-D.js new file mode 100644 index 00000000..3bf8a442 --- /dev/null +++ b/packages/server/__fixtures__/letters-D.js @@ -0,0 +1 @@ +module.exports = 'd' \ No newline at end of file diff --git a/packages/server/__fixtures__/letters-E.js b/packages/server/__fixtures__/letters-E.js new file mode 100644 index 00000000..a1dcc04e --- /dev/null +++ b/packages/server/__fixtures__/letters-E.js @@ -0,0 +1 @@ +module.exports = 'e' \ No newline at end of file diff --git a/packages/server/src/ChunkExtractor.js b/packages/server/src/ChunkExtractor.js index 46b54772..3b2d9705 100644 --- a/packages/server/src/ChunkExtractor.js +++ b/packages/server/src/ChunkExtractor.js @@ -307,6 +307,21 @@ class ChunkExtractor { const assets = this.getChunkAssets(entrypoint) const mainAsset = assets.find(asset => asset.scriptType === 'script') invariant(mainAsset, 'asset not found') + + this.stats.assets + .filter(({ name }) => { + const type = extensionToScriptType( + path + .extname(name) + .split('?')[0] + .toLowerCase(), + ) + return type === 'script' + }) + .forEach(({ name }) => { + smartRequire(path.join(this.outputPath, name.split('?')[0])) + }) + return smartRequire(mainAsset.path) }