@nx/webpack 19.0.0-beta.1 → 19.0.0-beta.11
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/app-plugin.d.ts +2 -0
- package/app-plugin.js +5 -0
- package/index.d.ts +6 -2
- package/index.js +8 -5
- package/migrations.json +0 -24
- package/package.json +4 -4
- package/src/executors/webpack/schema.d.ts +1 -1
- package/src/generators/configuration/configuration.js +4 -4
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +2 -2
- package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +2 -2
- package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +2 -2
- package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +2 -2
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +2 -2
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +12 -3
- package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +4 -4
- package/src/plugins/nx-webpack-plugin/{nx-webpack-plugin-options.d.ts → nx-app-webpack-plugin-options.d.ts} +2 -2
- package/src/plugins/nx-webpack-plugin/{nx-webpack-plugin.d.ts → nx-app-webpack-plugin.d.ts} +3 -3
- package/src/plugins/nx-webpack-plugin/{nx-webpack-plugin.js → nx-app-webpack-plugin.js} +3 -3
- package/src/utils/get-client-environment.js +3 -6
- package/src/utils/module-federation/secondary-entry-points.js +2 -7
- package/src/utils/webpack/interpolate-env-variables-to-index.js +2 -5
- package/src/utils/webpack/resolve-user-defined-webpack-config.js +2 -3
- package/src/utils/with-nx.d.ts +2 -2
- package/tsconfig-paths-plugin.d.ts +1 -0
- package/tsconfig-paths-plugin.js +5 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/add-babel-inputs.js +0 -9
- package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.d.ts +0 -2
- package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.js +0 -20
- package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +0 -2
- package/src/migrations/update-15-6-3/webpack-config-setup.js +0 -100
- package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.d.ts +0 -2
- package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.js +0 -17
- /package/src/plugins/nx-webpack-plugin/{nx-webpack-plugin-options.js → nx-app-webpack-plugin-options.js} +0 -0
package/app-plugin.d.ts
ADDED
package/app-plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxAppWebpackPlugin = void 0;
|
|
4
|
+
var nx_app_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-app-webpack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "NxAppWebpackPlugin", { enumerable: true, get: function () { return nx_app_webpack_plugin_1.NxAppWebpackPlugin; } });
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { configurationGenerator } from './src/generators/configuration/configuration';
|
|
2
|
+
import { NxAppWebpackPlugin } from './src/plugins/nx-webpack-plugin/nx-app-webpack-plugin';
|
|
3
|
+
import { NxTsconfigPathsWebpackPlugin as _NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
|
|
2
4
|
export { configurationGenerator };
|
|
3
5
|
/** @deprecated Use `configurationGenerator` instead. */
|
|
4
6
|
export declare const webpackProjectGenerator: typeof configurationGenerator;
|
|
7
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
8
|
+
export declare const NxWebpackPlugin: typeof NxAppWebpackPlugin;
|
|
9
|
+
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
10
|
+
export declare const NxTsconfigPathsWebpackPlugin: typeof _NxTsconfigPathsWebpackPlugin;
|
|
5
11
|
export * from './src/utils/create-copy-plugin';
|
|
6
12
|
export * from './src/utils/config';
|
|
7
13
|
export { webpackInitGenerator } from './src/generators/init/init';
|
|
@@ -14,5 +20,3 @@ export * from './src/utils/get-css-module-local-ident';
|
|
|
14
20
|
export * from './src/utils/with-nx';
|
|
15
21
|
export * from './src/utils/with-web';
|
|
16
22
|
export * from './src/utils/module-federation/public-api';
|
|
17
|
-
export { NxWebpackPlugin } from './src/plugins/nx-webpack-plugin/nx-webpack-plugin';
|
|
18
|
-
export { NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
|
package/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.webpackInitGenerator = exports.NxTsconfigPathsWebpackPlugin = exports.NxWebpackPlugin = 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; } });
|
|
7
|
+
const nx_app_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-app-webpack-plugin");
|
|
8
|
+
const nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
|
|
7
9
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
8
10
|
/** @deprecated Use `configurationGenerator` instead. */
|
|
9
11
|
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
12
|
+
// TODO(v20): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
|
13
|
+
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
14
|
+
exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
|
|
15
|
+
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
|
16
|
+
exports.NxTsconfigPathsWebpackPlugin = nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin;
|
|
10
17
|
tslib_1.__exportStar(require("./src/utils/create-copy-plugin"), exports);
|
|
11
18
|
tslib_1.__exportStar(require("./src/utils/config"), exports);
|
|
12
19
|
var init_1 = require("./src/generators/init/init");
|
|
@@ -18,7 +25,3 @@ tslib_1.__exportStar(require("./src/utils/get-css-module-local-ident"), exports)
|
|
|
18
25
|
tslib_1.__exportStar(require("./src/utils/with-nx"), exports);
|
|
19
26
|
tslib_1.__exportStar(require("./src/utils/with-web"), exports);
|
|
20
27
|
tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
|
|
21
|
-
var nx_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-webpack-plugin");
|
|
22
|
-
Object.defineProperty(exports, "NxWebpackPlugin", { enumerable: true, get: function () { return nx_webpack_plugin_1.NxWebpackPlugin; } });
|
|
23
|
-
var nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
|
|
24
|
-
Object.defineProperty(exports, "NxTsconfigPathsWebpackPlugin", { enumerable: true, get: function () { return nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin; } });
|
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.
|
|
3
|
+
"version": "19.0.0-beta.11",
|
|
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.
|
|
67
|
-
"@nx/js": "19.0.0-beta.
|
|
68
|
-
"@nrwl/webpack": "19.0.0-beta.
|
|
66
|
+
"@nx/devkit": "19.0.0-beta.11",
|
|
67
|
+
"@nx/js": "19.0.0-beta.11",
|
|
68
|
+
"@nrwl/webpack": "19.0.0-beta.11"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"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(v20): 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;
|
|
@@ -63,7 +63,7 @@ function createWebpackConfig(tree, options) {
|
|
|
63
63
|
if (options.target === 'web') {
|
|
64
64
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
65
65
|
? `
|
|
66
|
-
const {
|
|
66
|
+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
67
67
|
const { join } = require('path');
|
|
68
68
|
|
|
69
69
|
module.exports = {
|
|
@@ -71,7 +71,7 @@ module.exports = {
|
|
|
71
71
|
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
72
72
|
},
|
|
73
73
|
plugins: [
|
|
74
|
-
new
|
|
74
|
+
new NxAppWebpackPlugin({
|
|
75
75
|
target: '${buildOptions.target}',
|
|
76
76
|
tsConfig: '${buildOptions.tsConfig}',
|
|
77
77
|
compiler: '${buildOptions.compiler}',
|
|
@@ -95,7 +95,7 @@ module.exports = composePlugins(withNx(), withWeb(), (config) => {
|
|
|
95
95
|
else {
|
|
96
96
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), (0, has_plugin_1.hasPlugin)(tree)
|
|
97
97
|
? `
|
|
98
|
-
const {
|
|
98
|
+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
99
99
|
const { join } = require('path');
|
|
100
100
|
|
|
101
101
|
module.exports = {
|
|
@@ -103,7 +103,7 @@ module.exports = {
|
|
|
103
103
|
path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
|
|
104
104
|
},
|
|
105
105
|
plugins: [
|
|
106
|
-
new
|
|
106
|
+
new NxAppWebpackPlugin({
|
|
107
107
|
target: '${buildOptions.target}',
|
|
108
108
|
tsConfig: '${buildOptions.tsConfig}',
|
|
109
109
|
compiler: '${buildOptions.compiler}',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Configuration, WebpackOptionsNormalized } from 'webpack';
|
|
2
|
-
import {
|
|
3
|
-
export declare function applyBaseConfig(options:
|
|
2
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
3
|
+
export declare function applyBaseConfig(options: NormalizedNxAppWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
|
|
4
4
|
useNormalizedEntry?: boolean;
|
|
5
5
|
}): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Configuration, WebpackOptionsNormalized } from 'webpack';
|
|
2
|
-
import {
|
|
3
|
-
export declare function applyWebConfig(options:
|
|
2
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
3
|
+
export declare function applyWebConfig(options: NormalizedNxAppWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
|
|
4
4
|
useNormalizedEntry?: boolean;
|
|
5
5
|
}): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createLoaderFromCompiler(options:
|
|
1
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
2
|
+
export declare function createLoaderFromCompiler(options: NormalizedNxAppWebpackPluginOptions): {
|
|
3
3
|
test: RegExp;
|
|
4
4
|
loader: string;
|
|
5
5
|
exclude: RegExp;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { WebpackPluginInstance } from 'webpack';
|
|
2
|
-
import {
|
|
3
|
-
export declare function instantiateScriptPlugins(options:
|
|
2
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
3
|
+
export declare function instantiateScriptPlugins(options: NormalizedNxAppWebpackPluginOptions): WebpackPluginInstance[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetGlobPattern, FileReplacement,
|
|
2
|
-
export declare function normalizeOptions(options:
|
|
1
|
+
import { AssetGlobPattern, FileReplacement, NormalizedNxAppWebpackPluginOptions, NxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
2
|
+
export declare function normalizeOptions(options: NxAppWebpackPluginOptions): NormalizedNxAppWebpackPluginOptions;
|
|
3
3
|
export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string, resolveRelativePathsToProjectRoot?: boolean): AssetGlobPattern[];
|
|
4
4
|
export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
|
|
@@ -7,11 +7,20 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
function normalizeOptions(options) {
|
|
8
8
|
const combinedPluginAndMaybeExecutorOptions = {};
|
|
9
9
|
const isProd = process.env.NODE_ENV === 'production';
|
|
10
|
-
const projectName = process.env.NX_TASK_TARGET_PROJECT;
|
|
11
|
-
const targetName = process.env.NX_TASK_TARGET_TARGET;
|
|
12
|
-
const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
|
|
13
10
|
// Since this is invoked by the executor, the graph has already been created and cached.
|
|
14
11
|
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
12
|
+
const taskDetailsFromBuildTarget = process.env.NX_BUILD_TARGET
|
|
13
|
+
? (0, devkit_1.parseTargetString)(process.env.NX_BUILD_TARGET, projectGraph)
|
|
14
|
+
: undefined;
|
|
15
|
+
const projectName = taskDetailsFromBuildTarget
|
|
16
|
+
? taskDetailsFromBuildTarget.project
|
|
17
|
+
: process.env.NX_TASK_TARGET_PROJECT;
|
|
18
|
+
const targetName = taskDetailsFromBuildTarget
|
|
19
|
+
? taskDetailsFromBuildTarget.target
|
|
20
|
+
: process.env.NX_TASK_TARGET_TARGET;
|
|
21
|
+
const configurationName = taskDetailsFromBuildTarget
|
|
22
|
+
? taskDetailsFromBuildTarget.configuration
|
|
23
|
+
: process.env.NX_TASK_TARGET_CONFIGURATION;
|
|
15
24
|
const projectNode = projectGraph.nodes[projectName];
|
|
16
25
|
const targetConfig = projectNode.data.targets[targetName];
|
|
17
26
|
normalizeRelativePaths(projectNode.data.root, options);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getCSSModuleLocalIdent } from '../../../utils/get-css-module-local-ident';
|
|
2
|
-
import {
|
|
2
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
|
|
3
3
|
interface PostcssOptions {
|
|
4
4
|
(loader: any): any;
|
|
5
5
|
config?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function getCommonLoadersForCssModules(options:
|
|
7
|
+
export declare function getCommonLoadersForCssModules(options: NormalizedNxAppWebpackPluginOptions, includePaths: string[]): ({
|
|
8
8
|
loader: any;
|
|
9
9
|
options?: undefined;
|
|
10
10
|
} | {
|
|
@@ -27,7 +27,7 @@ export declare function getCommonLoadersForCssModules(options: NormalizedNxWebpa
|
|
|
27
27
|
importLoaders?: undefined;
|
|
28
28
|
};
|
|
29
29
|
})[];
|
|
30
|
-
export declare function getCommonLoadersForGlobalCss(options:
|
|
30
|
+
export declare function getCommonLoadersForGlobalCss(options: NormalizedNxAppWebpackPluginOptions, includePaths: string[]): ({
|
|
31
31
|
loader: any;
|
|
32
32
|
options?: undefined;
|
|
33
33
|
} | {
|
|
@@ -45,7 +45,7 @@ export declare function getCommonLoadersForGlobalCss(options: NormalizedNxWebpac
|
|
|
45
45
|
url?: undefined;
|
|
46
46
|
};
|
|
47
47
|
})[];
|
|
48
|
-
export declare function getCommonLoadersForGlobalStyle(options:
|
|
48
|
+
export declare function getCommonLoadersForGlobalStyle(options: NormalizedNxAppWebpackPluginOptions, includePaths: string[]): ({
|
|
49
49
|
loader: any;
|
|
50
50
|
options: {
|
|
51
51
|
esModule: boolean;
|
|
@@ -29,7 +29,7 @@ export interface OptimizationOptions {
|
|
|
29
29
|
scripts: boolean;
|
|
30
30
|
styles: boolean;
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface NxAppWebpackPluginOptions {
|
|
33
33
|
/**
|
|
34
34
|
* The tsconfig file for the project. e.g. `tsconfig.json`
|
|
35
35
|
*/
|
|
@@ -203,7 +203,7 @@ export interface NxWebpackPluginOptions {
|
|
|
203
203
|
*/
|
|
204
204
|
watch?: boolean;
|
|
205
205
|
}
|
|
206
|
-
export interface
|
|
206
|
+
export interface NormalizedNxAppWebpackPluginOptions extends NxAppWebpackPluginOptions {
|
|
207
207
|
projectName: string;
|
|
208
208
|
root: string;
|
|
209
209
|
projectRoot: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Compiler } from 'webpack';
|
|
2
|
-
import {
|
|
2
|
+
import { NxAppWebpackPluginOptions } from './nx-app-webpack-plugin-options';
|
|
3
3
|
/**
|
|
4
4
|
* This plugin provides features to build Node and Web applications.
|
|
5
5
|
* - TS support (including tsconfig paths)
|
|
@@ -10,8 +10,8 @@ import { NxWebpackPluginOptions } from './nx-webpack-plugin-options';
|
|
|
10
10
|
*
|
|
11
11
|
* Web-only features, such as stylesheets and images, are only supported when `target` is 'web' or 'webworker'.
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class NxAppWebpackPlugin {
|
|
14
14
|
private readonly options;
|
|
15
|
-
constructor(options?:
|
|
15
|
+
constructor(options?: NxAppWebpackPluginOptions);
|
|
16
16
|
apply(compiler: Compiler): void;
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NxAppWebpackPlugin = void 0;
|
|
4
4
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
5
5
|
const fs_1 = require("../../utils/fs");
|
|
6
6
|
const apply_base_config_1 = require("./lib/apply-base-config");
|
|
@@ -15,7 +15,7 @@ const apply_web_config_1 = require("./lib/apply-web-config");
|
|
|
15
15
|
*
|
|
16
16
|
* Web-only features, such as stylesheets and images, are only supported when `target` is 'web' or 'webworker'.
|
|
17
17
|
*/
|
|
18
|
-
class
|
|
18
|
+
class NxAppWebpackPlugin {
|
|
19
19
|
constructor(options = {}) {
|
|
20
20
|
// If we're building inferred targets, skip normalizing build options.
|
|
21
21
|
if (!global.NX_GRAPH_CREATION) {
|
|
@@ -45,4 +45,4 @@ class NxWebpackPlugin {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
exports.
|
|
48
|
+
exports.NxAppWebpackPlugin = NxAppWebpackPlugin;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getClientEnvironment = void 0;
|
|
4
|
-
// Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
|
|
5
|
-
// TODO(v19): Only env vars prefixed with NX_PUBLIC should be bundled. This is a breaking change so we won't do it in v18.
|
|
6
|
-
const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
|
|
7
4
|
function getClientEnvironment(mode) {
|
|
8
|
-
// Grab NODE_ENV and
|
|
5
|
+
// Grab NODE_ENV and NX_PUBLIC_* environment variables and prepare them to be
|
|
9
6
|
// injected into the application via DefinePlugin in webpack configuration.
|
|
10
|
-
const
|
|
7
|
+
const nxPublicKeyRegex = /^NX_PUBLIC_/i;
|
|
11
8
|
const raw = Object.keys(process.env)
|
|
12
|
-
.filter((key) =>
|
|
9
|
+
.filter((key) => nxPublicKeyRegex.test(key))
|
|
13
10
|
.reduce((env, key) => {
|
|
14
11
|
env[key] = process.env[key];
|
|
15
12
|
return env;
|
|
@@ -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
|
|
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 {
|
|
@@ -6,12 +6,9 @@ function interpolateEnvironmentVariablesToIndex(contents, deployUrl) {
|
|
|
6
6
|
return interpolateEnvironmentVariables(contents, environmentVariables);
|
|
7
7
|
}
|
|
8
8
|
exports.interpolateEnvironmentVariablesToIndex = interpolateEnvironmentVariablesToIndex;
|
|
9
|
-
const NX_PREFIX = /^
|
|
10
|
-
// Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
|
|
11
|
-
// TODO(v19): Only env vars prefixed with NX_PUBLIC should be bundled. This is a breaking change so we won't do it in v18.
|
|
12
|
-
const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
|
|
9
|
+
const NX_PREFIX = /^NX_PUBLIC_/i;
|
|
13
10
|
function isNxEnvironmentKey(x) {
|
|
14
|
-
return
|
|
11
|
+
return NX_PREFIX.test(x);
|
|
15
12
|
}
|
|
16
13
|
function getClientEnvironment(deployUrl) {
|
|
17
14
|
return Object.keys(process.env)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveUserDefinedWebpackConfig = void 0;
|
|
4
4
|
const internal_1 = require("@nx/js/src/internal");
|
|
5
|
+
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
5
6
|
function resolveUserDefinedWebpackConfig(path, tsConfig,
|
|
6
7
|
/** Skip require cache and return latest content */
|
|
7
8
|
reload = false) {
|
|
@@ -9,9 +10,7 @@ reload = false) {
|
|
|
9
10
|
// Clear cache if the path is in the cache
|
|
10
11
|
if (require.cache[path]) {
|
|
11
12
|
// Clear all entries because config may import other modules
|
|
12
|
-
|
|
13
|
-
delete require.cache[k];
|
|
14
|
-
}
|
|
13
|
+
(0, config_utils_1.clearRequireCache)();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
// Don't transpile non-TS files. This prevents workspaces libs from being registered via tsconfig-paths.
|
package/src/utils/with-nx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NxComposableWebpackPlugin } from './config';
|
|
2
|
-
import {
|
|
3
|
-
export type WithNxOptions = Partial<
|
|
2
|
+
import { NxAppWebpackPluginOptions } from '../plugins/nx-webpack-plugin/nx-app-webpack-plugin-options';
|
|
3
|
+
export type WithNxOptions = Partial<NxAppWebpackPluginOptions>;
|
|
4
4
|
/**
|
|
5
5
|
* @param {WithNxOptions} pluginOptions
|
|
6
6
|
* @returns {NxWebpackPlugin}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxTsconfigPathsWebpackPlugin = void 0;
|
|
4
|
+
var nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "NxTsconfigPathsWebpackPlugin", { enumerable: true, get: function () { return nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin; } });
|
|
@@ -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,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,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,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;
|
|
File without changes
|