@nx/webpack 16.4.0-beta.1 → 16.4.0-beta.13
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 +8 -7
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +18 -23
- package/src/executors/webpack/schema.d.ts +0 -12
- package/src/generators/init/init.js +0 -4
- package/src/generators/webpack-project/schema.json +1 -1
- package/src/generators/webpack-project/webpack-project.js +6 -3
- package/src/utils/web-babel-loader.js +4 -3
- package/src/utils/with-nx.d.ts +1 -0
- package/src/utils/with-nx.js +28 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "16.4.0-beta.
|
|
3
|
+
"version": "16.4.0-beta.13",
|
|
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": {
|
|
@@ -30,16 +30,17 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/core": "^7.15.0",
|
|
33
|
-
"@nrwl/webpack": "16.4.0-beta.
|
|
34
|
-
"@nx/devkit": "16.4.0-beta.
|
|
35
|
-
"@nx/js": "16.4.0-beta.
|
|
33
|
+
"@nrwl/webpack": "16.4.0-beta.13",
|
|
34
|
+
"@nx/devkit": "16.4.0-beta.13",
|
|
35
|
+
"@nx/js": "16.4.0-beta.13",
|
|
36
36
|
"autoprefixer": "^10.4.9",
|
|
37
37
|
"babel-loader": "^9.1.2",
|
|
38
|
+
"browserslist": "^4.21.4",
|
|
38
39
|
"chalk": "^4.1.0",
|
|
39
40
|
"chokidar": "^3.5.1",
|
|
40
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
41
42
|
"css-loader": "^6.4.0",
|
|
42
|
-
"css-minimizer-webpack-plugin": "^
|
|
43
|
+
"css-minimizer-webpack-plugin": "^5.0.0",
|
|
43
44
|
"dotenv": "~10.0.0",
|
|
44
45
|
"file-loader": "^6.2.0",
|
|
45
46
|
"fork-ts-checker-webpack-plugin": "7.2.13",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"sass-loader": "^12.2.0",
|
|
59
60
|
"source-map-loader": "^3.0.0",
|
|
60
61
|
"style-loader": "^3.3.0",
|
|
61
|
-
"stylus": "^0.
|
|
62
|
+
"stylus": "^0.59.0",
|
|
62
63
|
"stylus-loader": "^7.1.0",
|
|
63
64
|
"terser-webpack-plugin": "^5.3.3",
|
|
64
65
|
"ts-loader": "^9.3.1",
|
|
@@ -75,5 +76,5 @@
|
|
|
75
76
|
"access": "public"
|
|
76
77
|
},
|
|
77
78
|
"types": "./index.d.ts",
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "d81afedfcc8d07db8cdb9b0e9286de0321ee184e"
|
|
79
80
|
}
|
|
@@ -7,9 +7,9 @@ const chalk = require("chalk");
|
|
|
7
7
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
8
8
|
const wait_until_server_is_listening_1 = require("./lib/wait-until-server-is-listening");
|
|
9
9
|
function ssrDevServerExecutor(options, context) {
|
|
10
|
-
var _a;
|
|
10
|
+
var _a, _b;
|
|
11
11
|
return tslib_1.__asyncGenerator(this, arguments, function* ssrDevServerExecutor_1() {
|
|
12
|
-
var
|
|
12
|
+
var _c, e_1, _d, _e;
|
|
13
13
|
const browserTarget = (0, devkit_1.parseTargetString)(options.browserTarget, context.projectGraph);
|
|
14
14
|
const serverTarget = (0, devkit_1.parseTargetString)(options.serverTarget, context.projectGraph);
|
|
15
15
|
const browserOptions = (0, devkit_1.readTargetOptions)(browserTarget, context);
|
|
@@ -21,34 +21,29 @@ function ssrDevServerExecutor(options, context) {
|
|
|
21
21
|
const combined = (0, async_iterable_1.combineAsyncIterables)(runBrowser, runServer);
|
|
22
22
|
process.env['port'] = `${options.port}`;
|
|
23
23
|
try {
|
|
24
|
-
for (var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
nodeStarted = true;
|
|
33
|
-
}
|
|
34
|
-
else if (((_a = output.options) === null || _a === void 0 ? void 0 : _a.target) === 'web') {
|
|
35
|
-
browserBuilt = true;
|
|
36
|
-
}
|
|
37
|
-
if (nodeStarted && browserBuilt) {
|
|
38
|
-
yield tslib_1.__await((0, wait_until_server_is_listening_1.waitUntilServerIsListening)(options.port));
|
|
39
|
-
console.log(`[ ${chalk.green('ready')} ] on http://localhost:${options.port}`);
|
|
40
|
-
yield yield tslib_1.__await(Object.assign(Object.assign({}, output), { baseUrl: `http://localhost:${options.port}` }));
|
|
41
|
-
}
|
|
24
|
+
for (var _f = true, combined_1 = tslib_1.__asyncValues(combined), combined_1_1; combined_1_1 = yield tslib_1.__await(combined_1.next()), _c = combined_1_1.done, !_c; _f = true) {
|
|
25
|
+
_e = combined_1_1.value;
|
|
26
|
+
_f = false;
|
|
27
|
+
const output = _e;
|
|
28
|
+
if (!output.success)
|
|
29
|
+
throw new Error('Could not build application');
|
|
30
|
+
if (((_a = output.options) === null || _a === void 0 ? void 0 : _a.target) === 'node') {
|
|
31
|
+
nodeStarted = true;
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
else if (((_b = output.options) === null || _b === void 0 ? void 0 : _b.target) === 'web') {
|
|
34
|
+
browserBuilt = true;
|
|
35
|
+
}
|
|
36
|
+
if (nodeStarted && browserBuilt) {
|
|
37
|
+
yield tslib_1.__await((0, wait_until_server_is_listening_1.waitUntilServerIsListening)(options.port));
|
|
38
|
+
console.log(`[ ${chalk.green('ready')} ] on http://localhost:${options.port}`);
|
|
39
|
+
yield yield tslib_1.__await(Object.assign(Object.assign({}, output), { baseUrl: `http://localhost:${options.port}` }));
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
49
44
|
finally {
|
|
50
45
|
try {
|
|
51
|
-
if (!
|
|
46
|
+
if (!_f && !_c && (_d = combined_1.return)) yield tslib_1.__await(_d.call(combined_1));
|
|
52
47
|
}
|
|
53
48
|
finally { if (e_1) throw e_1.error; }
|
|
54
49
|
}
|
|
@@ -70,28 +70,16 @@ export interface WebpackExecutorOptions {
|
|
|
70
70
|
webpackConfig?: string;
|
|
71
71
|
babelConfig?: string;
|
|
72
72
|
babelUpwardRootMode?: boolean;
|
|
73
|
-
// TODO(jack): Also deprecate these in schema.json once we have migration from executor options to webpack.config.js file.
|
|
74
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
75
73
|
baseHref?: string;
|
|
76
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
77
74
|
crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
|
|
78
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
79
75
|
deployUrl?: string;
|
|
80
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
81
76
|
extractCss?: boolean;
|
|
82
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
83
77
|
generateIndexHtml?: boolean;
|
|
84
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
85
78
|
index?: string;
|
|
86
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
87
79
|
postcssConfig?: string;
|
|
88
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
89
80
|
scripts?: Array<ExtraEntryPointClass | string>;
|
|
90
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
91
81
|
stylePreprocessorOptions?: any;
|
|
92
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
93
82
|
styles?: Array<ExtraEntryPointClass | string>;
|
|
94
|
-
/** @deprecated Moved to withWeb options from `@nx/webpack` */
|
|
95
83
|
subresourceIntegrity?: boolean;
|
|
96
84
|
}
|
|
97
85
|
|
|
@@ -5,13 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
|
|
9
8
|
function webpackInitGenerator(tree, schema) {
|
|
10
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
10
|
const tasks = [];
|
|
12
|
-
if (schema.compiler === 'babel') {
|
|
13
|
-
(0, add_babel_inputs_1.addBabelInputs)(tree);
|
|
14
|
-
}
|
|
15
11
|
const devDependencies = {
|
|
16
12
|
'@nx/webpack': versions_1.nxVersion,
|
|
17
13
|
};
|
|
@@ -37,7 +37,7 @@ function addBuildTarget(tree, options) {
|
|
|
37
37
|
const buildOptions = {
|
|
38
38
|
target: options.target,
|
|
39
39
|
outputPath: (0, devkit_1.joinPathFragments)('dist', project.root),
|
|
40
|
-
compiler: (_a = options.compiler) !== null && _a !== void 0 ? _a : '
|
|
40
|
+
compiler: (_a = options.compiler) !== null && _a !== void 0 ? _a : 'swc',
|
|
41
41
|
main: (_b = options.main) !== null && _b !== void 0 ? _b : (0, devkit_1.joinPathFragments)(project.root, 'src/main.ts'),
|
|
42
42
|
tsConfig: (_c = options.tsConfig) !== null && _c !== void 0 ? _c : (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.app.json'),
|
|
43
43
|
webpackConfig: (0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'),
|
|
@@ -48,8 +48,11 @@ function addBuildTarget(tree, options) {
|
|
|
48
48
|
if (options.babelConfig) {
|
|
49
49
|
buildOptions.babelConfig = options.babelConfig;
|
|
50
50
|
}
|
|
51
|
-
else {
|
|
52
|
-
|
|
51
|
+
else if (options.compiler === 'babel') {
|
|
52
|
+
// If no babel config file is provided then write a default one, otherwise build will fail.
|
|
53
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(project.root, '.babelrc'), {
|
|
54
|
+
presets: ['@nx/js/babel'],
|
|
55
|
+
});
|
|
53
56
|
}
|
|
54
57
|
if (options.target === 'web') {
|
|
55
58
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'webpack.config.js'), `
|
|
@@ -12,15 +12,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
module.exports = require('babel-loader').custom(() => {
|
|
13
13
|
return {
|
|
14
14
|
customOptions(_a) {
|
|
15
|
-
var { isModern, emitDecoratorMetadata } = _a, loader = __rest(_a, ["isModern", "emitDecoratorMetadata"]);
|
|
15
|
+
var { isTest, isModern, emitDecoratorMetadata } = _a, loader = __rest(_a, ["isTest", "isModern", "emitDecoratorMetadata"]);
|
|
16
16
|
return {
|
|
17
|
-
custom: { isModern, emitDecoratorMetadata },
|
|
17
|
+
custom: { isTest, isModern, emitDecoratorMetadata },
|
|
18
18
|
loader,
|
|
19
19
|
};
|
|
20
20
|
},
|
|
21
|
-
config(cfg, { customOptions: { isModern, emitDecoratorMetadata } }) {
|
|
21
|
+
config(cfg, { customOptions: { isTest, isModern, emitDecoratorMetadata } }) {
|
|
22
22
|
// Add hint to our babel preset so it can handle modern vs legacy bundles.
|
|
23
23
|
cfg.options.caller.isModern = isModern;
|
|
24
|
+
cfg.options.caller.isTest = isTest;
|
|
24
25
|
cfg.options.caller.emitDecoratorMetadata = emitDecoratorMetadata;
|
|
25
26
|
return cfg.options;
|
|
26
27
|
},
|
package/src/utils/with-nx.d.ts
CHANGED
package/src/utils/with-nx.js
CHANGED
|
@@ -2,17 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLoaderFromCompiler = exports.withNx = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const webpack_1 = require("webpack");
|
|
6
7
|
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
7
8
|
const js_1 = require("@nx/js");
|
|
8
9
|
const license_webpack_plugin_1 = require("license-webpack-plugin");
|
|
9
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
10
|
-
const nodeExternals = require("webpack-node-externals");
|
|
11
|
-
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
12
10
|
const stats_json_plugin_1 = require("../plugins/stats-json-plugin");
|
|
13
11
|
const create_copy_plugin_1 = require("./create-copy-plugin");
|
|
14
12
|
const generate_package_json_plugin_1 = require("../plugins/generate-package-json-plugin");
|
|
15
13
|
const hash_format_1 = require("./hash-format");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
16
|
+
const nodeExternals = require("webpack-node-externals");
|
|
17
|
+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
18
|
+
const browserslist = require("browserslist");
|
|
19
|
+
const VALID_BROWSERSLIST_FILES = ['.browserslistrc', 'browserslist'];
|
|
20
|
+
function getTerserEcmaVersion(projectRoot) {
|
|
21
|
+
let pathToBrowserslistFile = '';
|
|
22
|
+
for (const browserslistFile of VALID_BROWSERSLIST_FILES) {
|
|
23
|
+
const fullPathToFile = (0, path_1.join)(projectRoot, browserslistFile);
|
|
24
|
+
if ((0, fs_1.existsSync)(fullPathToFile)) {
|
|
25
|
+
pathToBrowserslistFile = fullPathToFile;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!pathToBrowserslistFile) {
|
|
30
|
+
return 2020;
|
|
31
|
+
}
|
|
32
|
+
const env = browserslist.loadConfig({ path: pathToBrowserslistFile });
|
|
33
|
+
const browsers = browserslist(env);
|
|
34
|
+
return browsers.includes('ie 11') ? 5 : 2020;
|
|
35
|
+
}
|
|
16
36
|
const IGNORED_WEBPACK_WARNINGS = [
|
|
17
37
|
/The comment file/i,
|
|
18
38
|
/could not find any license/i,
|
|
@@ -143,7 +163,7 @@ function withNx(pluginOptions) {
|
|
|
143
163
|
parallel: true,
|
|
144
164
|
terserOptions: {
|
|
145
165
|
keep_classnames: true,
|
|
146
|
-
ecma:
|
|
166
|
+
ecma: getTerserEcmaVersion((0, path_1.join)(options.root, options.projectRoot)),
|
|
147
167
|
safari10: true,
|
|
148
168
|
format: {
|
|
149
169
|
ascii_only: true,
|
|
@@ -215,7 +235,7 @@ function withNx(pluginOptions) {
|
|
|
215
235
|
}
|
|
216
236
|
exports.withNx = withNx;
|
|
217
237
|
function createLoaderFromCompiler(options) {
|
|
218
|
-
var _a, _b;
|
|
238
|
+
var _a, _b, _c;
|
|
219
239
|
switch (options.compiler) {
|
|
220
240
|
case 'swc':
|
|
221
241
|
return {
|
|
@@ -267,7 +287,8 @@ function createLoaderFromCompiler(options) {
|
|
|
267
287
|
cwd: path.join(options.root, options.sourceRoot),
|
|
268
288
|
emitDecoratorMetadata: tsConfig.options.emitDecoratorMetadata,
|
|
269
289
|
isModern: true,
|
|
270
|
-
|
|
290
|
+
isTest: process.env.NX_CYPRESS_COMPONENT_TEST === 'true',
|
|
291
|
+
envName: (_a = process.env.BABEL_ENV) !== null && _a !== void 0 ? _a : process.env.NODE_ENV,
|
|
271
292
|
cacheDirectory: true,
|
|
272
293
|
cacheCompression: false,
|
|
273
294
|
},
|
|
@@ -278,7 +299,7 @@ function createLoaderFromCompiler(options) {
|
|
|
278
299
|
}
|
|
279
300
|
else {
|
|
280
301
|
babelConfig.options['configFile'] =
|
|
281
|
-
(
|
|
302
|
+
(_c = (_b = babelConfig.options) === null || _b === void 0 ? void 0 : _b['babelConfig']) !== null && _c !== void 0 ? _c : path.join(options.root, options.projectRoot, '.babelrc');
|
|
282
303
|
}
|
|
283
304
|
return babelConfig;
|
|
284
305
|
default:
|