@financial-times/dotcom-build-code-splitting 7.3.0 → 7.3.2

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,17 +1,16 @@
1
1
  {
2
2
  "name": "@financial-times/dotcom-build-code-splitting",
3
- "version": "7.3.0",
3
+ "version": "7.3.2",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "tsc": "../../node_modules/.bin/tsc --incremental",
10
9
  "clean": "npm run clean:dist && npm run clean:node_modules",
11
10
  "clean:dist": "rm -rf dist",
12
11
  "clean:node_modules": "rm -rf node_modules",
12
+ "build:node": "tsc",
13
13
  "build": "npm run build:node",
14
- "build:node": "npm run tsc -- --module commonjs --outDir ./dist/node",
15
14
  "dev": "npm run build:node -- --watch",
16
15
  "preinstall": "[ \"$INIT_CWD\" != \"$PWD\" ] || npm_config_yes=true npx check-engine"
17
16
  },
@@ -36,6 +35,10 @@
36
35
  "node": ">= 14.0.0",
37
36
  "npm": "7.x || 8.x"
38
37
  },
38
+ "files": [
39
+ "dist/",
40
+ "src/"
41
+ ],
39
42
  "repository": {
40
43
  "type": "git",
41
44
  "repository": "https://github.com/Financial-Times/dotcom-page-kit.git",
@@ -45,4 +48,4 @@
45
48
  "volta": {
46
49
  "extends": "../../package.json"
47
50
  }
48
- }
51
+ }
@@ -0,0 +1,3 @@
1
+ exports.privacy1 = function() {
2
+ return 'module-privacy-1-' + Date.now()
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "privacy-module-1",
3
+ "main": "index.js"
4
+ }
@@ -0,0 +1,3 @@
1
+ exports.privacy2 = function() {
2
+ return 'module-privacy-2-' + Date.now()
3
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "privacy-module-2",
3
+ "main": "index.js"
4
+ }
@@ -0,0 +1,4 @@
1
+ const { privacy1 } = require('./@financial-times/privacy-module-1');
2
+ const { privacy2 } = require('./@financial-times/privacy-module-2');
3
+
4
+ console.log(privacy1(), privacy2())
@@ -0,0 +1,36 @@
1
+ import { PageKitCodeSplittingPlugin } from '../index'
2
+ import webpack from 'webpack'
3
+ import path from 'path'
4
+
5
+ describe('dotcom-build-code-splitting', () => {
6
+ it('create chunk for privacy modules', async () => {
7
+ await new Promise((resolve) =>
8
+ webpack(
9
+ {
10
+ mode: 'none',
11
+ entry: {
12
+ scripts: path.join(__dirname, '/__fixtures__', 'entry-point.js')
13
+ },
14
+ output: {
15
+ filename: '[name].js',
16
+ path: path.join(__dirname, '/tmp')
17
+ },
18
+ plugins: [new PageKitCodeSplittingPlugin()]
19
+ },
20
+ function (error, stats) {
21
+ if (error) {
22
+ throw error
23
+ } else if (stats.hasErrors()) {
24
+ throw stats.toString()
25
+ }
26
+
27
+ const files = stats.toJson().assets.map((asset) => asset.name)
28
+
29
+ expect(files).toEqual(expect.arrayContaining(['privacy-components.js']))
30
+
31
+ resolve()
32
+ }
33
+ )
34
+ )
35
+ })
36
+ })