@nx/webpack 18.0.0-beta.1 → 18.0.0-beta.3
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 +4 -4
- package/src/generators/configuration/configuration.d.ts +3 -2
- package/src/generators/configuration/configuration.js +23 -7
- package/src/generators/configuration/schema.d.ts +1 -0
- 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/plugins/nx-webpack-plugin/lib/compiler-loaders.js +1 -1
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +1 -1
- package/src/plugins/plugin.js +0 -2
- package/src/utils/with-nx.js +1 -0
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.3",
|
|
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": {
|
|
@@ -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.3",
|
|
66
|
+
"@nx/js": "18.0.0-beta.3",
|
|
67
|
+
"@nrwl/webpack": "18.0.0-beta.3"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { ConfigurationGeneratorSchema } from './schema';
|
|
3
|
-
export declare function configurationGenerator(tree: Tree, options: ConfigurationGeneratorSchema): Promise<
|
|
3
|
+
export declare function configurationGenerator(tree: Tree, options: ConfigurationGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function configurationGeneratorInternal(tree: Tree, options: ConfigurationGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
5
|
export default configurationGenerator;
|
|
@@ -1,15 +1,27 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
8
|
+
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
9
|
+
function configurationGenerator(tree, options) {
|
|
10
|
+
return configurationGeneratorInternal(tree, { addPlugin: false, ...options });
|
|
11
|
+
}
|
|
12
|
+
exports.configurationGenerator = configurationGenerator;
|
|
13
|
+
async function configurationGeneratorInternal(tree, options) {
|
|
14
|
+
const tasks = [];
|
|
15
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
16
|
+
const initTask = await (0, init_1.webpackInitGenerator)(tree, {
|
|
10
17
|
...options,
|
|
11
18
|
skipFormat: true,
|
|
12
19
|
});
|
|
20
|
+
tasks.push(initTask);
|
|
21
|
+
const depsTask = (0, ensure_dependencies_1.ensureDependencies)(tree, {
|
|
22
|
+
compiler: options.compiler === 'babel' ? undefined : options.compiler,
|
|
23
|
+
});
|
|
24
|
+
tasks.push(depsTask);
|
|
13
25
|
checkForTargetConflicts(tree, options);
|
|
14
26
|
if (!(0, has_plugin_1.hasPlugin)(tree)) {
|
|
15
27
|
addBuildTarget(tree, options);
|
|
@@ -21,9 +33,9 @@ async function configurationGenerator(tree, options) {
|
|
|
21
33
|
if (!options.skipFormat) {
|
|
22
34
|
await (0, devkit_1.formatFiles)(tree);
|
|
23
35
|
}
|
|
24
|
-
return
|
|
36
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
25
37
|
}
|
|
26
|
-
exports.
|
|
38
|
+
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
27
39
|
function checkForTargetConflicts(tree, options) {
|
|
28
40
|
if (options.skipValidation)
|
|
29
41
|
return;
|
|
@@ -49,10 +61,11 @@ function createWebpackConfig(tree, options) {
|
|
|
49
61
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
50
62
|
? `
|
|
51
63
|
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
64
|
+
const { join } = require('path');
|
|
52
65
|
|
|
53
66
|
module.exports = {
|
|
54
67
|
output: {
|
|
55
|
-
path: '${buildOptions.outputPath}',
|
|
68
|
+
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
56
69
|
},
|
|
57
70
|
plugins: [
|
|
58
71
|
new NxWebpackPlugin({
|
|
@@ -60,6 +73,7 @@ module.exports = {
|
|
|
60
73
|
tsConfig: '${buildOptions.tsConfig}',
|
|
61
74
|
compiler: '${buildOptions.compiler}',
|
|
62
75
|
main: '${buildOptions.main}',
|
|
76
|
+
outputHashing: '${buildOptions.target !== 'web' ? 'none' : 'all'}',
|
|
63
77
|
})
|
|
64
78
|
],
|
|
65
79
|
}
|
|
@@ -79,10 +93,11 @@ module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
|
79
93
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
80
94
|
? `
|
|
81
95
|
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
96
|
+
const { join } = require('path');
|
|
82
97
|
|
|
83
98
|
module.exports = {
|
|
84
99
|
output: {
|
|
85
|
-
path: '${buildOptions.outputPath}',
|
|
100
|
+
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
86
101
|
},
|
|
87
102
|
plugins: [
|
|
88
103
|
new NxWebpackPlugin({
|
|
@@ -90,6 +105,7 @@ module.exports = {
|
|
|
90
105
|
tsConfig: '${buildOptions.tsConfig}',
|
|
91
106
|
compiler: '${buildOptions.compiler}',
|
|
92
107
|
main: '${buildOptions.main}',
|
|
108
|
+
outputHashing: '${buildOptions.target !== 'web' ? 'none' : 'all'}',
|
|
93
109
|
})
|
|
94
110
|
],
|
|
95
111
|
}
|
|
@@ -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'),
|
|
@@ -65,7 +65,7 @@ function normalizeOptions(options) {
|
|
|
65
65
|
sourceMap: options.sourceMap ?? !isProd,
|
|
66
66
|
sourceRoot,
|
|
67
67
|
styles: options.styles ?? [],
|
|
68
|
-
target: options.target
|
|
68
|
+
target: options.target,
|
|
69
69
|
targetName,
|
|
70
70
|
vendorChunk: options.vendorChunk ?? !isProd,
|
|
71
71
|
};
|
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 = {};
|
package/src/utils/with-nx.js
CHANGED