sku 11.0.4 → 11.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # sku
2
2
 
3
+ ## 11.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Include node_modules in node builds ([#651](https://github.com/seek-oss/sku/pull/651))
8
+
9
+ Previously, sku would only compile code within your src folder, plus any compile packages, for builds targetting the node environment. While this results in faster builds, it can sometimes lead to incorrect versions of packages being resolved due to clashing version range requirements. All node_modules will now included in the compilation by default, ensuring the correct package version is always required.
10
+
11
+ The old behaviour can be re-enabled via the new `externalizeNodeModules` config.
12
+
3
13
  ## 11.0.4
4
14
 
5
15
  ### Patch Changes
@@ -39,6 +39,7 @@ const {
39
39
  cspExtraScriptSrcHosts,
40
40
  rootResolution,
41
41
  skipPackageCompatibilityCompilation,
42
+ externalizeNodeModules,
42
43
  } = config;
43
44
 
44
45
  // port is only required for dev builds
@@ -268,19 +269,21 @@ const makeWebpackConfig = ({
268
269
  // render will run within the same process
269
270
  target: `browserslist:${nodeTarget}`,
270
271
  externals: [
271
- // Don't bundle or transpile non-compiled packages
272
- nodeExternals({
273
- allowlist: [
274
- 'classnames', // Workaround for https://github.com/JedWatson/classnames/issues/240
272
+ // Don't bundle or transpile non-compiled packages if externalizeNodeModules is enabled
273
+ externalizeNodeModules
274
+ ? nodeExternals({
275
+ allowlist: [
276
+ 'classnames', // Workaround for https://github.com/JedWatson/classnames/issues/240
275
277
 
276
- // webpack-node-externals compares the `import` or `require` expression to this list,
277
- // not the package name, so we map each packageName to a pattern. This ensures it
278
- // matches when importing a file within a package e.g. import { Text } from 'seek-style-guide/react'.
279
- ...paths.compilePackages.map(
280
- (packageName) => new RegExp(`^(${packageName})`),
281
- ),
282
- ],
283
- }),
278
+ // webpack-node-externals compares the `import` or `require` expression to this list,
279
+ // not the package name, so we map each packageName to a pattern. This ensures it
280
+ // matches when importing a file within a package e.g. import { Text } from 'seek-style-guide/react'.
281
+ ...paths.compilePackages.map(
282
+ (packageName) => new RegExp(`^(${packageName})`),
283
+ ),
284
+ ],
285
+ })
286
+ : {},
284
287
  ],
285
288
  output: {
286
289
  path: paths.target,
@@ -30,6 +30,7 @@ const {
30
30
  useDevServerMiddleware,
31
31
  rootResolution,
32
32
  skipPackageCompatibilityCompilation,
33
+ externalizeNodeModules,
33
34
  } = require('../../context');
34
35
  const { getVocabConfig } = require('../vocab/vocab');
35
36
  const statsConfig = require('./statsConfig');
@@ -225,17 +226,20 @@ const makeWebpackConfig = ({
225
226
  {
226
227
  __sku_alias__webpackStats: `commonjs ./${webpackStatsFilename}`,
227
228
  },
228
- nodeExternals({
229
- modulesDir: findUp.sync('node_modules'), // Allow usage within project subdirectories (required for tests)
230
- allowlist: [
231
- // webpack-node-externals compares the `import` or `require` expression to this list,
232
- // not the package name, so we map each packageName to a pattern. This ensures it
233
- // matches when importing a file within a package e.g. import { Text } from 'seek-style-guide/react'.
234
- ...paths.compilePackages.map(
235
- (packageName) => new RegExp(`^(${packageName})`),
236
- ),
237
- ],
238
- }),
229
+ // Don't bundle or transpile non-compiled packages if externalizeNodeModules is enabled
230
+ externalizeNodeModules
231
+ ? nodeExternals({
232
+ modulesDir: findUp.sync('node_modules'), // Allow usage within project subdirectories (required for tests)
233
+ allowlist: [
234
+ // webpack-node-externals compares the `import` or `require` expression to this list,
235
+ // not the package name, so we map each packageName to a pattern. This ensures it
236
+ // matches when importing a file within a package e.g. import { Text } from 'seek-style-guide/react'.
237
+ ...paths.compilePackages.map(
238
+ (packageName) => new RegExp(`^(${packageName})`),
239
+ ),
240
+ ],
241
+ })
242
+ : {},
239
243
  ],
240
244
  resolve: {
241
245
  alias: {
@@ -190,4 +190,7 @@ module.exports = validator.compile({
190
190
  persistentCache: {
191
191
  type: 'boolean',
192
192
  },
193
+ externalizeNodeModules: {
194
+ type: 'boolean',
195
+ },
193
196
  });
@@ -45,4 +45,5 @@ module.exports = {
45
45
  languages: null,
46
46
  skipPackageCompatibilityCompilation: [],
47
47
  persistentCache: true,
48
+ externalizeNodeModules: false,
48
49
  };
package/context/index.js CHANGED
@@ -171,4 +171,5 @@ module.exports = {
171
171
  skipPackageCompatibilityCompilation:
172
172
  skuConfig.skipPackageCompatibilityCompilation,
173
173
  persistentCache: skuConfig.persistentCache,
174
+ externalizeNodeModules: skuConfig.externalizeNodeModules,
174
175
  };
@@ -143,6 +143,14 @@ Default: `[]`
143
143
 
144
144
  An array of environments the app supports. Apps should have one environment for local development plus one for each environment they're deployed to. Use this value to drive app config (e.g. `analyticsEnabled` or `apiEndpoint`). See [static-rendering](./docs/static-rendering.md) for more info.
145
145
 
146
+ ## externalizeNodeModules
147
+
148
+ type `boolean`
149
+
150
+ Default: `false`
151
+
152
+ By default, sku compiles all node_modules in builds that target node. Setting this option to `true` will instead externalize all node_modules, excluding `compilePackages`.
153
+
146
154
  ## skipPackageCompatibilityCompilation
147
155
 
148
156
  type `Array<string>`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sku",
3
- "version": "11.0.4",
3
+ "version": "11.1.0",
4
4
  "description": "Front-end development toolkit, powered by Webpack, Babel, CSS Modules, Less and Jest",
5
5
  "main": "index.js",
6
6
  "bin": {