@nx/node 17.2.0-beta.1 → 17.2.0-beta.10

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.1",
3
+ "version": "17.2.0-beta.10",
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.1",
35
- "@nx/jest": "17.2.0-beta.1",
36
- "@nx/js": "17.2.0-beta.1",
37
- "@nx/eslint": "17.2.0-beta.1",
38
- "@nrwl/node": "17.2.0-beta.1"
34
+ "@nx/devkit": "17.2.0-beta.10",
35
+ "@nx/jest": "17.2.0-beta.10",
36
+ "@nx/js": "17.2.0-beta.10",
37
+ "@nx/eslint": "17.2.0-beta.10",
38
+ "@nrwl/node": "17.2.0-beta.10"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -7,12 +7,12 @@ const jest_1 = require("@nx/jest");
7
7
  const js_1 = require("@nx/js");
8
8
  const versions_1 = require("@nx/js/src/utils/versions");
9
9
  const eslint_1 = require("@nx/eslint");
10
- const lint_project_1 = require("@nx/eslint/src/generators/lint-project/lint-project");
11
10
  const path_1 = require("path");
12
11
  const versions_2 = require("../../utils/versions");
13
12
  const e2e_project_1 = require("../e2e-project/e2e-project");
14
13
  const init_1 = require("../init/init");
15
14
  const setup_docker_1 = require("../setup-docker/setup-docker");
15
+ const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
16
16
  function getWebpackBuildConfig(project, options) {
17
17
  return {
18
18
  executor: `@nx/webpack:webpack`,
@@ -25,7 +25,6 @@ function getWebpackBuildConfig(project, options) {
25
25
  main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
26
26
  tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
27
27
  assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
28
- isolatedConfig: true,
29
28
  webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
30
29
  },
31
30
  configurations: {
@@ -95,14 +94,19 @@ function addProject(tree, options) {
95
94
  targets: {},
96
95
  tags: options.parsedTags,
97
96
  };
98
- project.targets.build =
99
- options.bundler === 'esbuild'
100
- ? getEsBuildConfig(project, options)
101
- : getWebpackBuildConfig(project, options);
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
+ }
102
105
  project.targets.serve = getServeConfig(options);
103
106
  (0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
104
107
  }
105
108
  function addAppFiles(tree, options) {
109
+ const sourceRoot = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src');
106
110
  (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
107
111
  ...options,
108
112
  tmpl: '',
@@ -110,6 +114,14 @@ function addAppFiles(tree, options) {
110
114
  root: options.appProjectRoot,
111
115
  offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
112
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,
113
125
  });
114
126
  if (options.bundler !== 'webpack') {
115
127
  tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'));
@@ -169,9 +181,6 @@ async function addLintingToApplication(tree, options) {
169
181
  tsConfigPaths: [
170
182
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
171
183
  ],
172
- eslintFilePatterns: [
173
- (0, lint_project_1.mapLintPattern)(options.appProjectRoot, options.js ? 'js' : 'ts', options.rootProject),
174
- ],
175
184
  unitTestRunner: options.unitTestRunner,
176
185
  skipFormat: true,
177
186
  setParserOptionsProject: options.setParserOptionsProject,
@@ -266,6 +275,14 @@ async function applicationGeneratorInternal(tree, schema) {
266
275
  tasks.push(initTask);
267
276
  const installTask = addProjectDependencies(tree, options);
268
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
+ }
269
286
  addAppFiles(tree, options);
270
287
  addProject(tree, options);
271
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(withNx(), (config) => {
5
- // Update the webpack config as needed here.
6
- // e.g. `config.plugins.push(new MyPlugin())`
7
- return config;
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
+ <% } %>
@@ -71,7 +71,6 @@ async function e2eProjectGeneratorInternal(host, _options) {
71
71
  tsConfigPaths: [
72
72
  (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
73
73
  ],
74
- eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
75
74
  setParserOptionsProject: false,
76
75
  skipPackageJson: false,
77
76
  rootProject: options.rootProject,
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function hasWebpackPlugin(tree: Tree): boolean;
@@ -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;