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

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.
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createBundlesForRegExp = exports.createBundlesForPackages = exports.createBundleWithRegExp = exports.createBundleWithPackages = void 0;
6
+ exports.createBundleWithPackages = createBundleWithPackages;
7
+ exports.createBundleWithRegExp = createBundleWithRegExp;
8
+ exports.createBundlesForPackages = createBundlesForPackages;
9
+ exports.createBundlesForRegExp = createBundlesForRegExp;
7
10
  const extractPackageName_1 = __importDefault(require("./extractPackageName"));
8
11
  const createSafeChunkName_1 = __importDefault(require("./createSafeChunkName"));
9
12
  const disable_tree_shaking_for_chunk_plugin_1 = __importDefault(require("disable-tree-shaking-for-chunk-plugin"));
@@ -25,7 +28,7 @@ function createBundleWithPackages({ compiler, name, packages, usedInUnknownWay }
25
28
  [name]: {
26
29
  name,
27
30
  test: (module) => {
28
- const packageName = isJS(module) && extractPackageName_1.default(module.context);
31
+ const packageName = isJS(module) && (0, extractPackageName_1.default)(module.context);
29
32
  return packageName ? packages.includes(packageName) : false;
30
33
  },
31
34
  enforce: true
@@ -35,7 +38,6 @@ function createBundleWithPackages({ compiler, name, packages, usedInUnknownWay }
35
38
  }
36
39
  };
37
40
  }
38
- exports.createBundleWithPackages = createBundleWithPackages;
39
41
  /**
40
42
  * Create a chunk which includes all modules which match the given pattern
41
43
  */
@@ -62,7 +64,6 @@ function createBundleWithRegExp({ compiler, name, pattern, usedInUnknownWay }) {
62
64
  }
63
65
  };
64
66
  }
65
- exports.createBundleWithRegExp = createBundleWithRegExp;
66
67
  /**
67
68
  * Create a chunk for each package in the given list of names
68
69
  */
@@ -80,13 +81,13 @@ function createBundlesForPackages({ compiler, name, packages, usedInUnknownWay }
80
81
  cacheGroups: {
81
82
  [name]: {
82
83
  name(module) {
83
- const packageName = extractPackageName_1.default(module.context);
84
- const chunkName = createSafeChunkName_1.default(packageName);
84
+ const packageName = (0, extractPackageName_1.default)(module.context);
85
+ const chunkName = (0, createSafeChunkName_1.default)(packageName);
85
86
  generatedChunkNames.add(chunkName);
86
87
  return chunkName;
87
88
  },
88
89
  test(module) {
89
- const packageName = isJS(module) && extractPackageName_1.default(module.context);
90
+ const packageName = isJS(module) && (0, extractPackageName_1.default)(module.context);
90
91
  return packageName ? packages.includes(packageName) : false;
91
92
  },
92
93
  enforce: true
@@ -96,7 +97,6 @@ function createBundlesForPackages({ compiler, name, packages, usedInUnknownWay }
96
97
  }
97
98
  };
98
99
  }
99
- exports.createBundlesForPackages = createBundlesForPackages;
100
100
  /**
101
101
  * Create a chunk for each group of modules which match the given pattern
102
102
  */
@@ -114,8 +114,8 @@ function createBundlesForRegExp({ compiler, name, pattern, usedInUnknownWay }) {
114
114
  cacheGroups: {
115
115
  [name]: {
116
116
  name(module) {
117
- const packageName = extractPackageName_1.default(module.context);
118
- const chunkName = createSafeChunkName_1.default(packageName);
117
+ const packageName = (0, extractPackageName_1.default)(module.context);
118
+ const chunkName = (0, createSafeChunkName_1.default)(packageName);
119
119
  generatedChunkNames.add(chunkName);
120
120
  return chunkName;
121
121
  },
@@ -129,4 +129,3 @@ function createBundlesForRegExp({ compiler, name, pattern, usedInUnknownWay }) {
129
129
  }
130
130
  };
131
131
  }
132
- exports.createBundlesForRegExp = createBundlesForRegExp;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = createSafeChunkName;
3
4
  function createSafeChunkName(name) {
4
5
  // Remove or replace any non-safe filename characters
5
6
  return name.replace('@', '').replace('/', '-');
6
7
  }
7
- exports.default = createSafeChunkName;
@@ -8,7 +8,7 @@ const get_package_name_1 = __importDefault(require("get-package-name"));
8
8
  const moduleType = /(node_modules)/;
9
9
  function extractPackageName(modulePath) {
10
10
  const type = modulePath.match(moduleType);
11
- return Array.isArray(type) ? get_package_name_1.default(modulePath, type[type.length - 1]) : null;
11
+ return Array.isArray(type) ? (0, get_package_name_1.default)(modulePath, type[type.length - 1]) : null;
12
12
  }
13
13
  // Memoize these calls as modules often need to be resolved many times.
14
- exports.default = memoize_one_1.default(extractPackageName);
14
+ exports.default = (0, memoize_one_1.default)(extractPackageName);
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PageKitCodeSplittingPlugin = void 0;
7
7
  const assign_deep_1 = __importDefault(require("assign-deep"));
8
- const reliable_module_ids_plugin_1 = __importDefault(require("reliable-module-ids-plugin"));
9
8
  const bundleTypes_1 = require("./bundleTypes");
10
9
  class PageKitCodeSplittingPlugin {
11
10
  apply(compiler) {
@@ -17,51 +16,49 @@ class PageKitCodeSplittingPlugin {
17
16
  name: 'webpack-runtime'
18
17
  },
19
18
  splitChunks: {
20
- chunks: 'all'
21
- },
22
- // We're going to implement our own algorithm so don't double effort
23
- moduleIds: false,
24
- chunkIds: 'named'
19
+ chunks: 'all',
20
+ name: compiler.options.mode === 'development' ? 'vendors' : false
21
+ }
25
22
  }
26
23
  };
27
24
  // Split each o-, n-, x- and next- prefixed packages into a separate bundles
28
25
  // NOTE: we need to check we're in a package directory as our apps are usually prefixed with "next-"
29
- const addComponentCodeSplitting = bundleTypes_1.createBundlesForRegExp({
26
+ const addComponentCodeSplitting = (0, bundleTypes_1.createBundlesForRegExp)({
30
27
  compiler,
31
28
  name: 'shared-components',
32
29
  pattern: /(node_modules\/@financial-times)\/(o|n|x|next)-/,
33
30
  usedInUnknownWay: true
34
31
  });
35
32
  // split all dotcom-ui- packages into one bundle file
36
- const addPageKitCodeSplittingPlugin = bundleTypes_1.createBundleWithRegExp({
33
+ const addPageKitCodeSplittingPlugin = (0, bundleTypes_1.createBundleWithRegExp)({
37
34
  compiler,
38
35
  name: 'page-kit-components',
39
36
  pattern: /[\\\/]dotcom-ui-/,
40
37
  usedInUnknownWay: true
41
38
  });
42
39
  // split any of these JS frameworks and libraries into separate bundle files
43
- const addLibraryCodeSplitting = bundleTypes_1.createBundlesForPackages({
40
+ const addLibraryCodeSplitting = (0, bundleTypes_1.createBundlesForPackages)({
44
41
  compiler,
45
42
  name: 'js-frameworks',
46
43
  packages: ['react', 'preact', 'hyperons', 'dateformat', 'regenerator-runtime']
47
44
  });
48
45
  // These packages are a dependency of ads, marketing, MyFT, syndication, cookie banners
49
46
  // and other components but they are not all dependencies of our apps.
50
- const addSuperstoreCodeSplitting = bundleTypes_1.createBundleWithPackages({
47
+ const addSuperstoreCodeSplitting = (0, bundleTypes_1.createBundleWithPackages)({
51
48
  compiler,
52
49
  name: 'superstore',
53
50
  packages: ['superstore', 'superstore-sync'],
54
51
  usedInUnknownWay: true
55
52
  });
56
53
  // split all privacy- packages into one bundle file
57
- const addPrivacyCodeSplitting = bundleTypes_1.createBundleWithRegExp({
54
+ const addPrivacyCodeSplitting = (0, bundleTypes_1.createBundleWithRegExp)({
58
55
  compiler,
59
56
  name: 'privacy-components',
60
57
  pattern: /@financial-times\/privacy-/,
61
58
  usedInUnknownWay: true
62
59
  });
63
60
  // split packages used by all pages (i.e. used by Page Kit) into a shared bundle
64
- const addSharedStableCodeSplitting = bundleTypes_1.createBundleWithPackages({
61
+ const addSharedStableCodeSplitting = (0, bundleTypes_1.createBundleWithPackages)({
65
62
  compiler,
66
63
  name: 'shared.stable',
67
64
  packages: [
@@ -76,14 +73,13 @@ class PageKitCodeSplittingPlugin {
76
73
  usedInUnknownWay: true
77
74
  });
78
75
  // split packages which are commonly used together around FT.com into a shared bundle
79
- const addSharedVolatileCodeSplitting = bundleTypes_1.createBundleWithPackages({
76
+ const addSharedVolatileCodeSplitting = (0, bundleTypes_1.createBundleWithPackages)({
80
77
  compiler,
81
78
  name: 'shared.volatile',
82
79
  packages: ['@financial-times/n-tracking', '@financial-times/n-syndication'],
83
80
  usedInUnknownWay: true
84
81
  });
85
- new reliable_module_ids_plugin_1.default().apply(compiler);
86
- assign_deep_1.default(compiler.options, addInitialCodeSplitting, addPageKitCodeSplittingPlugin, addLibraryCodeSplitting, addComponentCodeSplitting, addSuperstoreCodeSplitting, addPrivacyCodeSplitting, addSharedStableCodeSplitting, addSharedVolatileCodeSplitting);
82
+ (0, assign_deep_1.default)(compiler.options, addInitialCodeSplitting, addPageKitCodeSplittingPlugin, addLibraryCodeSplitting, addComponentCodeSplitting, addSuperstoreCodeSplitting, addPrivacyCodeSplitting, addSharedStableCodeSplitting, addSharedVolatileCodeSplitting);
87
83
  }
88
84
  }
89
85
  exports.PageKitCodeSplittingPlugin = PageKitCodeSplittingPlugin;