@financial-times/dotcom-build-code-splitting 11.3.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-build-code-splitting",
3
- "version": "11.3.0",
3
+ "version": "12.0.0",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "types": "dist/node/index.d.ts",
@@ -17,17 +17,13 @@
17
17
  "author": "",
18
18
  "license": "MIT",
19
19
  "peerDependencies": {
20
- "webpack": "^4.39.2"
20
+ "webpack": "5.x"
21
21
  },
22
22
  "dependencies": {
23
23
  "assign-deep": "^1.0.1",
24
- "disable-tree-shaking-for-chunk-plugin": "^1.1.0",
24
+ "disable-tree-shaking-for-chunk-plugin": "^2.0.0",
25
25
  "get-package-name": "^1.1.0",
26
- "memoize-one": "^5.0.4",
27
- "reliable-module-ids-plugin": "^1.0.1"
28
- },
29
- "devDependencies": {
30
- "@types/webpack": "^4.41.7"
26
+ "memoize-one": "^5.0.4"
31
27
  },
32
28
  "engines": {
33
29
  "node": "18.x || 20.x || 22.x"
@@ -1,5 +1,5 @@
1
1
  import { promisify } from 'util'
2
- import webpack, { Configuration as WebpackConfiguration, Stats } from 'webpack'
2
+ import webpack, { Configuration as WebpackConfiguration } from 'webpack'
3
3
  import path from 'path'
4
4
  import { PageKitCodeSplittingPlugin } from '../index'
5
5
 
@@ -17,12 +17,16 @@ describe('dotcom-build-code-splitting', () => {
17
17
  },
18
18
  plugins: [new PageKitCodeSplittingPlugin()]
19
19
  }
20
- const result = (await webpackAsync([webpackConfig])) as { stats: [Stats] }
20
+ const result = await webpackAsync([webpackConfig])
21
+ if (!result) {
22
+ throw new Error('No webpack result')
23
+ }
21
24
 
22
25
  const stats = result.stats[0].toJson()
23
26
  if (!stats) {
24
27
  throw new Error('No stats')
25
28
  }
29
+
26
30
  const files = stats.assets?.map((asset) => asset.name) as string[]
27
31
  expect(files.find((file) => file.includes('privacy-components'))).toBeTruthy()
28
32
  })
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import assignDeep from 'assign-deep'
2
- import ReliableModuleIdsPlugin from 'reliable-module-ids-plugin'
3
2
  import type webpack from 'webpack'
4
3
 
5
4
  import {
@@ -19,11 +18,9 @@ export class PageKitCodeSplittingPlugin {
19
18
  name: 'webpack-runtime'
20
19
  },
21
20
  splitChunks: {
22
- chunks: 'all'
23
- },
24
- // We're going to implement our own algorithm so don't double effort
25
- moduleIds: false,
26
- chunkIds: 'named'
21
+ chunks: 'all',
22
+ name: compiler.options.mode === 'development' ? 'vendors' : false
23
+ }
27
24
  }
28
25
  }
29
26
 
@@ -92,8 +89,6 @@ export class PageKitCodeSplittingPlugin {
92
89
  usedInUnknownWay: true
93
90
  })
94
91
 
95
- new ReliableModuleIdsPlugin().apply(compiler)
96
-
97
92
  assignDeep(
98
93
  compiler.options,
99
94
  addInitialCodeSplitting,