@nx/webpack 16.4.0-beta.9 → 16.5.0-beta.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/migrations.json CHANGED
@@ -40,6 +40,15 @@
40
40
  "alwaysAddToPackageJson": false
41
41
  }
42
42
  }
43
+ },
44
+ "16.4.1": {
45
+ "version": "16.4.1-beta.0",
46
+ "packages": {
47
+ "webpack": {
48
+ "version": "^5.80.0",
49
+ "alwaysAddToPackageJson": false
50
+ }
51
+ }
43
52
  }
44
53
  }
45
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "16.4.0-beta.9",
3
+ "version": "16.5.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -30,18 +30,18 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/core": "^7.15.0",
33
- "@nrwl/webpack": "16.4.0-beta.9",
34
- "@nx/devkit": "16.4.0-beta.9",
35
- "@nx/js": "16.4.0-beta.9",
33
+ "@nrwl/webpack": "16.5.0-beta.0",
34
+ "@nx/devkit": "16.5.0-beta.0",
35
+ "@nx/js": "16.5.0-beta.0",
36
36
  "autoprefixer": "^10.4.9",
37
37
  "babel-loader": "^9.1.2",
38
+ "browserslist": "^4.21.4",
38
39
  "chalk": "^4.1.0",
39
40
  "chokidar": "^3.5.1",
40
41
  "copy-webpack-plugin": "^10.2.4",
41
42
  "css-loader": "^6.4.0",
42
43
  "css-minimizer-webpack-plugin": "^5.0.0",
43
44
  "dotenv": "~10.0.0",
44
- "file-loader": "^6.2.0",
45
45
  "fork-ts-checker-webpack-plugin": "7.2.13",
46
46
  "ignore": "^5.0.4",
47
47
  "less": "4.1.3",
@@ -75,5 +75,5 @@
75
75
  "access": "public"
76
76
  },
77
77
  "types": "./index.d.ts",
78
- "gitHead": "b7fbc25d5be1789d42805e2254cf4a6070889157"
78
+ "gitHead": "376d656cfc7f6390ff1cd6d9de348baf7bccbf33"
79
79
  }
@@ -21,27 +21,22 @@ function ssrDevServerExecutor(options, context) {
21
21
  const combined = (0, async_iterable_1.combineAsyncIterables)(runBrowser, runServer);
22
22
  process.env['port'] = `${options.port}`;
23
23
  try {
24
- for (var _f = true, combined_1 = tslib_1.__asyncValues(combined), combined_1_1; combined_1_1 = yield tslib_1.__await(combined_1.next()), _c = combined_1_1.done, !_c;) {
24
+ for (var _f = true, combined_1 = tslib_1.__asyncValues(combined), combined_1_1; combined_1_1 = yield tslib_1.__await(combined_1.next()), _c = combined_1_1.done, !_c; _f = true) {
25
25
  _e = combined_1_1.value;
26
26
  _f = false;
27
- try {
28
- const output = _e;
29
- if (!output.success)
30
- throw new Error('Could not build application');
31
- if (((_a = output.options) === null || _a === void 0 ? void 0 : _a.target) === 'node') {
32
- nodeStarted = true;
33
- }
34
- else if (((_b = output.options) === null || _b === void 0 ? void 0 : _b.target) === 'web') {
35
- browserBuilt = true;
36
- }
37
- if (nodeStarted && browserBuilt) {
38
- yield tslib_1.__await((0, wait_until_server_is_listening_1.waitUntilServerIsListening)(options.port));
39
- console.log(`[ ${chalk.green('ready')} ] on http://localhost:${options.port}`);
40
- yield yield tslib_1.__await(Object.assign(Object.assign({}, output), { baseUrl: `http://localhost:${options.port}` }));
41
- }
27
+ const output = _e;
28
+ if (!output.success)
29
+ throw new Error('Could not build application');
30
+ if (((_a = output.options) === null || _a === void 0 ? void 0 : _a.target) === 'node') {
31
+ nodeStarted = true;
42
32
  }
43
- finally {
44
- _f = true;
33
+ else if (((_b = output.options) === null || _b === void 0 ? void 0 : _b.target) === 'web') {
34
+ browserBuilt = true;
35
+ }
36
+ if (nodeStarted && browserBuilt) {
37
+ yield tslib_1.__await((0, wait_until_server_is_listening_1.waitUntilServerIsListening)(options.port));
38
+ console.log(`[ ${chalk.green('ready')} ] on http://localhost:${options.port}`);
39
+ yield yield tslib_1.__await(Object.assign(Object.assign({}, output), { baseUrl: `http://localhost:${options.port}` }));
45
40
  }
46
41
  }
47
42
  }
@@ -12,15 +12,16 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  module.exports = require('babel-loader').custom(() => {
13
13
  return {
14
14
  customOptions(_a) {
15
- var { isModern, emitDecoratorMetadata } = _a, loader = __rest(_a, ["isModern", "emitDecoratorMetadata"]);
15
+ var { isTest, isModern, emitDecoratorMetadata } = _a, loader = __rest(_a, ["isTest", "isModern", "emitDecoratorMetadata"]);
16
16
  return {
17
- custom: { isModern, emitDecoratorMetadata },
17
+ custom: { isTest, isModern, emitDecoratorMetadata },
18
18
  loader,
19
19
  };
20
20
  },
21
- config(cfg, { customOptions: { isModern, emitDecoratorMetadata } }) {
21
+ config(cfg, { customOptions: { isTest, isModern, emitDecoratorMetadata } }) {
22
22
  // Add hint to our babel preset so it can handle modern vs legacy bundles.
23
23
  cfg.options.caller.isModern = isModern;
24
+ cfg.options.caller.isTest = isTest;
24
25
  cfg.options.caller.emitDecoratorMetadata = emitDecoratorMetadata;
25
26
  return cfg.options;
26
27
  },
@@ -16,6 +16,7 @@ export declare function createLoaderFromCompiler(options: NormalizedWebpackExecu
16
16
  cwd: string;
17
17
  emitDecoratorMetadata: boolean;
18
18
  isModern: boolean;
19
+ isTest: boolean;
19
20
  envName: string;
20
21
  cacheDirectory: boolean;
21
22
  cacheCompression: boolean;
@@ -2,23 +2,43 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLoaderFromCompiler = exports.withNx = void 0;
4
4
  const path = require("path");
5
+ const path_1 = require("path");
5
6
  const webpack_1 = require("webpack");
6
7
  const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
7
8
  const js_1 = require("@nx/js");
8
9
  const license_webpack_plugin_1 = require("license-webpack-plugin");
9
- const TerserPlugin = require("terser-webpack-plugin");
10
- const nodeExternals = require("webpack-node-externals");
11
- const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
12
10
  const stats_json_plugin_1 = require("../plugins/stats-json-plugin");
13
11
  const create_copy_plugin_1 = require("./create-copy-plugin");
14
12
  const generate_package_json_plugin_1 = require("../plugins/generate-package-json-plugin");
15
13
  const hash_format_1 = require("./hash-format");
14
+ const fs_1 = require("fs");
15
+ const TerserPlugin = require("terser-webpack-plugin");
16
+ const nodeExternals = require("webpack-node-externals");
17
+ const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
18
+ const browserslist = require("browserslist");
19
+ const VALID_BROWSERSLIST_FILES = ['.browserslistrc', 'browserslist'];
20
+ function getTerserEcmaVersion(projectRoot) {
21
+ let pathToBrowserslistFile = '';
22
+ for (const browserslistFile of VALID_BROWSERSLIST_FILES) {
23
+ const fullPathToFile = (0, path_1.join)(projectRoot, browserslistFile);
24
+ if ((0, fs_1.existsSync)(fullPathToFile)) {
25
+ pathToBrowserslistFile = fullPathToFile;
26
+ break;
27
+ }
28
+ }
29
+ if (!pathToBrowserslistFile) {
30
+ return 2020;
31
+ }
32
+ const env = browserslist.loadConfig({ path: pathToBrowserslistFile });
33
+ const browsers = browserslist(env);
34
+ return browsers.includes('ie 11') ? 5 : 2020;
35
+ }
16
36
  const IGNORED_WEBPACK_WARNINGS = [
17
37
  /The comment file/i,
18
38
  /could not find any license/i,
19
39
  ];
20
40
  const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
21
- const mainFields = ['main', 'module'];
41
+ const mainFields = ['module', 'main'];
22
42
  const processed = new Set();
23
43
  /**
24
44
  * @param {WithNxOptions} pluginOptions
@@ -143,7 +163,7 @@ function withNx(pluginOptions) {
143
163
  parallel: true,
144
164
  terserOptions: {
145
165
  keep_classnames: true,
146
- ecma: 2020,
166
+ ecma: getTerserEcmaVersion((0, path_1.join)(options.root, options.projectRoot)),
147
167
  safari10: true,
148
168
  format: {
149
169
  ascii_only: true,
@@ -267,6 +287,7 @@ function createLoaderFromCompiler(options) {
267
287
  cwd: path.join(options.root, options.sourceRoot),
268
288
  emitDecoratorMetadata: tsConfig.options.emitDecoratorMetadata,
269
289
  isModern: true,
290
+ isTest: process.env.NX_CYPRESS_COMPONENT_TEST === 'true',
270
291
  envName: (_a = process.env.BABEL_ENV) !== null && _a !== void 0 ? _a : process.env.NODE_ENV,
271
292
  cacheDirectory: true,
272
293
  cacheCompression: false,
@@ -309,20 +309,38 @@ function withWeb(pluginOptions = {}) {
309
309
  config.resolve.mainFields = ['browser', 'module', 'main'];
310
310
  config.module = Object.assign(Object.assign({}, config.module), { rules: [
311
311
  ...((_c = config.module.rules) !== null && _c !== void 0 ? _c : []),
312
+ // Images: Inline small images, and emit a separate file otherwise.
312
313
  {
313
- test: /\.(bmp|png|jpe?g|gif|webp|avif)$/,
314
+ test: /\.(avif|bmp|gif|ico|jpe?g|png|webp)$/,
314
315
  type: 'asset',
315
316
  parser: {
316
317
  dataUrlCondition: {
317
318
  maxSize: 10000, // 10 kB
318
319
  },
319
320
  },
321
+ generator: {
322
+ filename: `[name]${hashFormat.file}[ext]`,
323
+ },
324
+ },
325
+ // SVG: same as image but we need to separate it so it can be swapped for SVGR in the React plugin.
326
+ {
327
+ test: /\.svg$/,
328
+ type: 'asset',
329
+ parser: {
330
+ dataUrlCondition: {
331
+ maxSize: 10000, // 10 kB
332
+ },
333
+ },
334
+ generator: {
335
+ filename: `[name]${hashFormat.file}[ext]`,
336
+ },
320
337
  },
338
+ // Fonts: Emit separate file and export the URL.
321
339
  {
322
- test: /\.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
323
- loader: require.resolve('file-loader'),
324
- options: {
325
- name: `[name]${hashFormat.file}.[ext]`,
340
+ test: /\.(eot|otf|ttf|woff|woff2)$/,
341
+ type: 'asset/resource',
342
+ generator: {
343
+ filename: `[name]${hashFormat.file}[ext]`,
326
344
  },
327
345
  },
328
346
  ...rules,