@nx/node 17.2.0-beta.8 → 17.2.0-beta.9
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "17.2.0-beta.
|
|
3
|
+
"version": "17.2.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
|
|
6
6
|
"repository": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nx/devkit": "17.2.0-beta.
|
|
35
|
-
"@nx/jest": "17.2.0-beta.
|
|
36
|
-
"@nx/js": "17.2.0-beta.
|
|
37
|
-
"@nx/eslint": "17.2.0-beta.
|
|
38
|
-
"@nrwl/node": "17.2.0-beta.
|
|
34
|
+
"@nx/devkit": "17.2.0-beta.9",
|
|
35
|
+
"@nx/jest": "17.2.0-beta.9",
|
|
36
|
+
"@nx/js": "17.2.0-beta.9",
|
|
37
|
+
"@nx/eslint": "17.2.0-beta.9",
|
|
38
|
+
"@nrwl/node": "17.2.0-beta.9"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -12,6 +12,7 @@ const versions_2 = require("../../utils/versions");
|
|
|
12
12
|
const e2e_project_1 = require("../e2e-project/e2e-project");
|
|
13
13
|
const init_1 = require("../init/init");
|
|
14
14
|
const setup_docker_1 = require("../setup-docker/setup-docker");
|
|
15
|
+
const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
15
16
|
function getWebpackBuildConfig(project, options) {
|
|
16
17
|
return {
|
|
17
18
|
executor: `@nx/webpack:webpack`,
|
|
@@ -24,7 +25,6 @@ function getWebpackBuildConfig(project, options) {
|
|
|
24
25
|
main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
|
|
25
26
|
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
26
27
|
assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
|
|
27
|
-
isolatedConfig: true,
|
|
28
28
|
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
|
29
29
|
},
|
|
30
30
|
configurations: {
|
|
@@ -94,14 +94,19 @@ function addProject(tree, options) {
|
|
|
94
94
|
targets: {},
|
|
95
95
|
tags: options.parsedTags,
|
|
96
96
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
if (options.bundler === 'esbuild') {
|
|
98
|
+
project.targets.build = getEsBuildConfig(project, options);
|
|
99
|
+
}
|
|
100
|
+
else if (options.bundler === 'webpack') {
|
|
101
|
+
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) {
|
|
102
|
+
project.targets.build = getWebpackBuildConfig(project, options);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
101
105
|
project.targets.serve = getServeConfig(options);
|
|
102
106
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
103
107
|
}
|
|
104
108
|
function addAppFiles(tree, options) {
|
|
109
|
+
const sourceRoot = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src');
|
|
105
110
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
106
111
|
...options,
|
|
107
112
|
tmpl: '',
|
|
@@ -109,6 +114,14 @@ function addAppFiles(tree, options) {
|
|
|
109
114
|
root: options.appProjectRoot,
|
|
110
115
|
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
111
116
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
117
|
+
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
118
|
+
? {
|
|
119
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.appProjectRoot),
|
|
120
|
+
main: './src/main' + (options.js ? '.js' : '.ts'),
|
|
121
|
+
tsConfig: './tsconfig.app.json',
|
|
122
|
+
assets: ['./assets'],
|
|
123
|
+
}
|
|
124
|
+
: null,
|
|
112
125
|
});
|
|
113
126
|
if (options.bundler !== 'webpack') {
|
|
114
127
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'));
|
|
@@ -262,6 +275,14 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
262
275
|
tasks.push(initTask);
|
|
263
276
|
const installTask = addProjectDependencies(tree, options);
|
|
264
277
|
tasks.push(installTask);
|
|
278
|
+
if (options.bundler === 'webpack') {
|
|
279
|
+
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_2.nxVersion);
|
|
280
|
+
const webpackInitTask = await webpackInitGenerator(tree, {
|
|
281
|
+
uiFramework: 'react',
|
|
282
|
+
skipFormat: true,
|
|
283
|
+
});
|
|
284
|
+
tasks.push(webpackInitTask);
|
|
285
|
+
}
|
|
265
286
|
addAppFiles(tree, options);
|
|
266
287
|
addProject(tree, options);
|
|
267
288
|
updateTsConfigOptions(tree, options);
|
|
@@ -1,8 +1,35 @@
|
|
|
1
|
+
<% if (webpackPluginOptions) { %>
|
|
2
|
+
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
output: {
|
|
7
|
+
path: join(__dirname, '<%= offset %><%= webpackPluginOptions.outputPath %>'),
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
new NxWebpackPlugin({
|
|
11
|
+
target: 'node',
|
|
12
|
+
compiler: 'tsc',
|
|
13
|
+
main: '<%= webpackPluginOptions.main %>',
|
|
14
|
+
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
|
|
15
|
+
assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
|
|
16
|
+
optimization: false,
|
|
17
|
+
outputHashing: 'none',
|
|
18
|
+
})
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
<% } else { %>
|
|
1
22
|
const { composePlugins, withNx} = require('@nx/webpack');
|
|
2
23
|
|
|
3
24
|
// Nx plugins for webpack.
|
|
4
|
-
module.exports = composePlugins(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
25
|
+
module.exports = composePlugins(
|
|
26
|
+
withNx({
|
|
27
|
+
target: 'node',
|
|
28
|
+
}),
|
|
29
|
+
(config) => {
|
|
30
|
+
// Update the webpack config as needed here.
|
|
31
|
+
// e.g. `config.plugins.push(new MyPlugin())`
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
<% } %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasWebpackPlugin = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function hasWebpackPlugin(tree) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
+
? p === '@nx/webpack/plugin'
|
|
9
|
+
: p.plugin === '@nx/webpack/plugin');
|
|
10
|
+
}
|
|
11
|
+
exports.hasWebpackPlugin = hasWebpackPlugin;
|