@nx/webpack 19.0.0-beta.8 → 19.0.0-beta.9

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
@@ -1,29 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "add-babel-inputs": {
4
- "cli": "nx",
5
- "version": "15.0.0-beta.0",
6
- "description": "Adds babel.config.json to the hash of all tasks",
7
- "factory": "./src/migrations/update-15-0-0/add-babel-inputs"
8
- },
9
- "remove-es2015-polyfills-option": {
10
- "cli": "nx",
11
- "version": "15.4.5-beta.0",
12
- "description": "Removes es2015Polyfills option since legacy browsers are no longer supported.",
13
- "factory": "./src/migrations/update-15-4-5/remove-es2015-polyfills-option"
14
- },
15
- "webpack-config-setup": {
16
- "cli": "nx",
17
- "version": "15.6.3-beta.0",
18
- "description": "Creates or updates webpack.config.js file with the new options for webpack.",
19
- "factory": "./src/migrations/update-15-6-3/webpack-config-setup"
20
- },
21
- "add-babelUpwardRootMode-flag": {
22
- "cli": "nx",
23
- "version": "15.7.2-beta.0",
24
- "description": "Add the babelUpwardRootMode option to the build executor options.",
25
- "factory": "./src/migrations/update-15-7-2/add-babelUpwardRootMode-flag"
26
- },
27
3
  "update-16-0-0-add-nx-packages": {
28
4
  "cli": "nx",
29
5
  "version": "16.0.0-beta.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "19.0.0-beta.8",
3
+ "version": "19.0.0-beta.9",
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": {
@@ -63,9 +63,9 @@
63
63
  "webpack-dev-server": "^4.9.3",
64
64
  "webpack-node-externals": "^3.0.0",
65
65
  "webpack-subresource-integrity": "^5.1.0",
66
- "@nx/devkit": "19.0.0-beta.8",
67
- "@nx/js": "19.0.0-beta.8",
68
- "@nrwl/webpack": "19.0.0-beta.8"
66
+ "@nx/devkit": "19.0.0-beta.9",
67
+ "@nx/js": "19.0.0-beta.9",
68
+ "@nrwl/webpack": "19.0.0-beta.9"
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public"
@@ -4,12 +4,7 @@ exports.collectPackageSecondaryEntryPoints = exports.recursivelyCollectSecondary
4
4
  const path_1 = require("path");
5
5
  const fs_1 = require("fs");
6
6
  const devkit_1 = require("@nx/devkit");
7
- const nx_1 = require("@nx/devkit/nx");
8
- let { readModulePackageJson } = (0, nx_1.requireNx)();
9
- // TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
10
- readModulePackageJson =
11
- readModulePackageJson ??
12
- require('nx/src/utils/package-json').readModulePackageJson;
7
+ const package_json_1 = require("nx/src/utils/package-json");
13
8
  function collectWorkspaceLibrarySecondaryEntryPoints(library, tsconfigPathAliases) {
14
9
  const libraryRoot = (0, path_1.join)(devkit_1.workspaceRoot, library.root);
15
10
  const needsSecondaryEntryPointsCollected = (0, fs_1.existsSync)((0, path_1.join)(libraryRoot, 'ng-package.json'));
@@ -86,7 +81,7 @@ function collectPackageSecondaryEntryPoints(pkgName, pkgVersion, collectedPackag
86
81
  let packageJsonPath;
87
82
  let packageJson;
88
83
  try {
89
- ({ path: packageJsonPath, packageJson } = readModulePackageJson(pkgName));
84
+ ({ path: packageJsonPath, packageJson } = (0, package_json_1.readModulePackageJson)(pkgName));
90
85
  pathToPackage = (0, path_1.dirname)(packageJsonPath);
91
86
  }
92
87
  catch {
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
5
- async function default_1(tree) {
6
- (0, add_babel_inputs_1.addBabelInputs)(tree);
7
- await (0, devkit_1.formatFiles)(tree);
8
- }
9
- exports.default = default_1;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- async function default_1(tree) {
5
- const projects = (0, devkit_1.getProjects)(tree);
6
- projects.forEach((p) => {
7
- let shouldUpdate = false;
8
- Object.entries(p.targets).forEach(([name, config]) => {
9
- if (p.targets?.[name]?.executor === '@nrwl/webpack:webpack' &&
10
- p.targets?.[name]?.options.es2015Polyfills) {
11
- delete p.targets?.[name]?.options.es2015Polyfills;
12
- shouldUpdate = true;
13
- }
14
- });
15
- if (shouldUpdate) {
16
- (0, devkit_1.updateProjectConfiguration)(tree, p.name, p);
17
- }
18
- });
19
- }
20
- exports.default = default_1;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
5
- const path_1 = require("path");
6
- async function default_1(tree) {
7
- // Since projects can have multiple configurations, we need to know if the default options
8
- // need to be migrated or not. If so then the subsequent configurations with `webpackConfig` also need to be.
9
- const defaultOptionsUpdated = new Set();
10
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/webpack:webpack', (options, projectName, targetName, configurationName) => {
11
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
12
- const defaultOptions = projectConfiguration.targets[targetName].options;
13
- const defaultWasUpdated = defaultOptionsUpdated.has(projectName);
14
- // If default was not updated (for different configurations), we don't do anything
15
- // If isolatedConfig is set, we don't need to do anything
16
- // If project is React, we don't need to do anything
17
- if (!defaultWasUpdated &&
18
- (defaultOptions?.isolatedConfig ||
19
- defaultOptions?.main?.match(/main\.(t|j)sx$/) ||
20
- defaultOptions?.webpackConfig === '@nrwl/react/plugins/webpack')) {
21
- return;
22
- }
23
- defaultOptionsUpdated.add(projectName);
24
- // If this is not the base options (e.g. for development, production, or something custom),
25
- // then skip it unless it specifically configures a webpackConfig file
26
- if (configurationName && !options?.webpackConfig) {
27
- return;
28
- }
29
- // If webpackConfig is set, update it with the new options
30
- // If webpackConfig is not set, we need to create a new
31
- // webpack.config.js file and set the path to it in the
32
- // executor options
33
- if (options?.webpackConfig) {
34
- let oldName = options.webpackConfig;
35
- if (options.webpackConfig.endsWith('.js')) {
36
- oldName = options.webpackConfig.replace('.js', '.old.js');
37
- }
38
- if (options.webpackConfig.endsWith('.ts')) {
39
- oldName = options.webpackConfig.replace('.ts', '.old.ts');
40
- }
41
- renameFile(tree, options.webpackConfig, oldName);
42
- const justTheFileName = (0, path_1.basename)(oldName);
43
- tree.write(options.webpackConfig, `
44
- const { composePlugins, withNx } = require('@nrwl/webpack');
45
-
46
- // Nx plugins for webpack.
47
- module.exports = composePlugins(withNx(), (config, { options, context }) => {
48
- // Note: This was added by an Nx migration.
49
- // You should consider inlining the logic into this file.
50
- // For more information on webpack config and Nx see:
51
- // https://nx.dev/recipes/webpack/webpack-config-setup
52
- return require('./${justTheFileName}')(config, context);
53
- });
54
- `);
55
- options.isolatedConfig = true;
56
- projectConfiguration.targets[targetName][configurationName ?? 'options'] = options;
57
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
58
- devkit_1.logger.info(`
59
- ${options.webpackConfig} has been renamed to ${oldName} and a new ${options.webpackConfig}
60
- has been created for your project ${projectName}.
61
- You should consider inlining the logic from ${oldName} into ${options.webpackConfig}.
62
- You can read our guide on how to do this here:
63
-
64
- https://nx.dev/recipes/webpack/webpack-config-setup
65
- `);
66
- }
67
- else {
68
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
69
- if (!options) {
70
- options = {};
71
- }
72
- options.webpackConfig = `${projectConfiguration.root}/webpack.config.js`;
73
- options.isolatedConfig = true;
74
- tree.write(options.webpackConfig, `
75
- const { composePlugins, withNx } = require('@nrwl/webpack');
76
-
77
- // Nx plugins for webpack.
78
- module.exports = composePlugins(withNx(), (config) => {
79
- // Update the webpack config as needed here.
80
- // e.g. config.plugins.push(new MyPlugin())
81
- // For more information on webpack config and Nx see:
82
- // https://nx.dev/recipes/webpack/webpack-config-setup
83
- return config;
84
- });
85
- `);
86
- projectConfiguration.targets[targetName].options = options;
87
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
88
- }
89
- });
90
- await (0, devkit_1.formatFiles)(tree);
91
- }
92
- exports.default = default_1;
93
- function renameFile(tree, from, to) {
94
- const buffer = tree.read(from);
95
- if (!buffer) {
96
- return;
97
- }
98
- tree.write(to, buffer);
99
- tree.delete(from);
100
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
5
- async function default_1(tree) {
6
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/webpack:webpack', (options, projectName, targetName, _configurationName) => {
7
- if (options.babelUpwardRootMode !== undefined) {
8
- return;
9
- }
10
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
11
- projectConfiguration.targets[targetName].options.babelUpwardRootMode =
12
- true;
13
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
14
- });
15
- await (0, devkit_1.formatFiles)(tree);
16
- }
17
- exports.default = default_1;