@nx/web 16.8.0-beta.1 → 16.8.0-beta.2

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/generators.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "hidden": true
11
11
  },
12
12
  "application": {
13
- "factory": "./src/generators/application/application#applicationGenerator",
13
+ "factory": "./src/generators/application/application#applicationGeneratorInternal",
14
14
  "schema": "./src/generators/application/schema.json",
15
15
  "aliases": ["app"],
16
16
  "x-type": "application",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/web",
3
- "version": "16.8.0-beta.1",
3
+ "version": "16.8.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nrwl/web": "16.8.0-beta.1",
34
- "@nx/devkit": "16.8.0-beta.1",
35
- "@nx/js": "16.8.0-beta.1",
33
+ "@nrwl/web": "16.8.0-beta.2",
34
+ "@nx/devkit": "16.8.0-beta.2",
35
+ "@nx/js": "16.8.0-beta.2",
36
36
  "chalk": "^4.1.0",
37
37
  "chokidar": "^3.5.1",
38
38
  "detect-port": "^1.5.1",
@@ -44,5 +44,5 @@
44
44
  "access": "public"
45
45
  },
46
46
  "type": "commonjs",
47
- "gitHead": "231a998e004c13e559c171ba6c164a9127886153"
47
+ "gitHead": "9bcc04742f9e1516d8c1ddbfb1907770c347876f"
48
48
  }
@@ -1,5 +1,6 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function applicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function applicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
5
  export default applicationGenerator;
5
6
  export declare const applicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applicationSchematic = exports.applicationGenerator = void 0;
3
+ exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path_1 = require("path");
6
5
  const devkit_1 = require("@nx/devkit");
7
- const versions_1 = require("@nx/js/src/utils/versions");
6
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
8
7
  const js_1 = require("@nx/js");
8
+ const versions_1 = require("@nx/js/src/utils/versions");
9
+ const path_1 = require("path");
9
10
  const versions_2 = require("../../utils/versions");
10
11
  const init_1 = require("../init/init");
11
12
  function createApplicationFiles(tree, options) {
@@ -105,7 +106,13 @@ function setDefaults(tree, options) {
105
106
  }
106
107
  function applicationGenerator(host, schema) {
107
108
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
- const options = normalizeOptions(host, schema);
109
+ return yield applicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
110
+ });
111
+ }
112
+ exports.applicationGenerator = applicationGenerator;
113
+ function applicationGeneratorInternal(host, schema) {
114
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
115
+ const options = yield normalizeOptions(host, schema);
109
116
  const tasks = [];
110
117
  const webTask = yield (0, init_1.webInitGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
111
118
  tasks.push(webTask);
@@ -160,7 +167,9 @@ function applicationGenerator(host, schema) {
160
167
  }
161
168
  if (options.e2eTestRunner === 'cypress') {
162
169
  const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
163
- const cypressTask = yield cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { name: `${options.name}-e2e`, directory: options.directory, project: options.projectName, skipFormat: true }));
170
+ const cypressTask = yield cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { name: options.e2eProjectName, directory: options.e2eProjectRoot,
171
+ // the name and root are already normalized, instruct the generator to use them as is
172
+ projectNameAndRootFormat: 'as-provided', project: options.projectName, skipFormat: true }));
164
173
  tasks.push(cypressTask);
165
174
  }
166
175
  else if (options.e2eTestRunner === 'playwright') {
@@ -197,9 +206,22 @@ function applicationGenerator(host, schema) {
197
206
  tasks.push(jestTask);
198
207
  }
199
208
  if (options.compiler === 'swc') {
209
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.swcrc'), {
210
+ jsc: {
211
+ parser: {
212
+ syntax: 'typescript',
213
+ },
214
+ target: 'es2016',
215
+ },
216
+ });
200
217
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@swc/core': versions_1.swcCoreVersion, 'swc-loader': versions_2.swcLoaderVersion });
201
218
  tasks.push(installTask);
202
219
  }
220
+ else {
221
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc'), {
222
+ presets: ['@nx/js/babel'],
223
+ });
224
+ }
203
225
  setDefaults(host, options);
204
226
  if (!schema.skipFormat) {
205
227
  yield (0, devkit_1.formatFiles)(host);
@@ -207,33 +229,36 @@ function applicationGenerator(host, schema) {
207
229
  return (0, devkit_1.runTasksInSerial)(...tasks);
208
230
  });
209
231
  }
210
- exports.applicationGenerator = applicationGenerator;
232
+ exports.applicationGeneratorInternal = applicationGeneratorInternal;
211
233
  function normalizeOptions(host, options) {
212
234
  var _a, _b, _c, _d;
213
- const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
214
- const appDirectory = projectDirectory
215
- ? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
216
- : (0, devkit_1.names)(options.name).fileName;
217
- const { appsDir: defaultAppsDir, npmScope } = (0, devkit_1.getWorkspaceLayout)(host);
218
- const appsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultAppsDir;
219
- const appProjectName = appDirectory.replace(new RegExp('/', 'g'), '-');
220
- const e2eProjectName = `${appProjectName}-e2e`;
221
- const appProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, appDirectory);
222
- const e2eProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, `${appDirectory}-e2e`);
223
- const parsedTags = options.tags
224
- ? options.tags.split(',').map((s) => s.trim())
225
- : [];
226
- if (options.bundler === 'vite' && !options.unitTestRunner) {
227
- options.unitTestRunner = 'vitest';
228
- }
229
- options.style = options.style || 'css';
230
- options.linter = options.linter || 'eslint';
231
- options.unitTestRunner = options.unitTestRunner || 'jest';
232
- options.e2eTestRunner = options.e2eTestRunner || 'cypress';
233
- return Object.assign(Object.assign({}, options), { prefix: (_b = (_a = options.prefix) !== null && _a !== void 0 ? _a : npmScope) !== null && _b !== void 0 ? _b : 'app', name: (0, devkit_1.names)(options.name).fileName, compiler: (_c = options.compiler) !== null && _c !== void 0 ? _c : 'babel', bundler: (_d = options.bundler) !== null && _d !== void 0 ? _d : 'webpack', projectName: appProjectName, appProjectRoot,
234
- e2eProjectRoot,
235
- e2eProjectName,
236
- parsedTags });
235
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
236
+ const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
237
+ name: options.name,
238
+ projectType: 'application',
239
+ directory: options.directory,
240
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
241
+ callingGenerator: '@nx/web:application',
242
+ });
243
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
244
+ const e2eProjectName = `${appProjectName}-e2e`;
245
+ const e2eProjectRoot = `${appProjectRoot}-e2e`;
246
+ const { npmScope } = (0, devkit_1.getWorkspaceLayout)(host);
247
+ const parsedTags = options.tags
248
+ ? options.tags.split(',').map((s) => s.trim())
249
+ : [];
250
+ if (options.bundler === 'vite' && !options.unitTestRunner) {
251
+ options.unitTestRunner = 'vitest';
252
+ }
253
+ options.style = options.style || 'css';
254
+ options.linter = options.linter || 'eslint';
255
+ options.unitTestRunner = options.unitTestRunner || 'jest';
256
+ options.e2eTestRunner = options.e2eTestRunner || 'cypress';
257
+ return Object.assign(Object.assign({}, options), { prefix: (_b = (_a = options.prefix) !== null && _a !== void 0 ? _a : npmScope) !== null && _b !== void 0 ? _b : 'app', name: (0, devkit_1.names)(options.name).fileName, compiler: (_c = options.compiler) !== null && _c !== void 0 ? _c : 'babel', bundler: (_d = options.bundler) !== null && _d !== void 0 ? _d : 'webpack', projectName: appProjectName, appProjectRoot,
258
+ e2eProjectRoot,
259
+ e2eProjectName,
260
+ parsedTags });
261
+ });
237
262
  }
238
263
  exports.default = applicationGenerator;
239
264
  exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
@@ -1,3 +1,4 @@
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
1
2
  import type { Linter } from '@nx/linter';
2
3
 
3
4
  export interface Schema {
@@ -8,6 +9,7 @@ export interface Schema {
8
9
  compiler?: 'babel' | 'swc';
9
10
  skipFormat?: boolean;
10
11
  directory?: string;
12
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
13
  tags?: string;
12
14
  unitTestRunner?: 'jest' | 'vitest' | 'none';
13
15
  inSourceTests?: boolean;
@@ -14,12 +14,17 @@
14
14
  "index": 0
15
15
  },
16
16
  "x-prompt": "What name would you like to use for the application?",
17
- "pattern": "^[a-zA-Z].*$"
17
+ "pattern": "^[a-zA-Z][^:]*$"
18
18
  },
19
19
  "directory": {
20
20
  "description": "The directory of the new application.",
21
21
  "type": "string"
22
22
  },
23
+ "projectNameAndRootFormat": {
24
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
25
+ "type": "string",
26
+ "enum": ["as-provided", "derived"]
27
+ },
23
28
  "style": {
24
29
  "description": "The file extension to be used for style files.",
25
30
  "type": "string",
@@ -1,5 +0,0 @@
1
- {
2
- "presets": [
3
- "@nx/js/babel"
4
- ]
5
- }