@nx/node 20.4.4 → 20.5.0-beta.1

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": "20.4.4",
3
+ "version": "20.5.0-beta.1",
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": {
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "tslib": "^2.3.0",
35
- "@nx/devkit": "20.4.4",
36
- "@nx/jest": "20.4.4",
37
- "@nx/js": "20.4.4",
38
- "@nx/eslint": "20.4.4"
35
+ "@nx/devkit": "20.5.0-beta.1",
36
+ "@nx/jest": "20.5.0-beta.1",
37
+ "@nx/js": "20.5.0-beta.1",
38
+ "@nx/eslint": "20.5.0-beta.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -166,9 +166,7 @@ function addAppFiles(tree, options) {
166
166
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
167
167
  webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
168
168
  ? {
169
- outputPath: options.isUsingTsSolutionConfig
170
- ? 'dist'
171
- : (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.appProjectRoot), 'dist', options.rootProject ? options.name : options.appProjectRoot),
169
+ outputPath: options.outputPath,
172
170
  main: './src/main' + (options.js ? '.js' : '.ts'),
173
171
  tsConfig: './tsconfig.app.json',
174
172
  assets: ['./src/assets'],
@@ -484,9 +482,7 @@ async function normalizeOptions(host, options) {
484
482
  unitTestRunner: options.unitTestRunner ?? 'jest',
485
483
  rootProject: options.rootProject ?? false,
486
484
  port: options.port ?? 3000,
487
- outputPath: isUsingTsSolutionConfig
488
- ? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
489
- : (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
485
+ outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
490
486
  isUsingTsSolutionConfig,
491
487
  swcJest,
492
488
  };
@@ -4,7 +4,7 @@ const { join } = require('path');
4
4
 
5
5
  module.exports = {
6
6
  output: {
7
- path: join(__dirname, '<%= webpackPluginOptions.outputPath %>'),
7
+ path: join(__dirname, '<%= offset %><%= webpackPluginOptions.outputPath %>'),
8
8
  },
9
9
  plugins: [
10
10
  new NxAppWebpackPlugin({
@@ -14,6 +14,7 @@ const config_file_1 = require("@nx/jest/src/utils/config/config-file");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
15
  const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
16
16
  const posix_1 = require("node:path/posix");
17
+ const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
17
18
  async function e2eProjectGenerator(host, options) {
18
19
  return await e2eProjectGeneratorInternal(host, {
19
20
  addPlugin: false,
@@ -96,13 +97,19 @@ async function e2eProjectGeneratorInternal(host, _options) {
96
97
  const tsConfigFile = isUsingTsSolutionConfig
97
98
  ? 'tsconfig.json'
98
99
  : 'tsconfig.spec.json';
100
+ const rootOffset = (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot);
101
+ const coverageDirectory = isUsingTsSolutionConfig
102
+ ? 'test-output/jest/coverage'
103
+ : (0, devkit_1.joinPathFragments)(rootOffset, 'coverage', options.e2eProjectName);
99
104
  if (options.projectType === 'server') {
100
105
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
101
106
  ...options,
102
107
  ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
103
108
  tsConfigFile,
104
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
109
+ offsetFromRoot: rootOffset,
105
110
  jestPreset,
111
+ coverageDirectory,
112
+ isUsingTsSolutionConfig,
106
113
  tmpl: '',
107
114
  });
108
115
  if (options.isNest) {
@@ -110,7 +117,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
110
117
  ...options,
111
118
  ...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
112
119
  tsConfigFile,
113
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
120
+ offsetFromRoot: rootOffset,
114
121
  tmpl: '',
115
122
  });
116
123
  }
@@ -122,23 +129,26 @@ async function e2eProjectGeneratorInternal(host, _options) {
122
129
  ...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
123
130
  mainFile,
124
131
  tsConfigFile,
125
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
132
+ offsetFromRoot: rootOffset,
126
133
  jestPreset,
134
+ coverageDirectory,
135
+ isUsingTsSolutionConfig,
127
136
  tmpl: '',
128
137
  });
129
138
  }
130
139
  if (isUsingTsSolutionConfig) {
140
+ (0, add_swc_config_1.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
131
141
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/ts-solution'), options.e2eProjectRoot, {
132
142
  ...options,
133
143
  relativeProjectReferencePath: (0, posix_1.relative)(options.e2eProjectRoot, appProject.root),
134
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
144
+ offsetFromRoot: rootOffset,
135
145
  tmpl: '',
136
146
  });
137
147
  }
138
148
  else {
139
149
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/non-ts-solution'), options.e2eProjectRoot, {
140
150
  ...options,
141
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
151
+ offsetFromRoot: rootOffset,
142
152
  tmpl: '',
143
153
  });
144
154
  }
@@ -1,13 +1,26 @@
1
+ <%_ if (isUsingTsSolutionConfig) { _%>
2
+ /* eslint-disable */
3
+ import { readFileSync } from 'fs';
4
+
5
+ // Reading the SWC compilation config for the spec files
6
+ const swcJestConfig = JSON.parse(
7
+ readFileSync(`${__dirname}/.spec.swcrc`, 'utf-8')
8
+ );
9
+
10
+ // Disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves
11
+ swcJestConfig.swcrc = false;
12
+
13
+ <%_ } _%>
1
14
  export default {
2
15
  displayName: '<%= e2eProjectName %>',
3
16
  preset: '<%= offsetFromRoot %><%= jestPreset %>',
4
17
  setupFiles: ['<rootDir>/src/test-setup.ts'],
5
18
  testEnvironment: 'node',
6
19
  transform: {
7
- '^.+\\.[tj]s$': ['ts-jest', {
20
+ '^.+\\.[tj]s$': <% if (isUsingTsSolutionConfig) { %>['@swc/jest', swcJestConfig]<% } else { %>['ts-jest', {
8
21
  tsconfig: '<rootDir>/<%= tsConfigFile %>',
9
- }],
22
+ }]<% } %>,
10
23
  },
11
24
  moduleFileExtensions: ['ts', 'js', 'html'],
12
- coverageDirectory: '<%= offsetFromRoot %>coverage/<%= e2eProjectName %>',
25
+ coverageDirectory: '<%= coverageDirectory %>',
13
26
  };
@@ -1,3 +1,16 @@
1
+ <%_ if (isUsingTsSolutionConfig) { _%>
2
+ /* eslint-disable */
3
+ import { readFileSync } from 'fs';
4
+
5
+ // Reading the SWC compilation config for the spec files
6
+ const swcJestConfig = JSON.parse(
7
+ readFileSync(`${__dirname}/.spec.swcrc`, 'utf-8')
8
+ );
9
+
10
+ // Disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves
11
+ swcJestConfig.swcrc = false;
12
+
13
+ <%_ } _%>
1
14
  export default {
2
15
  displayName: '<%= e2eProjectName %>',
3
16
  preset: '<%= offsetFromRoot %><%= jestPreset %>',
@@ -6,10 +19,10 @@ export default {
6
19
  setupFiles: ['<rootDir>/src/support/test-setup.ts'],
7
20
  testEnvironment: 'node',
8
21
  transform: {
9
- '^.+\\.[tj]s$': ['ts-jest', {
22
+ '^.+\\.[tj]s$': <% if (isUsingTsSolutionConfig) { %>['@swc/jest', swcJestConfig]<% } else { %>['ts-jest', {
10
23
  tsconfig: '<rootDir>/<%= tsConfigFile %>',
11
- }],
24
+ }]<% } %>,
12
25
  },
13
26
  moduleFileExtensions: ['ts', 'js', 'html'],
14
- coverageDirectory: '<%= offsetFromRoot %>coverage/<%= e2eProjectName %>',
27
+ coverageDirectory: '<%= coverageDirectory %>',
15
28
  };