Skip to content

Commit 183b146

Browse files
committed
Re-adding the traditional createSharedEntry functionality
1 parent b4c5a81 commit 183b146

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
## 0.21.0 Webpack 4 Upgrade
44

5-
* Webpack was upgraded to version 4. This includes a number of major
5+
* [BC BREAK] Webpack was upgraded to version 4. This includes a number of major
66
and minor changes. The changes are listed below.
77

8+
* [BC BREAK] If you're using `createSharedEntry()`, the name of the
9+
`manifest.js` file is now `runtime.js`. You will need to update
10+
your `<script>` tag to point to the new `runtime.js`.
11+
812
* The NamedModulesPlugin was removed.
913

1014
* The `babel-preset-env` package (which was at version ^1.2.2) was

lib/config-generator.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,27 @@ class ConfigGenerator {
321321
optimization.namedModules = true;
322322
}
323323

324+
if (this.webpackConfig.sharedCommonsEntryName) {
325+
const cacheGroups = {};
326+
cacheGroups[this.webpackConfig.sharedCommonsEntryName] = {
327+
chunks: 'initial',
328+
name: this.webpackConfig.sharedCommonsEntryName,
329+
// important: setting this to the entry name means that
330+
// all modules included by that entry go into this cache group
331+
test: this.webpackConfig.sharedCommonsEntryName,
332+
// seems to default the rest of the options (like minSize)
333+
// to settings so that modules matched by "test" are
334+
// *definitely* included.
335+
enforce: true,
336+
};
337+
338+
optimization.splitChunks = {
339+
cacheGroups: cacheGroups
340+
};
341+
// causes a runtime.js to be emitted with the Webpack runtime
342+
optimization.runtimeChunk = 'single';
343+
}
344+
324345
return optimization;
325346
}
326347

0 commit comments

Comments
 (0)