@nx/webpack 18.0.0-beta.0 → 18.0.0-beta.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/generators.json +2 -2
- package/index.d.ts +1 -1
- package/index.js +3 -2
- package/package.json +5 -5
- package/src/executors/webpack/schema.d.ts +1 -1
- package/src/executors/webpack/schema.json +1 -1
- package/src/generators/configuration/configuration.d.ts +1 -0
- package/src/generators/configuration/configuration.js +12 -5
- package/src/generators/configuration/schema.d.ts +1 -0
- package/src/generators/configuration/schema.json +1 -1
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +10 -6
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +1 -1
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +1 -1
- package/src/plugins/plugin.js +0 -2
- package/src/utils/module-federation/secondary-entry-points.js +1 -1
- package/src/utils/module-federation/typescript.js +14 -9
- package/src/utils/webpack/deprecated-stylus-loader.js +2 -2
- package/src/utils/webpack/plugins/postcss-cli-resources.js +2 -2
package/generators.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": "0.1",
|
|
4
4
|
"generators": {
|
|
5
5
|
"init": {
|
|
6
|
-
"factory": "./src/generators/init/init#
|
|
6
|
+
"factory": "./src/generators/init/init#webpackInitGeneratorInternal",
|
|
7
7
|
"schema": "./src/generators/init/schema.json",
|
|
8
8
|
"description": "Initialize the `@nrwl/webpack` plugin.",
|
|
9
9
|
"aliases": ["ng-add"],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"configuration": {
|
|
13
13
|
"aliases": ["webpack-project"],
|
|
14
|
-
"factory": "./src/generators/configuration/configuration",
|
|
14
|
+
"factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
|
|
15
15
|
"schema": "./src/generators/configuration/schema.json",
|
|
16
16
|
"description": "Add webpack configuration to a project.",
|
|
17
17
|
"hidden": true
|
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { configurationGenerator };
|
|
|
4
4
|
export declare const webpackProjectGenerator: typeof configurationGenerator;
|
|
5
5
|
export * from './src/utils/create-copy-plugin';
|
|
6
6
|
export * from './src/utils/config';
|
|
7
|
-
export
|
|
7
|
+
export { webpackInitGenerator } from './src/generators/init/init';
|
|
8
8
|
export type { WebDevServerOptions } from './src/executors/dev-server/schema';
|
|
9
9
|
export * from './src/executors/dev-server/dev-server.impl';
|
|
10
10
|
export * from './src/executors/webpack/lib/normalize-options';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NxTsconfigPathsWebpackPlugin = exports.NxWebpackPlugin = exports.webpackProjectGenerator = exports.configurationGenerator = void 0;
|
|
3
|
+
exports.NxTsconfigPathsWebpackPlugin = exports.NxWebpackPlugin = exports.webpackInitGenerator = exports.webpackProjectGenerator = exports.configurationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const configuration_1 = require("./src/generators/configuration/configuration");
|
|
6
6
|
Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
|
|
@@ -9,7 +9,8 @@ Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get
|
|
|
9
9
|
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
10
10
|
tslib_1.__exportStar(require("./src/utils/create-copy-plugin"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./src/utils/config"), exports);
|
|
12
|
-
|
|
12
|
+
var init_1 = require("./src/generators/init/init");
|
|
13
|
+
Object.defineProperty(exports, "webpackInitGenerator", { enumerable: true, get: function () { return init_1.webpackInitGenerator; } });
|
|
13
14
|
tslib_1.__exportStar(require("./src/executors/dev-server/dev-server.impl"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./src/executors/webpack/lib/normalize-options"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./src/executors/webpack/webpack.impl"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "18.0.0-beta.
|
|
3
|
+
"version": "18.0.0-beta.2",
|
|
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": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"migrations": "./migrations.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@babel/core": "^7.
|
|
32
|
+
"@babel/core": "^7.23.2",
|
|
33
33
|
"autoprefixer": "^10.4.9",
|
|
34
34
|
"babel-loader": "^9.1.2",
|
|
35
35
|
"browserslist": "^4.21.4",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"webpack-dev-server": "^4.9.3",
|
|
63
63
|
"webpack-node-externals": "^3.0.0",
|
|
64
64
|
"webpack-subresource-integrity": "^5.1.0",
|
|
65
|
-
"@nx/devkit": "18.0.0-beta.
|
|
66
|
-
"@nx/js": "18.0.0-beta.
|
|
67
|
-
"@nrwl/webpack": "18.0.0-beta.
|
|
65
|
+
"@nx/devkit": "18.0.0-beta.2",
|
|
66
|
+
"@nx/js": "18.0.0-beta.2",
|
|
67
|
+
"@nrwl/webpack": "18.0.0-beta.2"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
@@ -47,7 +47,7 @@ export interface WebpackExecutorOptions {
|
|
|
47
47
|
extractLicenses?: boolean;
|
|
48
48
|
fileReplacements?: FileReplacement[];
|
|
49
49
|
generatePackageJson?: boolean;
|
|
50
|
-
// TODO(
|
|
50
|
+
// TODO(v19): Remove this option
|
|
51
51
|
/** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
|
|
52
52
|
isolatedConfig?: boolean;
|
|
53
53
|
standardWebpackConfigFunction?: boolean;
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
"type": "boolean",
|
|
236
236
|
"description": "Do not apply Nx webpack plugins automatically. Plugins need to be applied in the project's webpack.config.js file (e.g. withNx, withReact, etc.).",
|
|
237
237
|
"default": true,
|
|
238
|
-
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx
|
|
238
|
+
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 19. See https://nx.dev/recipes/webpack/webpack-config-setup."
|
|
239
239
|
},
|
|
240
240
|
"standardWebpackConfigFunction": {
|
|
241
241
|
"type": "boolean",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { ConfigurationGeneratorSchema } from './schema';
|
|
3
3
|
export declare function configurationGenerator(tree: Tree, options: ConfigurationGeneratorSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
export declare function configurationGeneratorInternal(tree: Tree, options: ConfigurationGeneratorSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
5
|
export default configurationGenerator;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configurationGenerator = void 0;
|
|
3
|
+
exports.configurationGeneratorInternal = exports.configurationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const init_1 = require("../init/init");
|
|
6
6
|
const has_plugin_1 = require("../../utils/has-plugin");
|
|
7
7
|
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
8
|
-
|
|
8
|
+
function configurationGenerator(tree, options) {
|
|
9
|
+
return configurationGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
10
|
+
}
|
|
11
|
+
exports.configurationGenerator = configurationGenerator;
|
|
12
|
+
async function configurationGeneratorInternal(tree, options) {
|
|
13
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
9
14
|
const task = await (0, init_1.webpackInitGenerator)(tree, {
|
|
10
15
|
...options,
|
|
11
16
|
skipFormat: true,
|
|
@@ -23,7 +28,7 @@ async function configurationGenerator(tree, options) {
|
|
|
23
28
|
}
|
|
24
29
|
return task;
|
|
25
30
|
}
|
|
26
|
-
exports.
|
|
31
|
+
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
27
32
|
function checkForTargetConflicts(tree, options) {
|
|
28
33
|
if (options.skipValidation)
|
|
29
34
|
return;
|
|
@@ -49,10 +54,11 @@ function createWebpackConfig(tree, options) {
|
|
|
49
54
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
50
55
|
? `
|
|
51
56
|
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
57
|
+
const { join } = require('path');
|
|
52
58
|
|
|
53
59
|
module.exports = {
|
|
54
60
|
output: {
|
|
55
|
-
path: '${buildOptions.outputPath}',
|
|
61
|
+
path: join(__dirname, '${buildOptions.outputPath}'),
|
|
56
62
|
},
|
|
57
63
|
plugins: [
|
|
58
64
|
new NxWebpackPlugin({
|
|
@@ -79,10 +85,11 @@ module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
|
79
85
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
80
86
|
? `
|
|
81
87
|
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
88
|
+
const { join } = require('path');
|
|
82
89
|
|
|
83
90
|
module.exports = {
|
|
84
91
|
output: {
|
|
85
|
-
path: '${buildOptions.outputPath}',
|
|
92
|
+
path: join(__dirname, '${buildOptions.outputPath}'),
|
|
86
93
|
},
|
|
87
94
|
plugins: [
|
|
88
95
|
new NxWebpackPlugin({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function webpackInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function webpackInitGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default webpackInitGenerator;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webpackInitGenerator = void 0;
|
|
3
|
+
exports.webpackInitGeneratorInternal = exports.webpackInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const plugin_1 = require("../../plugins/plugin");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function webpackInitGenerator(tree, schema) {
|
|
9
|
+
return webpackInitGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
10
|
+
}
|
|
11
|
+
exports.webpackInitGenerator = webpackInitGenerator;
|
|
12
|
+
async function webpackInitGeneratorInternal(tree, schema) {
|
|
13
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
14
|
+
if (schema.addPlugin) {
|
|
11
15
|
addPlugin(tree);
|
|
12
16
|
}
|
|
13
17
|
let installTask = () => { };
|
|
@@ -16,7 +20,7 @@ async function webpackInitGenerator(tree, schema) {
|
|
|
16
20
|
'@nx/webpack': versions_1.nxVersion,
|
|
17
21
|
'@nx/web': versions_1.nxVersion,
|
|
18
22
|
};
|
|
19
|
-
if (
|
|
23
|
+
if (schema.addPlugin) {
|
|
20
24
|
devDependencies['webpack-cli'] = versions_1.webpackCliVersion;
|
|
21
25
|
}
|
|
22
26
|
installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
|
|
@@ -29,7 +33,7 @@ async function webpackInitGenerator(tree, schema) {
|
|
|
29
33
|
}
|
|
30
34
|
return installTask;
|
|
31
35
|
}
|
|
32
|
-
exports.
|
|
36
|
+
exports.webpackInitGeneratorInternal = webpackInitGeneratorInternal;
|
|
33
37
|
function addPlugin(tree) {
|
|
34
38
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
35
39
|
nxJson.plugins ??= [];
|
|
@@ -46,7 +46,7 @@ function createLoaderFromCompiler(options) {
|
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
case 'babel':
|
|
49
|
-
const tsConfig = (0, js_1.readTsConfig)(options.tsConfig);
|
|
49
|
+
const tsConfig = (0, js_1.readTsConfig)(path.join(options.root, options.tsConfig));
|
|
50
50
|
const babelConfig = {
|
|
51
51
|
test: /\.([jt])sx?$/,
|
|
52
52
|
loader: path.join(__dirname, '../../../utils/web-babel-loader'),
|
package/src/plugins/plugin.js
CHANGED
|
@@ -57,9 +57,7 @@ exports.createNodes = [
|
|
|
57
57
|
];
|
|
58
58
|
async function createWebpackTargets(configFilePath, projectRoot, options, context) {
|
|
59
59
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
60
|
-
global.NX_GRAPH_CREATION = true;
|
|
61
60
|
const webpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
|
|
62
|
-
delete global.NX_GRAPH_CREATION;
|
|
63
61
|
const webpackOptions = await (0, read_webpack_options_1.readWebpackOptions)(webpackConfig);
|
|
64
62
|
const outputPath = normalizeOutputPath(webpackOptions.output?.path, projectRoot);
|
|
65
63
|
const targets = {};
|
|
@@ -6,7 +6,7 @@ const fs_1 = require("fs");
|
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const nx_1 = require("@nx/devkit/nx");
|
|
8
8
|
let { readModulePackageJson } = (0, nx_1.requireNx)();
|
|
9
|
-
// TODO: Remove this in Nx
|
|
9
|
+
// TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
|
|
10
10
|
readModulePackageJson =
|
|
11
11
|
readModulePackageJson ??
|
|
12
12
|
require('nx/src/utils/package-json').readModulePackageJson;
|
|
@@ -4,18 +4,23 @@ exports.getRootTsConfigPath = exports.readTsConfig = exports.readTsPathMappings
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
let tsConfig;
|
|
8
|
-
let tsPathMappings;
|
|
7
|
+
let tsConfig = new Map();
|
|
8
|
+
let tsPathMappings = new Map();
|
|
9
9
|
function readTsPathMappings(tsConfigPath = process.env.NX_TSCONFIG_PATH ?? getRootTsConfigPath()) {
|
|
10
|
-
if (tsPathMappings) {
|
|
11
|
-
return tsPathMappings;
|
|
10
|
+
if (tsPathMappings.has(tsConfigPath)) {
|
|
11
|
+
return tsPathMappings.get(tsConfigPath);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (!tsConfig.has(tsConfigPath)) {
|
|
14
|
+
tsConfig.set(tsConfigPath, readTsConfiguration(tsConfigPath));
|
|
15
|
+
}
|
|
16
|
+
tsPathMappings.set(tsConfigPath, {});
|
|
17
|
+
Object.entries(tsConfig.get(tsConfigPath).options?.paths ?? {}).forEach(([alias, paths]) => {
|
|
18
|
+
tsPathMappings.set(tsConfigPath, {
|
|
19
|
+
...tsPathMappings.get(tsConfigPath),
|
|
20
|
+
[alias]: paths.map((path) => path.replace(/^\.\//, '')),
|
|
21
|
+
});
|
|
17
22
|
});
|
|
18
|
-
return tsPathMappings;
|
|
23
|
+
return tsPathMappings.get(tsConfigPath);
|
|
19
24
|
}
|
|
20
25
|
exports.readTsPathMappings = readTsPathMappings;
|
|
21
26
|
function readTsConfiguration(tsConfigPath) {
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
const stylusLoader = require("stylus-loader");
|
|
6
|
-
// TOOD(
|
|
6
|
+
// TOOD(v19): Remove this file and stylus support.
|
|
7
7
|
function default_1(source) {
|
|
8
|
-
devkit_1.logger.warn(`Stylus is support is deprecated and will be removed in Nx
|
|
8
|
+
devkit_1.logger.warn(`Stylus is support is deprecated and will be removed in Nx 19. We recommend that you migrate to Sass by renaming \`.styl\` files to \`.scss\` and ensuring that the content is valid Sass.`);
|
|
9
9
|
return stylusLoader.call(this, source);
|
|
10
10
|
}
|
|
11
11
|
exports.default = default_1;
|
|
@@ -122,7 +122,7 @@ function PostcssCliResources(options) {
|
|
|
122
122
|
const resourceCache = new Map();
|
|
123
123
|
return Promise.all(urlDeclarations.map(async (decl) => {
|
|
124
124
|
const value = decl.value;
|
|
125
|
-
const urlRegex = /url
|
|
125
|
+
const urlRegex = /url(?:\(\s*['"]?)(.*?)(?:['"]?\s*\))/g;
|
|
126
126
|
const segments = [];
|
|
127
127
|
let match;
|
|
128
128
|
let lastIndex = 0;
|
|
@@ -131,7 +131,7 @@ function PostcssCliResources(options) {
|
|
|
131
131
|
const inputFile = decl.source && decl.source.input.file;
|
|
132
132
|
const context = (inputFile && path.dirname(inputFile)) || loader.context;
|
|
133
133
|
while ((match = urlRegex.exec(value))) {
|
|
134
|
-
const originalUrl = match[1]
|
|
134
|
+
const originalUrl = match[1];
|
|
135
135
|
let processedUrl;
|
|
136
136
|
try {
|
|
137
137
|
processedUrl = await process(originalUrl, context, resourceCache);
|