@nx/webpack 16.8.0-beta.4 → 16.8.0-beta.6
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 -5
- 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 +52 -56
- 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 +1 -2
- package/src/plugins/webpack-nx-build-coordination-plugin.js +30 -35
- 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.
|
|
@@ -55,10 +52,10 @@ function default_1(tree) {
|
|
|
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}.
|
|
@@ -66,15 +63,15 @@ function default_1(tree) {
|
|
|
66
63
|
|
|
67
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.
|
|
@@ -86,12 +83,11 @@ function default_1(tree) {
|
|
|
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,7 +36,7 @@ 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);
|
|
43
42
|
compilation.emitAsset((0, js_2.getLockFileName)(packageManager), new webpack_1.sources.RawSource((0, js_1.createLockFile)(packageJson, this.projectGraph, packageManager)));
|
|
@@ -1,7 +1,6 @@
|
|
|
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
4
|
const child_process_1 = require("child_process");
|
|
6
5
|
const client_1 = require("nx/src/daemon/client/client");
|
|
7
6
|
const watch_1 = require("nx/src/command-line/watch");
|
|
@@ -17,48 +16,44 @@ class WebpackNxBuildCoordinationPlugin {
|
|
|
17
16
|
this.startWatchingBuildableLibs();
|
|
18
17
|
}
|
|
19
18
|
apply(compiler) {
|
|
20
|
-
compiler.hooks.beforeCompile.tapPromise('IncrementalDevServerPlugin', () =>
|
|
19
|
+
compiler.hooks.beforeCompile.tapPromise('IncrementalDevServerPlugin', async () => {
|
|
21
20
|
while (this.currentlyRunning === 'nx-build') {
|
|
22
|
-
|
|
21
|
+
await sleep(50);
|
|
23
22
|
}
|
|
24
23
|
this.currentlyRunning = 'webpack-build';
|
|
25
|
-
})
|
|
26
|
-
compiler.hooks.done.tapPromise('IncrementalDevServerPlugin', () =>
|
|
24
|
+
});
|
|
25
|
+
compiler.hooks.done.tapPromise('IncrementalDevServerPlugin', async () => {
|
|
27
26
|
this.currentlyRunning = 'none';
|
|
28
|
-
})
|
|
27
|
+
});
|
|
29
28
|
}
|
|
30
|
-
startWatchingBuildableLibs() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
unregisterFileWatcher();
|
|
35
|
-
});
|
|
29
|
+
async startWatchingBuildableLibs() {
|
|
30
|
+
const unregisterFileWatcher = await this.createFileWatcher();
|
|
31
|
+
process.on('exit', () => {
|
|
32
|
+
unregisterFileWatcher();
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
|
-
buildChangedProjects() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
res();
|
|
51
|
-
});
|
|
52
|
-
this.buildCmdProcess.on('error', () => {
|
|
53
|
-
res();
|
|
54
|
-
});
|
|
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();
|
|
55
47
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
this.buildCmdProcess.on('error', () => {
|
|
49
|
+
res();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
this.currentlyRunning = 'none';
|
|
55
|
+
this.buildCmdProcess = null;
|
|
56
|
+
}
|
|
62
57
|
}
|
|
63
58
|
createFileWatcher() {
|
|
64
59
|
const runner = new watch_1.BatchFunctionRunner(() => this.buildChangedProjects());
|
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
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostcssCliResources = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const loader_utils_1 = require("loader-utils");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const url = require("node:url");
|
|
@@ -16,21 +15,19 @@ function wrapUrl(url) {
|
|
|
16
15
|
}
|
|
17
16
|
return `url(${wrappedUrl})`;
|
|
18
17
|
}
|
|
19
|
-
function resolve(file, base, resolver) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
});
|
|
18
|
+
async function resolve(file, base, resolver) {
|
|
19
|
+
try {
|
|
20
|
+
return await resolver(`./${file}`, base);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return resolver(file, base);
|
|
24
|
+
}
|
|
28
25
|
}
|
|
29
26
|
module.exports.postcss = true;
|
|
30
27
|
function PostcssCliResources(options) {
|
|
31
28
|
const { deployUrl = '', baseHref = '', resourcesOutputPath = '', rebaseRootRelative = false, filename, loader, } = options;
|
|
32
29
|
const dedupeSlashes = (url) => url.replace(/\/\/+/g, '/');
|
|
33
|
-
const process = (inputUrl, context, resourceCache) =>
|
|
30
|
+
const process = async (inputUrl, context, resourceCache) => {
|
|
34
31
|
// If root-relative, absolute or protocol relative url, leave as is
|
|
35
32
|
if (/^((?:\w+:)?\/\/|data:|chrome:|#)/.test(inputUrl)) {
|
|
36
33
|
return inputUrl;
|
|
@@ -80,7 +77,7 @@ function PostcssCliResources(options) {
|
|
|
80
77
|
resolve(result);
|
|
81
78
|
});
|
|
82
79
|
});
|
|
83
|
-
const result =
|
|
80
|
+
const result = await resolve(pathname, context, resolver);
|
|
84
81
|
return new Promise((resolve, reject) => {
|
|
85
82
|
loader.fs.readFile(result, (err, content) => {
|
|
86
83
|
if (err) {
|
|
@@ -105,7 +102,7 @@ function PostcssCliResources(options) {
|
|
|
105
102
|
resolve(outputUrl);
|
|
106
103
|
});
|
|
107
104
|
});
|
|
108
|
-
}
|
|
105
|
+
};
|
|
109
106
|
return {
|
|
110
107
|
postcssPlugin: 'postcss-cli-resources',
|
|
111
108
|
Once(root) {
|
|
@@ -123,7 +120,7 @@ function PostcssCliResources(options) {
|
|
|
123
120
|
return;
|
|
124
121
|
}
|
|
125
122
|
const resourceCache = new Map();
|
|
126
|
-
return Promise.all(urlDeclarations.map((decl) =>
|
|
123
|
+
return Promise.all(urlDeclarations.map(async (decl) => {
|
|
127
124
|
const value = decl.value;
|
|
128
125
|
const urlRegex = /url\(\s*(?:"([^"]+)"|'([^']+)'|(.+?))\s*\)/g;
|
|
129
126
|
const segments = [];
|
|
@@ -138,7 +135,7 @@ function PostcssCliResources(options) {
|
|
|
138
135
|
const originalUrl = match[1] || match[2] || match[3];
|
|
139
136
|
let processedUrl;
|
|
140
137
|
try {
|
|
141
|
-
processedUrl =
|
|
138
|
+
processedUrl = await process(originalUrl, context, resourceCache);
|
|
142
139
|
}
|
|
143
140
|
catch (err) {
|
|
144
141
|
loader.emitError(decl.error(err.message, { word: originalUrl }));
|
|
@@ -162,7 +159,7 @@ function PostcssCliResources(options) {
|
|
|
162
159
|
if (modified) {
|
|
163
160
|
decl.value = segments.join('');
|
|
164
161
|
}
|
|
165
|
-
}))
|
|
162
|
+
}));
|
|
166
163
|
},
|
|
167
164
|
};
|
|
168
165
|
}
|
|
@@ -21,13 +21,12 @@ class ScriptsWebpackPlugin {
|
|
|
21
21
|
this.options = options;
|
|
22
22
|
}
|
|
23
23
|
shouldSkip(compilation, scripts) {
|
|
24
|
-
var _a;
|
|
25
24
|
if (this._lastBuildTime == undefined) {
|
|
26
25
|
this._lastBuildTime = Date.now();
|
|
27
26
|
return false;
|
|
28
27
|
}
|
|
29
28
|
for (let i = 0; i < scripts.length; i++) {
|
|
30
|
-
const scriptTime =
|
|
29
|
+
const scriptTime = compilation.fileTimestamps?.get(scripts[i]);
|
|
31
30
|
if (!scriptTime || scriptTime > this._lastBuildTime) {
|
|
32
31
|
this._lastBuildTime = Date.now();
|
|
33
32
|
return false;
|