@nx/webpack 16.8.0-beta.3 → 16.8.0-beta.5
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/package.json +5 -7
- package/src/executors/dev-server/dev-server.impl.js +36 -38
- package/src/executors/dev-server/lib/get-dev-server-config.js +1 -2
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +27 -41
- package/src/executors/webpack/lib/normalize-options.js +22 -7
- package/src/executors/webpack/lib/run-webpack.js +1 -2
- package/src/executors/webpack/webpack.impl.js +79 -85
- package/src/generators/configuration/configuration.js +34 -24
- package/src/generators/init/init.js +26 -29
- package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
- package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.js +12 -16
- package/src/migrations/update-15-6-3/webpack-config-setup.js +55 -59
- package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.js +10 -13
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/plugins/generate-package-json-plugin.js +3 -3
- package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +3 -1
- package/src/plugins/webpack-nx-build-coordination-plugin.js +55 -53
- package/src/utils/config.js +6 -9
- package/src/utils/create-copy-plugin.js +1 -2
- package/src/utils/web-babel-loader.js +1 -13
- package/src/utils/webpack/normalize-entry.js +2 -3
- package/src/utils/webpack/plugins/postcss-cli-resources.js +13 -16
- package/src/utils/webpack/plugins/scripts-webpack-plugin.js +1 -2
- package/src/utils/with-nx.js +69 -22
- package/src/utils/with-web.js +34 -13
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webpackInitSchematic = exports.webpackInitGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
7
6
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
function webpackInitGenerator(tree, schema) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
35
|
-
});
|
|
7
|
+
async function webpackInitGenerator(tree, schema) {
|
|
8
|
+
const tasks = [];
|
|
9
|
+
const devDependencies = {
|
|
10
|
+
'@nx/webpack': versions_1.nxVersion,
|
|
11
|
+
};
|
|
12
|
+
if (schema.compiler === 'swc') {
|
|
13
|
+
devDependencies['swc-loader'] = versions_1.swcLoaderVersion;
|
|
14
|
+
const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(tree);
|
|
15
|
+
tasks.push(addSwcTask);
|
|
16
|
+
}
|
|
17
|
+
if (schema.compiler === 'tsc') {
|
|
18
|
+
devDependencies['tslib'] = versions_1.tsLibVersion;
|
|
19
|
+
}
|
|
20
|
+
if (schema.uiFramework === 'react') {
|
|
21
|
+
devDependencies['@pmmmwh/react-refresh-webpack-plugin'] =
|
|
22
|
+
versions_1.reactRefreshWebpackPluginVersion;
|
|
23
|
+
devDependencies['@svgr/webpack'] = versions_1.svgrWebpackVersion;
|
|
24
|
+
devDependencies['react-refresh'] = versions_1.reactRefreshVersion;
|
|
25
|
+
devDependencies['url-loader'] = versions_1.urlLoaderVersion;
|
|
26
|
+
}
|
|
27
|
+
if (!schema.skipFormat) {
|
|
28
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
29
|
+
}
|
|
30
|
+
const baseInstalTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
|
|
31
|
+
tasks.push(baseInstalTask);
|
|
32
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
36
33
|
}
|
|
37
34
|
exports.webpackInitGenerator = webpackInitGenerator;
|
|
38
35
|
exports.default = webpackInitGenerator;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
|
|
6
|
-
function default_1(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
(0, add_babel_inputs_1.addBabelInputs)(tree);
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = default_1;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function default_1(tree) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(_f = (_e = p.targets) === null || _e === void 0 ? void 0 : _e[name]) === null || _f === void 0 ? true : delete _f.options.es2015Polyfills;
|
|
15
|
-
shouldUpdate = true;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
if (shouldUpdate) {
|
|
19
|
-
(0, devkit_1.updateProjectConfiguration)(tree, p.name, p);
|
|
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;
|
|
20
13
|
}
|
|
21
14
|
});
|
|
15
|
+
if (shouldUpdate) {
|
|
16
|
+
(0, devkit_1.updateProjectConfiguration)(tree, p.name, p);
|
|
17
|
+
}
|
|
22
18
|
});
|
|
23
19
|
}
|
|
24
20
|
exports.default = default_1;
|
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
5
|
const path_1 = require("path");
|
|
7
|
-
function default_1(tree) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(0,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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');
|
|
25
37
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// then skip it unless it specifically configures a webpackConfig file
|
|
29
|
-
if (configurationName && !(options === null || options === void 0 ? void 0 : options.webpackConfig)) {
|
|
30
|
-
return;
|
|
38
|
+
if (options.webpackConfig.endsWith('.ts')) {
|
|
39
|
+
oldName = options.webpackConfig.replace('.ts', '.old.ts');
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// executor options
|
|
36
|
-
if (options === null || options === void 0 ? void 0 : options.webpackConfig) {
|
|
37
|
-
let oldName = options.webpackConfig;
|
|
38
|
-
if (options.webpackConfig.endsWith('.js')) {
|
|
39
|
-
oldName = options.webpackConfig.replace('.js', '.old.js');
|
|
40
|
-
}
|
|
41
|
-
if (options.webpackConfig.endsWith('.ts')) {
|
|
42
|
-
oldName = options.webpackConfig.replace('.ts', '.old.ts');
|
|
43
|
-
}
|
|
44
|
-
renameFile(tree, options.webpackConfig, oldName);
|
|
45
|
-
const justTheFileName = (0, path_1.basename)(oldName);
|
|
46
|
-
tree.write(options.webpackConfig, `
|
|
41
|
+
renameFile(tree, options.webpackConfig, oldName);
|
|
42
|
+
const justTheFileName = (0, path_1.basename)(oldName);
|
|
43
|
+
tree.write(options.webpackConfig, `
|
|
47
44
|
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
48
45
|
|
|
49
46
|
// Nx plugins for webpack.
|
|
@@ -51,30 +48,30 @@ function default_1(tree) {
|
|
|
51
48
|
// Note: This was added by an Nx migration.
|
|
52
49
|
// You should consider inlining the logic into this file.
|
|
53
50
|
// For more information on webpack config and Nx see:
|
|
54
|
-
// https://nx.dev/
|
|
51
|
+
// https://nx.dev/recipes/webpack/webpack-config-setup
|
|
55
52
|
return require('./${justTheFileName}')(config, context);
|
|
56
53
|
});
|
|
57
54
|
`);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
options.isolatedConfig = true;
|
|
56
|
+
projectConfiguration.targets[targetName][configurationName ?? 'options'] = options;
|
|
57
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
58
|
+
devkit_1.logger.info(`
|
|
62
59
|
${options.webpackConfig} has been renamed to ${oldName} and a new ${options.webpackConfig}
|
|
63
60
|
has been created for your project ${projectName}.
|
|
64
61
|
You should consider inlining the logic from ${oldName} into ${options.webpackConfig}.
|
|
65
62
|
You can read our guide on how to do this here:
|
|
66
63
|
|
|
67
|
-
https://nx.dev/
|
|
64
|
+
https://nx.dev/recipes/webpack/webpack-config-setup
|
|
68
65
|
`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
69
|
+
if (!options) {
|
|
70
|
+
options = {};
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
options = {};
|
|
74
|
-
}
|
|
75
|
-
options.webpackConfig = `${projectConfiguration.root}/webpack.config.js`;
|
|
76
|
-
options.isolatedConfig = true;
|
|
77
|
-
tree.write(options.webpackConfig, `
|
|
72
|
+
options.webpackConfig = `${projectConfiguration.root}/webpack.config.js`;
|
|
73
|
+
options.isolatedConfig = true;
|
|
74
|
+
tree.write(options.webpackConfig, `
|
|
78
75
|
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
79
76
|
|
|
80
77
|
// Nx plugins for webpack.
|
|
@@ -82,16 +79,15 @@ function default_1(tree) {
|
|
|
82
79
|
// Update the webpack config as needed here.
|
|
83
80
|
// e.g. config.plugins.push(new MyPlugin())
|
|
84
81
|
// For more information on webpack config and Nx see:
|
|
85
|
-
// https://nx.dev/
|
|
82
|
+
// https://nx.dev/recipes/webpack/webpack-config-setup
|
|
86
83
|
return config;
|
|
87
84
|
});
|
|
88
85
|
`);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
86
|
+
projectConfiguration.targets[targetName].options = options;
|
|
87
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
88
|
+
}
|
|
94
89
|
});
|
|
90
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
95
91
|
}
|
|
96
92
|
exports.default = default_1;
|
|
97
93
|
function renameFile(tree, from, to) {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function default_1(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
16
|
-
});
|
|
17
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
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);
|
|
18
14
|
});
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
16
|
}
|
|
20
17
|
exports.default = default_1;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/webpack', '@nx/webpack');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -18,7 +18,6 @@ class GeneratePackageJsonPlugin {
|
|
|
18
18
|
name: pluginName,
|
|
19
19
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
20
20
|
}, () => {
|
|
21
|
-
var _a;
|
|
22
21
|
const helperDependencies = (0, js_2.getHelperDependenciesFromProjectGraph)(this.context.root, this.context.projectName, this.projectGraph);
|
|
23
22
|
const importHelpers = !!(0, js_2.readTsConfig)(this.options.tsConfig).options
|
|
24
23
|
.importHelpers;
|
|
@@ -37,9 +36,10 @@ class GeneratePackageJsonPlugin {
|
|
|
37
36
|
isProduction: true,
|
|
38
37
|
helperDependencies: helperDependencies.map((dep) => dep.target),
|
|
39
38
|
});
|
|
40
|
-
packageJson.main =
|
|
39
|
+
packageJson.main = packageJson.main ?? this.options.outputFileName;
|
|
41
40
|
compilation.emitAsset('package.json', new webpack_1.sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
|
|
42
|
-
|
|
41
|
+
const packageManager = (0, devkit_1.detectPackageManager)(this.context.root);
|
|
42
|
+
compilation.emitAsset((0, js_2.getLockFileName)(packageManager), new webpack_1.sources.RawSource((0, js_1.createLockFile)(packageJson, this.projectGraph, packageManager)));
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -2,8 +2,10 @@ import type { Compiler } from 'webpack';
|
|
|
2
2
|
export declare class WebpackNxBuildCoordinationPlugin {
|
|
3
3
|
private readonly buildCmd;
|
|
4
4
|
private currentlyRunning;
|
|
5
|
+
private buildCmdProcess;
|
|
5
6
|
constructor(buildCmd: string, skipInitialBuild?: boolean);
|
|
6
7
|
apply(compiler: Compiler): void;
|
|
7
|
-
startWatchingBuildableLibs(): void
|
|
8
|
+
startWatchingBuildableLibs(): Promise<void>;
|
|
8
9
|
buildChangedProjects(): Promise<void>;
|
|
10
|
+
private createFileWatcher;
|
|
9
11
|
}
|
|
@@ -1,50 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebpackNxBuildCoordinationPlugin = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const chokidar_1 = require("chokidar");
|
|
6
4
|
const child_process_1 = require("child_process");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const fs_1 = require("fs");
|
|
5
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
6
|
+
const watch_1 = require("nx/src/command-line/watch");
|
|
7
|
+
const output_1 = require("nx/src/utils/output");
|
|
11
8
|
class WebpackNxBuildCoordinationPlugin {
|
|
12
9
|
constructor(buildCmd, skipInitialBuild) {
|
|
13
10
|
this.buildCmd = buildCmd;
|
|
14
11
|
this.currentlyRunning = 'none';
|
|
12
|
+
this.buildCmdProcess = null;
|
|
15
13
|
if (!skipInitialBuild) {
|
|
16
14
|
this.buildChangedProjects();
|
|
17
15
|
}
|
|
18
16
|
this.startWatchingBuildableLibs();
|
|
19
17
|
}
|
|
20
18
|
apply(compiler) {
|
|
21
|
-
compiler.hooks.beforeCompile.tapPromise('IncrementalDevServerPlugin', () =>
|
|
19
|
+
compiler.hooks.beforeCompile.tapPromise('IncrementalDevServerPlugin', async () => {
|
|
22
20
|
while (this.currentlyRunning === 'nx-build') {
|
|
23
|
-
|
|
21
|
+
await sleep(50);
|
|
24
22
|
}
|
|
25
23
|
this.currentlyRunning = 'webpack-build';
|
|
26
|
-
})
|
|
27
|
-
compiler.hooks.done.tapPromise('IncrementalDevServerPlugin', () =>
|
|
24
|
+
});
|
|
25
|
+
compiler.hooks.done.tapPromise('IncrementalDevServerPlugin', async () => {
|
|
28
26
|
this.currentlyRunning = 'none';
|
|
29
|
-
})
|
|
27
|
+
});
|
|
30
28
|
}
|
|
31
|
-
startWatchingBuildableLibs() {
|
|
32
|
-
createFileWatcher(
|
|
33
|
-
|
|
29
|
+
async startWatchingBuildableLibs() {
|
|
30
|
+
const unregisterFileWatcher = await this.createFileWatcher();
|
|
31
|
+
process.on('exit', () => {
|
|
32
|
+
unregisterFileWatcher();
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
|
-
buildChangedProjects() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
async buildChangedProjects() {
|
|
36
|
+
while (this.currentlyRunning === 'webpack-build') {
|
|
37
|
+
await sleep(50);
|
|
38
|
+
}
|
|
39
|
+
this.currentlyRunning = 'nx-build';
|
|
40
|
+
try {
|
|
41
|
+
return await new Promise((res) => {
|
|
42
|
+
this.buildCmdProcess = (0, child_process_1.exec)(this.buildCmd);
|
|
43
|
+
this.buildCmdProcess.stdout.pipe(process.stdout);
|
|
44
|
+
this.buildCmdProcess.stderr.pipe(process.stderr);
|
|
45
|
+
this.buildCmdProcess.on('exit', () => {
|
|
46
|
+
res();
|
|
47
|
+
});
|
|
48
|
+
this.buildCmdProcess.on('error', () => {
|
|
49
|
+
res();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
this.currentlyRunning = 'none';
|
|
55
|
+
this.buildCmdProcess = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
createFileWatcher() {
|
|
59
|
+
const runner = new watch_1.BatchFunctionRunner(() => this.buildChangedProjects());
|
|
60
|
+
return client_1.daemonClient.registerFileWatcher({
|
|
61
|
+
watchProjects: 'all',
|
|
62
|
+
}, (err, { changedProjects, changedFiles }) => {
|
|
63
|
+
if (err === 'closed') {
|
|
64
|
+
output_1.output.error({
|
|
65
|
+
title: 'Watch connection closed',
|
|
66
|
+
bodyLines: [
|
|
67
|
+
'The daemon has closed the connection to this watch process.',
|
|
68
|
+
'Please restart your watch command.',
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
process.exit(1);
|
|
40
72
|
}
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// eslint-disable-next-line no-empty
|
|
73
|
+
if (this.buildCmdProcess) {
|
|
74
|
+
this.buildCmdProcess.kill(2);
|
|
75
|
+
this.buildCmdProcess = null;
|
|
45
76
|
}
|
|
46
|
-
|
|
47
|
-
|
|
77
|
+
// Queue a build
|
|
78
|
+
runner.enqueue(changedProjects, changedFiles);
|
|
48
79
|
});
|
|
49
80
|
}
|
|
50
81
|
}
|
|
@@ -52,32 +83,3 @@ exports.WebpackNxBuildCoordinationPlugin = WebpackNxBuildCoordinationPlugin;
|
|
|
52
83
|
function sleep(time) {
|
|
53
84
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
54
85
|
}
|
|
55
|
-
function getIgnoredGlobs(root) {
|
|
56
|
-
const ig = (0, ignore_1.default)();
|
|
57
|
-
try {
|
|
58
|
-
ig.add((0, fs_1.readFileSync)(`${root}/.gitignore`, 'utf-8'));
|
|
59
|
-
}
|
|
60
|
-
catch (_a) { }
|
|
61
|
-
try {
|
|
62
|
-
ig.add((0, fs_1.readFileSync)(`${root}/.nxignore`, 'utf-8'));
|
|
63
|
-
}
|
|
64
|
-
catch (_b) { }
|
|
65
|
-
return ig;
|
|
66
|
-
}
|
|
67
|
-
function createFileWatcher(root, changeHandler) {
|
|
68
|
-
const ignoredGlobs = getIgnoredGlobs(root);
|
|
69
|
-
const layout = (0, devkit_1.workspaceLayout)();
|
|
70
|
-
const watcher = (0, chokidar_1.watch)([
|
|
71
|
-
(0, devkit_2.joinPathFragments)(layout.appsDir, '**'),
|
|
72
|
-
(0, devkit_2.joinPathFragments)(layout.libsDir, '**'),
|
|
73
|
-
], {
|
|
74
|
-
cwd: root,
|
|
75
|
-
ignoreInitial: true,
|
|
76
|
-
});
|
|
77
|
-
watcher.on('all', (_event, path) => {
|
|
78
|
-
if (ignoredGlobs.ignores(path))
|
|
79
|
-
return;
|
|
80
|
-
changeHandler();
|
|
81
|
-
});
|
|
82
|
-
return { close: () => watcher.close() };
|
|
83
|
-
}
|
package/src/utils/config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.composePluginsSync = exports.composePlugins = exports.getBaseWebpackPartial = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const with_nx_1 = require("./with-nx");
|
|
6
5
|
const with_web_1 = require("./with-web");
|
|
7
6
|
/** @deprecated use withNx and withWeb plugins directly */
|
|
@@ -12,14 +11,12 @@ function getBaseWebpackPartial(options, context) {
|
|
|
12
11
|
}
|
|
13
12
|
exports.getBaseWebpackPartial = getBaseWebpackPartial;
|
|
14
13
|
function composePlugins(...plugins) {
|
|
15
|
-
return function combined(config, ctx) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return config;
|
|
22
|
-
});
|
|
14
|
+
return async function combined(config, ctx) {
|
|
15
|
+
for (const plugin of plugins) {
|
|
16
|
+
const fn = await plugin;
|
|
17
|
+
config = await fn(config, ctx);
|
|
18
|
+
}
|
|
19
|
+
return config;
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
22
|
exports.composePlugins = composePlugins;
|
|
@@ -5,7 +5,6 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
|
5
5
|
function createCopyPlugin(assets) {
|
|
6
6
|
return new CopyWebpackPlugin({
|
|
7
7
|
patterns: assets.map((asset) => {
|
|
8
|
-
var _a;
|
|
9
8
|
return {
|
|
10
9
|
context: asset.input,
|
|
11
10
|
// Now we remove starting slash to make Webpack place it from the output root.
|
|
@@ -16,7 +15,7 @@ function createCopyPlugin(assets) {
|
|
|
16
15
|
'.gitkeep',
|
|
17
16
|
'**/.DS_Store',
|
|
18
17
|
'**/Thumbs.db',
|
|
19
|
-
...(
|
|
18
|
+
...(asset.ignore ?? []),
|
|
20
19
|
],
|
|
21
20
|
dot: true,
|
|
22
21
|
},
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
module.exports = require('babel-loader').custom(() => {
|
|
13
2
|
return {
|
|
14
|
-
customOptions(
|
|
15
|
-
var { isTest, isModern, emitDecoratorMetadata } = _a, loader = __rest(_a, ["isTest", "isModern", "emitDecoratorMetadata"]);
|
|
3
|
+
customOptions({ isTest, isModern, emitDecoratorMetadata, ...loader }) {
|
|
16
4
|
return {
|
|
17
5
|
custom: { isTest, isModern, emitDecoratorMetadata },
|
|
18
6
|
loader,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeExtraEntryPoints = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
|
|
6
5
|
return extraEntryPoints.map((entry) => {
|
|
7
6
|
let normalizedEntry;
|
|
@@ -13,7 +12,7 @@ function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
|
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
else {
|
|
16
|
-
const { inject = true
|
|
15
|
+
const { inject = true, ...newEntry } = entry;
|
|
17
16
|
let bundleName;
|
|
18
17
|
if (entry.bundleName) {
|
|
19
18
|
bundleName = entry.bundleName;
|
|
@@ -21,7 +20,7 @@ function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
|
|
|
21
20
|
else {
|
|
22
21
|
bundleName = defaultBundleName;
|
|
23
22
|
}
|
|
24
|
-
normalizedEntry =
|
|
23
|
+
normalizedEntry = { ...newEntry, bundleName };
|
|
25
24
|
}
|
|
26
25
|
return normalizedEntry;
|
|
27
26
|
});
|