@nx/web 21.0.0-beta.1 → 21.0.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/package.json +3 -3
- package/src/generators/application/application.js +64 -59
- package/src/generators/application/files/app-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/app-webpack/src/index.html +1 -1
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "21.0.0-beta.
|
|
3
|
+
"version": "21.0.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, Playwright, 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": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"http-server": "^14.1.0",
|
|
36
36
|
"picocolors": "^1.1.0",
|
|
37
37
|
"tslib": "^2.3.0",
|
|
38
|
-
"@nx/devkit": "21.0.0-beta.
|
|
39
|
-
"@nx/js": "21.0.0-beta.
|
|
38
|
+
"@nx/devkit": "21.0.0-beta.2",
|
|
39
|
+
"@nx/js": "21.0.0-beta.2"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -16,13 +16,11 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
|
16
16
|
const static_serve_configuration_1 = require("../static-serve/static-serve-configuration");
|
|
17
17
|
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
18
18
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
19
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
20
19
|
function createApplicationFiles(tree, options) {
|
|
21
20
|
const rootTsConfigPath = (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot);
|
|
22
21
|
if (options.bundler === 'vite') {
|
|
23
22
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-vite'), options.appProjectRoot, {
|
|
24
23
|
...options,
|
|
25
|
-
...(0, devkit_1.names)(options.name),
|
|
26
24
|
tmpl: '',
|
|
27
25
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
28
26
|
rootTsConfigPath,
|
|
@@ -32,7 +30,6 @@ function createApplicationFiles(tree, options) {
|
|
|
32
30
|
const rootOffset = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
|
|
33
31
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-webpack'), options.appProjectRoot, {
|
|
34
32
|
...options,
|
|
35
|
-
...(0, devkit_1.names)(options.name),
|
|
36
33
|
tmpl: '',
|
|
37
34
|
offsetFromRoot: rootOffset,
|
|
38
35
|
rootTsConfigPath,
|
|
@@ -153,17 +150,19 @@ async function setupBundler(tree, options) {
|
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
152
|
async function addProject(tree, options) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
const packageJson = {
|
|
154
|
+
name: options.importPath,
|
|
155
|
+
version: '0.0.1',
|
|
156
|
+
private: true,
|
|
157
|
+
};
|
|
158
|
+
if (!options.useProjectJson) {
|
|
159
|
+
if (options.projectName !== options.importPath) {
|
|
160
|
+
packageJson.nx = { name: options.projectName };
|
|
161
|
+
}
|
|
162
|
+
if (options.parsedTags?.length) {
|
|
163
|
+
packageJson.nx ??= {};
|
|
164
|
+
packageJson.nx.tags = options.parsedTags;
|
|
165
|
+
}
|
|
167
166
|
}
|
|
168
167
|
else {
|
|
169
168
|
(0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
|
|
@@ -174,6 +173,9 @@ async function addProject(tree, options) {
|
|
|
174
173
|
targets: {},
|
|
175
174
|
});
|
|
176
175
|
}
|
|
176
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
177
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
178
|
+
}
|
|
177
179
|
}
|
|
178
180
|
function setDefaults(tree, options) {
|
|
179
181
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -196,7 +198,7 @@ async function applicationGenerator(host, schema) {
|
|
|
196
198
|
async function applicationGeneratorInternal(host, schema) {
|
|
197
199
|
const options = await normalizeOptions(host, schema);
|
|
198
200
|
if (options.isUsingTsSolutionConfig) {
|
|
199
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
201
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
200
202
|
}
|
|
201
203
|
const tasks = [];
|
|
202
204
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
@@ -215,6 +217,21 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
215
217
|
await setupBundler(host, options);
|
|
216
218
|
}
|
|
217
219
|
createApplicationFiles(host, options);
|
|
220
|
+
if (options.linter === 'eslint') {
|
|
221
|
+
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_2.nxVersion);
|
|
222
|
+
const lintTask = await lintProjectGenerator(host, {
|
|
223
|
+
linter: options.linter,
|
|
224
|
+
project: options.projectName,
|
|
225
|
+
tsConfigPaths: [
|
|
226
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
227
|
+
],
|
|
228
|
+
unitTestRunner: options.unitTestRunner,
|
|
229
|
+
skipFormat: true,
|
|
230
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
231
|
+
addPlugin: options.addPlugin,
|
|
232
|
+
});
|
|
233
|
+
tasks.push(lintTask);
|
|
234
|
+
}
|
|
218
235
|
if (options.bundler === 'vite') {
|
|
219
236
|
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_2.nxVersion);
|
|
220
237
|
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
@@ -262,21 +279,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
262
279
|
options.inSourceTests) {
|
|
263
280
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/app.element.spec.ts`));
|
|
264
281
|
}
|
|
265
|
-
if (options.linter === 'eslint') {
|
|
266
|
-
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_2.nxVersion);
|
|
267
|
-
const lintTask = await lintProjectGenerator(host, {
|
|
268
|
-
linter: options.linter,
|
|
269
|
-
project: options.projectName,
|
|
270
|
-
tsConfigPaths: [
|
|
271
|
-
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
272
|
-
],
|
|
273
|
-
unitTestRunner: options.unitTestRunner,
|
|
274
|
-
skipFormat: true,
|
|
275
|
-
setParserOptionsProject: options.setParserOptionsProject,
|
|
276
|
-
addPlugin: options.addPlugin,
|
|
277
|
-
});
|
|
278
|
-
tasks.push(lintTask);
|
|
279
|
-
}
|
|
280
282
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
281
283
|
let hasPlugin;
|
|
282
284
|
let buildPlugin;
|
|
@@ -310,17 +312,15 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
310
312
|
}
|
|
311
313
|
if (options.e2eTestRunner === 'cypress') {
|
|
312
314
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
},
|
|
323
|
-
});
|
|
315
|
+
const packageJson = {
|
|
316
|
+
name: options.e2eProjectName,
|
|
317
|
+
version: '0.0.1',
|
|
318
|
+
private: true,
|
|
319
|
+
};
|
|
320
|
+
if (!options.useProjectJson) {
|
|
321
|
+
packageJson.nx = {
|
|
322
|
+
implicitDependencies: [options.projectName],
|
|
323
|
+
};
|
|
324
324
|
}
|
|
325
325
|
else {
|
|
326
326
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -332,6 +332,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
332
332
|
implicitDependencies: [options.projectName],
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
336
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
337
|
+
}
|
|
335
338
|
const cypressTask = await configurationGenerator(host, {
|
|
336
339
|
...options,
|
|
337
340
|
project: options.e2eProjectName,
|
|
@@ -367,17 +370,15 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
367
370
|
}
|
|
368
371
|
else if (options.e2eTestRunner === 'playwright') {
|
|
369
372
|
const { configurationGenerator: playwrightConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
},
|
|
380
|
-
});
|
|
373
|
+
const packageJson = {
|
|
374
|
+
name: options.e2eProjectName,
|
|
375
|
+
version: '0.0.1',
|
|
376
|
+
private: true,
|
|
377
|
+
};
|
|
378
|
+
if (!options.useProjectJson) {
|
|
379
|
+
packageJson.nx = {
|
|
380
|
+
implicitDependencies: [options.projectName],
|
|
381
|
+
};
|
|
381
382
|
}
|
|
382
383
|
else {
|
|
383
384
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -389,6 +390,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
389
390
|
implicitDependencies: [options.projectName],
|
|
390
391
|
});
|
|
391
392
|
}
|
|
393
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
394
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
395
|
+
}
|
|
392
396
|
const playwrightTask = await playwrightConfigGenerator(host, {
|
|
393
397
|
project: options.e2eProjectName,
|
|
394
398
|
skipFormat: true,
|
|
@@ -462,8 +466,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
462
466
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
463
467
|
}
|
|
464
468
|
async function normalizeOptions(host, options) {
|
|
465
|
-
await (0, project_name_and_root_utils_1.
|
|
466
|
-
const { projectName
|
|
469
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
|
470
|
+
const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
467
471
|
name: options.name,
|
|
468
472
|
projectType: 'application',
|
|
469
473
|
directory: options.directory,
|
|
@@ -472,9 +476,10 @@ async function normalizeOptions(host, options) {
|
|
|
472
476
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
473
477
|
nxJson.useInferencePlugins !== false;
|
|
474
478
|
options.addPlugin ??= addPluginDefault;
|
|
479
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
480
|
+
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
475
481
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
476
482
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
477
|
-
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
478
483
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
479
484
|
const parsedTags = options.tags
|
|
480
485
|
? options.tags.split(',').map((s) => s.trim())
|
|
@@ -486,18 +491,18 @@ async function normalizeOptions(host, options) {
|
|
|
486
491
|
return {
|
|
487
492
|
...options,
|
|
488
493
|
prefix: options.prefix ?? npmScope ?? 'app',
|
|
489
|
-
name: (0, devkit_1.names)(options.name).fileName,
|
|
490
494
|
compiler: options.compiler ?? 'babel',
|
|
491
495
|
bundler: options.bundler ?? 'webpack',
|
|
492
|
-
projectName:
|
|
493
|
-
|
|
494
|
-
: appProjectName,
|
|
496
|
+
projectName: appProjectName,
|
|
497
|
+
importPath,
|
|
495
498
|
strict: options.strict ?? true,
|
|
496
499
|
appProjectRoot,
|
|
497
500
|
e2eProjectRoot,
|
|
498
501
|
e2eProjectName,
|
|
499
502
|
parsedTags,
|
|
503
|
+
names: (0, devkit_1.names)(projectName),
|
|
500
504
|
isUsingTsSolutionConfig,
|
|
505
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
501
506
|
};
|
|
502
507
|
}
|
|
503
508
|
exports.default = applicationGenerator;
|
|
@@ -104,6 +104,10 @@
|
|
|
104
104
|
"type": "boolean",
|
|
105
105
|
"description": "Creates an application with strict mode and strict type checking.",
|
|
106
106
|
"default": true
|
|
107
|
+
},
|
|
108
|
+
"useProjectJson": {
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
113
|
"required": ["directory"],
|