@nx/webpack 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca
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/LICENSE +1 -1
- package/README.md +1 -1
- package/index.d.ts +1 -2
- package/index.js +1 -3
- package/migrations.json +28 -30
- package/package.json +11 -15
- package/src/executors/dev-server/dev-server.impl.d.ts +1 -1
- package/src/executors/dev-server/schema.json +1 -0
- package/src/executors/ssr-dev-server/schema.json +1 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +2 -2
- package/src/executors/webpack/lib/normalize-options.js +3 -0
- package/src/executors/webpack/schema.d.ts +3 -4
- package/src/executors/webpack/schema.json +15 -6
- package/src/executors/webpack/webpack.impl.js +1 -10
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +0 -8
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +4 -1
- package/src/generators/init/init.js +11 -1
- package/src/migrations/update-21-0-0/remove-isolated-config.js +41 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +49 -9
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +23 -5
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +2 -0
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +2 -0
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +6 -1
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +1 -1
- package/src/plugins/nx-webpack-plugin/lib/utils.d.ts +7 -0
- package/src/plugins/nx-webpack-plugin/lib/utils.js +48 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts +17 -3
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +4 -0
- package/src/plugins/plugin.d.ts +2 -0
- package/src/plugins/plugin.js +35 -7
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts +1 -1
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +6 -3
- package/src/plugins/webpack-nx-build-coordination-plugin.js +1 -1
- package/src/utils/config.js +4 -0
- package/src/utils/webpack/read-webpack-options.d.ts +3 -2
- package/src/utils/webpack/read-webpack-options.js +60 -23
- package/src/utils/with-web.d.ts +6 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-17-2-1/webpack-config-setup.js +0 -31
- package/src/utils/module-federation/dependencies.d.ts +0 -6
- package/src/utils/module-federation/dependencies.js +0 -56
- package/src/utils/module-federation/get-remotes-for-host.d.ts +0 -16
- package/src/utils/module-federation/get-remotes-for-host.js +0 -106
- package/src/utils/module-federation/index.d.ts +0 -6
- package/src/utils/module-federation/index.js +0 -9
- package/src/utils/module-federation/models/index.d.ts +0 -47
- package/src/utils/module-federation/models/index.js +0 -2
- package/src/utils/module-federation/package-json.d.ts +0 -8
- package/src/utils/module-federation/package-json.js +0 -12
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +0 -13
- package/src/utils/module-federation/parse-static-remotes-config.js +0 -34
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +0 -3
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +0 -54
- package/src/utils/module-federation/public-api.d.ts +0 -6
- package/src/utils/module-federation/public-api.js +0 -16
- package/src/utils/module-federation/remotes.d.ts +0 -19
- package/src/utils/module-federation/remotes.js +0 -79
- package/src/utils/module-federation/secondary-entry-points.d.ts +0 -12
- package/src/utils/module-federation/secondary-entry-points.js +0 -125
- package/src/utils/module-federation/share.d.ts +0 -48
- package/src/utils/module-federation/share.js +0 -240
- package/src/utils/module-federation/start-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-remote-proxies.js +0 -38
- package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -52
- package/src/utils/module-federation/typescript.d.ts +0 -4
- package/src/utils/module-federation/typescript.js +0 -53
- /package/src/migrations/{update-17-2-1/webpack-config-setup.d.ts → update-21-0-0/remove-isolated-config.d.ts} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://circleci.com/gh/nrwl/nx)
|
|
11
11
|
[]()
|
|
12
|
-
[](https://www.npmjs.com/package/nx)
|
|
13
13
|
[]()
|
|
14
14
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
15
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { useLegacyNxPlugin } from './src/plugins/use-legacy-nx-plugin/use-legacy
|
|
|
6
6
|
export { configurationGenerator, convertConfigToWebpackPluginGenerator, useLegacyNxPlugin, };
|
|
7
7
|
/** @deprecated Use `configurationGenerator` instead. */
|
|
8
8
|
export declare const webpackProjectGenerator: typeof configurationGenerator;
|
|
9
|
-
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
9
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
|
|
10
10
|
export declare const NxWebpackPlugin: typeof NxAppWebpackPlugin;
|
|
11
11
|
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
12
12
|
export declare const NxTsconfigPathsWebpackPlugin: typeof _NxTsconfigPathsWebpackPlugin;
|
|
@@ -21,5 +21,4 @@ export * from './src/executors/webpack/webpack.impl';
|
|
|
21
21
|
export * from './src/utils/get-css-module-local-ident';
|
|
22
22
|
export * from './src/utils/with-nx';
|
|
23
23
|
export * from './src/utils/with-web';
|
|
24
|
-
export * from './src/utils/module-federation/public-api';
|
|
25
24
|
export * from './src/utils/e2e-web-server-info-utils';
|
package/index.js
CHANGED
|
@@ -13,8 +13,7 @@ Object.defineProperty(exports, "useLegacyNxPlugin", { enumerable: true, get: fun
|
|
|
13
13
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
14
14
|
/** @deprecated Use `configurationGenerator` instead. */
|
|
15
15
|
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
16
|
-
|
|
17
|
-
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
16
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead, which can improve graph creation by 150-200ms per file. */
|
|
18
17
|
exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
|
|
19
18
|
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
20
19
|
exports.NxTsconfigPathsWebpackPlugin = nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin;
|
|
@@ -28,5 +27,4 @@ tslib_1.__exportStar(require("./src/executors/webpack/webpack.impl"), exports);
|
|
|
28
27
|
tslib_1.__exportStar(require("./src/utils/get-css-module-local-ident"), exports);
|
|
29
28
|
tslib_1.__exportStar(require("./src/utils/with-nx"), exports);
|
|
30
29
|
tslib_1.__exportStar(require("./src/utils/with-web"), exports);
|
|
31
|
-
tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
|
|
32
30
|
tslib_1.__exportStar(require("./src/utils/e2e-web-server-info-utils"), exports);
|
package/migrations.json
CHANGED
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"update-16-0-0-add-nx-packages": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "16.0.0-beta.1",
|
|
6
|
-
"description": "Replace @nrwl/webpack with @nx/webpack",
|
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
-
},
|
|
9
|
-
"update-17-2-1-webpack-config-setup": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "17.2.1-beta.0",
|
|
12
|
-
"description": "Add webpack.config.js file when webpackConfig is not defined",
|
|
13
|
-
"implementation": "./src/migrations/update-17-2-1/webpack-config-setup"
|
|
14
|
-
},
|
|
15
3
|
"update-19-6-3-proxy-config": {
|
|
16
4
|
"cli": "nx",
|
|
17
5
|
"version": "19.6.3-beta.0",
|
|
18
6
|
"description": "Migrate proxy config files to match new format from webpack-dev-server v5.",
|
|
19
7
|
"implementation": "./src/migrations/update-19-6-3/proxy-config"
|
|
8
|
+
},
|
|
9
|
+
"update-21-0-0-remove-isolated-config": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "21.0.0-beta.11",
|
|
12
|
+
"description": "Remove isolatedConfig option for @nx/webpack:webpack",
|
|
13
|
+
"implementation": "./src/migrations/update-21-0-0/remove-isolated-config"
|
|
20
14
|
}
|
|
21
15
|
},
|
|
22
16
|
"packageJsonUpdates": {
|
|
23
|
-
"16.3.0": {
|
|
24
|
-
"version": "16.3.0-beta.8",
|
|
25
|
-
"packages": {
|
|
26
|
-
"@svgr/webpack": {
|
|
27
|
-
"version": "^8.0.1",
|
|
28
|
-
"alwaysAddToPackageJson": false
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"16.4.1": {
|
|
33
|
-
"version": "16.4.1-beta.0",
|
|
34
|
-
"packages": {
|
|
35
|
-
"webpack": {
|
|
36
|
-
"version": "^5.80.0",
|
|
37
|
-
"alwaysAddToPackageJson": false
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
17
|
"19.6.0": {
|
|
42
18
|
"version": "19.6.0-beta.1",
|
|
43
19
|
"packages": {
|
|
@@ -59,6 +35,28 @@
|
|
|
59
35
|
"alwaysAddToPackageJson": false
|
|
60
36
|
}
|
|
61
37
|
}
|
|
38
|
+
},
|
|
39
|
+
"20.5.0": {
|
|
40
|
+
"version": "20.5.0-beta.3",
|
|
41
|
+
"packages": {
|
|
42
|
+
"sass-loader": {
|
|
43
|
+
"version": "^16.0.4",
|
|
44
|
+
"alwaysAddToPackageJson": false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"20.7.1": {
|
|
49
|
+
"version": "20.7.1-beta.0",
|
|
50
|
+
"packages": {
|
|
51
|
+
"webpack": {
|
|
52
|
+
"version": "5.98.0",
|
|
53
|
+
"alwaysAddToPackageJson": false
|
|
54
|
+
},
|
|
55
|
+
"webpack-dev-server": {
|
|
56
|
+
"version": "^5.2.1",
|
|
57
|
+
"alwaysAddToPackageJson": false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31313-387cdca",
|
|
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": {
|
|
@@ -32,19 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/core": "^7.23.2",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
|
-
"@module-federation/sdk": "^0.6.0",
|
|
36
|
-
"@module-federation/enhanced": "^0.6.0",
|
|
37
35
|
"ajv": "^8.12.0",
|
|
38
36
|
"autoprefixer": "^10.4.9",
|
|
39
37
|
"babel-loader": "^9.1.2",
|
|
40
38
|
"browserslist": "^4.21.4",
|
|
41
|
-
"
|
|
39
|
+
"picocolors": "^1.1.0",
|
|
42
40
|
"copy-webpack-plugin": "^10.2.4",
|
|
43
41
|
"css-loader": "^6.4.0",
|
|
44
42
|
"css-minimizer-webpack-plugin": "^5.0.0",
|
|
45
|
-
"express": "^4.19.2",
|
|
46
43
|
"fork-ts-checker-webpack-plugin": "7.2.13",
|
|
47
|
-
"http-proxy-middleware": "^3.0.0",
|
|
48
44
|
"less": "4.1.3",
|
|
49
45
|
"less-loader": "11.1.0",
|
|
50
46
|
"license-webpack-plugin": "^4.0.2",
|
|
@@ -55,8 +51,9 @@
|
|
|
55
51
|
"postcss-import": "~14.1.0",
|
|
56
52
|
"postcss-loader": "^6.1.1",
|
|
57
53
|
"rxjs": "^7.8.0",
|
|
58
|
-
"sass": "^1.
|
|
59
|
-
"sass-
|
|
54
|
+
"sass": "^1.85.0",
|
|
55
|
+
"sass-embedded": "^1.83.4",
|
|
56
|
+
"sass-loader": "^16.0.4",
|
|
60
57
|
"source-map-loader": "^5.0.0",
|
|
61
58
|
"style-loader": "^3.3.0",
|
|
62
59
|
"stylus": "^0.64.0",
|
|
@@ -65,17 +62,16 @@
|
|
|
65
62
|
"ts-loader": "^9.3.1",
|
|
66
63
|
"tsconfig-paths-webpack-plugin": "4.0.0",
|
|
67
64
|
"tslib": "^2.3.0",
|
|
68
|
-
"webpack": "
|
|
69
|
-
"webpack-dev-server": "^5.
|
|
65
|
+
"webpack": "5.98.0",
|
|
66
|
+
"webpack-dev-server": "^5.2.1",
|
|
70
67
|
"webpack-node-externals": "^3.0.0",
|
|
71
68
|
"webpack-subresource-integrity": "^5.1.0",
|
|
72
|
-
"@nx/devkit": "0.0.0-pr-
|
|
73
|
-
"@nx/js": "0.0.0-pr-
|
|
74
|
-
"@nrwl/webpack": "0.0.0-pr-31222-862e973"
|
|
69
|
+
"@nx/devkit": "0.0.0-pr-31313-387cdca",
|
|
70
|
+
"@nx/js": "0.0.0-pr-31313-387cdca"
|
|
75
71
|
},
|
|
76
72
|
"publishConfig": {
|
|
77
73
|
"access": "public"
|
|
78
74
|
},
|
|
79
|
-
"
|
|
80
|
-
"
|
|
75
|
+
"types": "./index.d.ts",
|
|
76
|
+
"type": "commonjs"
|
|
81
77
|
}
|
|
@@ -3,5 +3,5 @@ import { WebDevServerOptions } from './schema';
|
|
|
3
3
|
export declare function devServerExecutor(serveOptions: WebDevServerOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
success: boolean;
|
|
6
|
-
}, any,
|
|
6
|
+
}, any, any>;
|
|
7
7
|
export default devServerExecutor;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ssrDevServerExecutor = ssrDevServerExecutor;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const pc = require("picocolors");
|
|
6
6
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
7
|
const wait_until_server_is_listening_1 = require("./lib/wait-until-server-is-listening");
|
|
8
8
|
async function* ssrDevServerExecutor(options, context) {
|
|
@@ -26,7 +26,7 @@ async function* ssrDevServerExecutor(options, context) {
|
|
|
26
26
|
}
|
|
27
27
|
if (nodeStarted && browserBuilt) {
|
|
28
28
|
await (0, wait_until_server_is_listening_1.waitUntilServerIsListening)(options.port);
|
|
29
|
-
console.log(`[ ${
|
|
29
|
+
console.log(`[ ${pc.green('ready')} ] on http://localhost:${options.port}`);
|
|
30
30
|
yield {
|
|
31
31
|
...output,
|
|
32
32
|
baseUrl: `http://localhost:${options.port}`,
|
|
@@ -4,9 +4,11 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
exports.normalizePluginPath = normalizePluginPath;
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const normalize_options_1 = require("../../../plugins/nx-webpack-plugin/lib/normalize-options");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
function normalizeOptions(options, root, projectRoot, sourceRoot) {
|
|
8
9
|
const normalizedOptions = {
|
|
9
10
|
...options,
|
|
11
|
+
useTsconfigPaths: !(0, ts_solution_setup_1.isUsingTsSolutionSetup)(),
|
|
10
12
|
root,
|
|
11
13
|
projectRoot,
|
|
12
14
|
sourceRoot,
|
|
@@ -14,6 +16,7 @@ function normalizeOptions(options, root, projectRoot, sourceRoot) {
|
|
|
14
16
|
outputFileName: options.outputFileName ?? 'main.js',
|
|
15
17
|
webpackConfig: normalizePluginPath(options.webpackConfig, root),
|
|
16
18
|
fileReplacements: (0, normalize_options_1.normalizeFileReplacements)(root, options.fileReplacements),
|
|
19
|
+
sassImplementation: options.sassImplementation ?? 'sass',
|
|
17
20
|
optimization: typeof options.optimization !== 'object'
|
|
18
21
|
? {
|
|
19
22
|
scripts: options.optimization,
|
|
@@ -47,9 +47,6 @@ export interface WebpackExecutorOptions {
|
|
|
47
47
|
extractLicenses?: boolean;
|
|
48
48
|
fileReplacements?: FileReplacement[];
|
|
49
49
|
generatePackageJson?: boolean;
|
|
50
|
-
// TODO(v20): Remove this option
|
|
51
|
-
/** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
|
|
52
|
-
isolatedConfig?: boolean;
|
|
53
50
|
standardWebpackConfigFunction?: boolean;
|
|
54
51
|
main?: string;
|
|
55
52
|
memoryLimit?: number;
|
|
@@ -62,7 +59,7 @@ export interface WebpackExecutorOptions {
|
|
|
62
59
|
polyfills?: string;
|
|
63
60
|
progress?: boolean;
|
|
64
61
|
runtimeChunk?: boolean;
|
|
65
|
-
sourceMap?: boolean |
|
|
62
|
+
sourceMap?: boolean | string;
|
|
66
63
|
statsJson?: boolean;
|
|
67
64
|
target?: string;
|
|
68
65
|
transformers?: TransformerEntry[];
|
|
@@ -81,6 +78,7 @@ export interface WebpackExecutorOptions {
|
|
|
81
78
|
index?: string;
|
|
82
79
|
postcssConfig?: string;
|
|
83
80
|
scripts?: Array<ExtraEntryPointClass | string>;
|
|
81
|
+
sassImplementation?: 'sass' | 'sass-embedded';
|
|
84
82
|
stylePreprocessorOptions?: any;
|
|
85
83
|
styles?: Array<ExtraEntryPointClass | string>;
|
|
86
84
|
subresourceIntegrity?: boolean;
|
|
@@ -95,4 +93,5 @@ export interface NormalizedWebpackExecutorOptions
|
|
|
95
93
|
root: string;
|
|
96
94
|
projectRoot: string;
|
|
97
95
|
sourceRoot: string;
|
|
96
|
+
useTsconfigPaths: boolean;
|
|
98
97
|
}
|
|
@@ -70,6 +70,11 @@
|
|
|
70
70
|
"type": "boolean",
|
|
71
71
|
"description": "Use a separate bundle containing the runtime."
|
|
72
72
|
},
|
|
73
|
+
"skipTypeChecking": {
|
|
74
|
+
"alias": "typeCheck",
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"description": "Skip the type checking. Default is `false`."
|
|
77
|
+
},
|
|
73
78
|
"sourceMap": {
|
|
74
79
|
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
|
|
75
80
|
"oneOf": [
|
|
@@ -85,6 +90,10 @@
|
|
|
85
90
|
"type": "boolean",
|
|
86
91
|
"description": "Log progress to the console while building."
|
|
87
92
|
},
|
|
93
|
+
"poll": {
|
|
94
|
+
"type": "number",
|
|
95
|
+
"description": "Enable and define the file watching poll time period."
|
|
96
|
+
},
|
|
88
97
|
"assets": {
|
|
89
98
|
"type": "array",
|
|
90
99
|
"description": "List of static application assets.",
|
|
@@ -135,6 +144,12 @@
|
|
|
135
144
|
},
|
|
136
145
|
"additionalProperties": false
|
|
137
146
|
},
|
|
147
|
+
"sassImplementation": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"description": "The implementation of the SASS compiler to use. Can be either `sass` or `sass-embedded`. Defaults to `sass-embedded`.",
|
|
150
|
+
"enum": ["sass", "sass-embedded"],
|
|
151
|
+
"default": "sass"
|
|
152
|
+
},
|
|
138
153
|
"optimization": {
|
|
139
154
|
"description": "Enables optimization of the build output.",
|
|
140
155
|
"oneOf": [
|
|
@@ -239,12 +254,6 @@
|
|
|
239
254
|
"type": "boolean",
|
|
240
255
|
"description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or `<https://webpack.github.io/analyse>`."
|
|
241
256
|
},
|
|
242
|
-
"isolatedConfig": {
|
|
243
|
-
"type": "boolean",
|
|
244
|
-
"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.).",
|
|
245
|
-
"default": true,
|
|
246
|
-
"x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 20. See https://nx.dev/recipes/webpack/webpack-config-setup."
|
|
247
|
-
},
|
|
248
257
|
"standardWebpackConfigFunction": {
|
|
249
258
|
"type": "boolean",
|
|
250
259
|
"description": "Set to true if the webpack config exports a standard webpack function, not an Nx-specific one. See: https://webpack.js.org/configuration/configuration-types/#exporting-a-function",
|
|
@@ -11,13 +11,8 @@ const fs_1 = require("../../utils/fs");
|
|
|
11
11
|
const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
|
|
12
12
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
13
13
|
const config_1 = require("../../utils/config");
|
|
14
|
-
const with_nx_1 = require("../../utils/with-nx");
|
|
15
14
|
const js_1 = require("@nx/js");
|
|
16
|
-
const with_web_1 = require("../../utils/with-web");
|
|
17
15
|
async function getWebpackConfigs(options, context) {
|
|
18
|
-
if (options.isolatedConfig && !options.webpackConfig) {
|
|
19
|
-
throw new Error(`Using "isolatedConfig" without a "webpackConfig" is not supported.`);
|
|
20
|
-
}
|
|
21
16
|
let userDefinedWebpackConfig = null;
|
|
22
17
|
if (options.webpackConfig) {
|
|
23
18
|
userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(options.webpackConfig, (0, js_1.getRootTsConfigPath)());
|
|
@@ -25,11 +20,7 @@ async function getWebpackConfigs(options, context) {
|
|
|
25
20
|
userDefinedWebpackConfig = await userDefinedWebpackConfig;
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
const config =
|
|
29
|
-
? {}
|
|
30
|
-
: (options.target === 'web'
|
|
31
|
-
? (0, config_1.composePluginsSync)((0, with_nx_1.withNx)(options), (0, with_web_1.withWeb)(options))
|
|
32
|
-
: (0, with_nx_1.withNx)(options))({}, { options, context });
|
|
23
|
+
const config = {};
|
|
33
24
|
if (typeof userDefinedWebpackConfig === 'function' &&
|
|
34
25
|
((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
|
|
35
26
|
!options.standardWebpackConfigFunction)) {
|
|
@@ -90,14 +90,6 @@ function extractPluginOptions(options, context, configName) {
|
|
|
90
90
|
}
|
|
91
91
|
delete options.memoryLimit;
|
|
92
92
|
}
|
|
93
|
-
else if (key === 'isolatedConfig') {
|
|
94
|
-
context.logger.addLog({
|
|
95
|
-
executorName: '@nx/webpack:webpack',
|
|
96
|
-
log: `The 'isolatedConfig' option is deprecated and not supported by the NxAppWebpackPlugin. It was removed from your project configuration.`,
|
|
97
|
-
project: context.projectName,
|
|
98
|
-
});
|
|
99
|
-
delete options.isolatedConfig;
|
|
100
|
-
}
|
|
101
93
|
else if (key === 'standardWebpackConfigFunction') {
|
|
102
94
|
delete options.standardWebpackConfigFunction;
|
|
103
95
|
}
|
|
@@ -156,7 +156,10 @@ function extractDevServerOptions(options, context) {
|
|
|
156
156
|
return devServerOptions;
|
|
157
157
|
}
|
|
158
158
|
function applyDefaults(options, buildOptions) {
|
|
159
|
-
if (options
|
|
159
|
+
if (!options) {
|
|
160
|
+
options = {};
|
|
161
|
+
}
|
|
162
|
+
if (options?.port === undefined) {
|
|
160
163
|
options.port = 4200;
|
|
161
164
|
}
|
|
162
165
|
options.headers = { 'Access-Control-Allow-Origin': '*' };
|
|
@@ -15,7 +15,7 @@ async function webpackInitGeneratorInternal(tree, schema) {
|
|
|
15
15
|
nxJson.useInferencePlugins !== false;
|
|
16
16
|
schema.addPlugin ??= addPluginDefault;
|
|
17
17
|
if (schema.addPlugin) {
|
|
18
|
-
await (0, add_plugin_1.
|
|
18
|
+
await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/webpack/plugin', plugin_1.createNodesV2, {
|
|
19
19
|
buildTargetName: [
|
|
20
20
|
'build',
|
|
21
21
|
'webpack:build',
|
|
@@ -37,6 +37,16 @@ async function webpackInitGeneratorInternal(tree, schema) {
|
|
|
37
37
|
'webpack-preview',
|
|
38
38
|
'preview-webpack',
|
|
39
39
|
],
|
|
40
|
+
buildDepsTargetName: [
|
|
41
|
+
'build-deps',
|
|
42
|
+
'webpack:build-deps',
|
|
43
|
+
'webpack-build-deps',
|
|
44
|
+
],
|
|
45
|
+
watchDepsTargetName: [
|
|
46
|
+
'watch-deps',
|
|
47
|
+
'webpack:watch-deps',
|
|
48
|
+
'webpack-watch-deps',
|
|
49
|
+
],
|
|
40
50
|
}, schema.updatePackageScripts);
|
|
41
51
|
}
|
|
42
52
|
let installTask = () => { };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
async function default_1(tree) {
|
|
7
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/webpack:webpack', (options, projectName, targetName, configurationName) => {
|
|
8
|
+
// Only handle webpack config for default configuration
|
|
9
|
+
if (configurationName)
|
|
10
|
+
return;
|
|
11
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
12
|
+
if (!options.webpackConfig) {
|
|
13
|
+
delete options['isolatedConfig'];
|
|
14
|
+
options.webpackConfig = `${projectConfiguration.root}/webpack.config.js`;
|
|
15
|
+
tree.write(options.webpackConfig, options.target === 'web'
|
|
16
|
+
? `
|
|
17
|
+
const { composePlugins, withNx, withWeb } = require('@nx/webpack');
|
|
18
|
+
|
|
19
|
+
// Nx plugins for webpack.
|
|
20
|
+
module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
21
|
+
// Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
|
|
22
|
+
// See: https://nx.dev/recipes/webpack/webpack-config-setup
|
|
23
|
+
return config;
|
|
24
|
+
});
|
|
25
|
+
`
|
|
26
|
+
: `
|
|
27
|
+
const { composePlugins, withNx } = require('@nx/webpack');
|
|
28
|
+
|
|
29
|
+
// Nx plugins for webpack.
|
|
30
|
+
module.exports = composePlugins(withNx(), (config) => {
|
|
31
|
+
// Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
|
|
32
|
+
// See: https://nx.dev/recipes/webpack/webpack-config-setup
|
|
33
|
+
return config;
|
|
34
|
+
});
|
|
35
|
+
`);
|
|
36
|
+
projectConfiguration.targets[targetName].options = options;
|
|
37
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
41
|
+
}
|
|
@@ -14,10 +14,16 @@ const get_terser_ecma_version_1 = require("./get-terser-ecma-version");
|
|
|
14
14
|
const compiler_loaders_1 = require("./compiler-loaders");
|
|
15
15
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
16
16
|
const nodeExternals = require("webpack-node-externals");
|
|
17
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
17
19
|
const IGNORED_WEBPACK_WARNINGS = [
|
|
18
20
|
/The comment file/i,
|
|
19
21
|
/could not find any license/i,
|
|
20
22
|
];
|
|
23
|
+
const extensionAlias = {
|
|
24
|
+
'.js': ['.ts', '.js'],
|
|
25
|
+
'.mjs': ['.mts', '.mjs'],
|
|
26
|
+
};
|
|
21
27
|
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
|
|
22
28
|
const mainFields = ['module', 'main'];
|
|
23
29
|
function applyBaseConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
@@ -30,7 +36,7 @@ function applyBaseConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
|
30
36
|
options.transformers ??= [];
|
|
31
37
|
applyNxIndependentConfig(options, config);
|
|
32
38
|
// Some of the options only work during actual tasks, not when reading the webpack config during CreateNodes.
|
|
33
|
-
if (
|
|
39
|
+
if (global.NX_GRAPH_CREATION)
|
|
34
40
|
return;
|
|
35
41
|
applyNxDependentConfig(options, config, { useNormalizedEntry });
|
|
36
42
|
}
|
|
@@ -60,11 +66,7 @@ function applyNxIndependentConfig(options, config) {
|
|
|
60
66
|
config.cache =
|
|
61
67
|
options.target === 'node' && options.watch ? { type: 'memory' } : undefined;
|
|
62
68
|
config.devtool =
|
|
63
|
-
options.sourceMap === '
|
|
64
|
-
? 'hidden-source-map'
|
|
65
|
-
: options.sourceMap
|
|
66
|
-
? 'source-map'
|
|
67
|
-
: false;
|
|
69
|
+
options.sourceMap === true ? 'source-map' : options.sourceMap;
|
|
68
70
|
config.output = {
|
|
69
71
|
...config.output,
|
|
70
72
|
libraryTarget: config.output?.libraryTarget ??
|
|
@@ -100,6 +102,7 @@ function applyNxIndependentConfig(options, config) {
|
|
|
100
102
|
config.experiments = { ...config.experiments, cacheUnaffected: true };
|
|
101
103
|
config.ignoreWarnings = [
|
|
102
104
|
(x) => IGNORED_WEBPACK_WARNINGS.some((r) => typeof x === 'string' ? r.test(x) : r.test(x.message)),
|
|
105
|
+
...(config.ignoreWarnings ?? []),
|
|
103
106
|
];
|
|
104
107
|
config.optimization = {
|
|
105
108
|
...config.optimization,
|
|
@@ -179,8 +182,17 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
179
182
|
configurationName: options.configurationName,
|
|
180
183
|
root: options.root,
|
|
181
184
|
};
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
const isUsingTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
186
|
+
options.useTsconfigPaths ??= !isUsingTsSolution;
|
|
187
|
+
// If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
|
|
188
|
+
if (options.useTsconfigPaths) {
|
|
189
|
+
plugins.push(new nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin({ ...options, tsConfig }));
|
|
190
|
+
}
|
|
191
|
+
// New TS Solution already has a typecheck target but allow it to run during serve
|
|
192
|
+
if ((!options?.skipTypeChecking && !isUsingTsSolution) ||
|
|
193
|
+
(isUsingTsSolution &&
|
|
194
|
+
options?.skipTypeChecking === false &&
|
|
195
|
+
process.env['WEBPACK_SERVE'])) {
|
|
184
196
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
185
197
|
plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
186
198
|
typescript: {
|
|
@@ -267,7 +279,31 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
267
279
|
const externals = [];
|
|
268
280
|
if (options.target === 'node' && options.externalDependencies === 'all') {
|
|
269
281
|
const modulesDir = `${options.root}/node_modules`;
|
|
270
|
-
|
|
282
|
+
const graph = options.projectGraph;
|
|
283
|
+
const projectName = options.projectName;
|
|
284
|
+
const deps = graph?.dependencies?.[projectName] ?? [];
|
|
285
|
+
// Collect non-buildable TS project references so that they are bundled
|
|
286
|
+
// in the final output. This is needed for projects that are not buildable
|
|
287
|
+
// but are referenced by buildable projects. This is needed for the new TS
|
|
288
|
+
// solution setup.
|
|
289
|
+
const nonBuildableWorkspaceLibs = isUsingTsSolution
|
|
290
|
+
? deps
|
|
291
|
+
.filter((dep) => {
|
|
292
|
+
const node = graph.nodes?.[dep.target];
|
|
293
|
+
if (!node || node.type !== 'lib')
|
|
294
|
+
return false;
|
|
295
|
+
const hasBuildTarget = 'build' in (node.data?.targets ?? {});
|
|
296
|
+
if (hasBuildTarget) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
// If there is no build target we check the package exports to see if they reference
|
|
300
|
+
// source files
|
|
301
|
+
return !(0, utils_1.isBuildableLibrary)(node);
|
|
302
|
+
})
|
|
303
|
+
.map((dep) => graph.nodes?.[dep.target]?.data?.metadata?.js?.packageName)
|
|
304
|
+
.filter((name) => !!name)
|
|
305
|
+
: [];
|
|
306
|
+
externals.push(nodeExternals({ modulesDir, allowlist: nonBuildableWorkspaceLibs }));
|
|
271
307
|
}
|
|
272
308
|
else if (Array.isArray(options.externalDependencies)) {
|
|
273
309
|
externals.push(function (ctx, callback) {
|
|
@@ -282,6 +318,10 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
282
318
|
config.resolve = {
|
|
283
319
|
...config.resolve,
|
|
284
320
|
extensions: [...(config?.resolve?.extensions ?? []), ...extensions],
|
|
321
|
+
extensionAlias: {
|
|
322
|
+
...(config.resolve?.extensionAlias ?? {}),
|
|
323
|
+
...extensionAlias,
|
|
324
|
+
},
|
|
285
325
|
alias: {
|
|
286
326
|
...(config.resolve?.alias ?? {}),
|
|
287
327
|
...(options.fileReplacements?.reduce((aliases, replacement) => ({
|