@nx/web 19.5.5 → 19.6.0-beta.0
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/web",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.6.0-beta.0",
|
|
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,9 +35,9 @@
|
|
|
35
35
|
"detect-port": "^1.5.1",
|
|
36
36
|
"http-server": "^14.1.0",
|
|
37
37
|
"tslib": "^2.3.0",
|
|
38
|
-
"@nx/devkit": "19.
|
|
39
|
-
"@nx/js": "19.
|
|
40
|
-
"@nrwl/web": "19.
|
|
38
|
+
"@nx/devkit": "19.6.0-beta.0",
|
|
39
|
+
"@nx/js": "19.6.0-beta.0",
|
|
40
|
+
"@nrwl/web": "19.6.0-beta.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -11,8 +11,10 @@ const versions_2 = require("../../utils/versions");
|
|
|
11
11
|
const init_1 = require("../init/init");
|
|
12
12
|
const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
|
|
13
13
|
const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
14
|
-
const
|
|
14
|
+
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
15
15
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
16
|
+
const static_serve_configuration_1 = require("../static-serve/static-serve-configuration");
|
|
17
|
+
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
16
18
|
function createApplicationFiles(tree, options) {
|
|
17
19
|
if (options.bundler === 'vite') {
|
|
18
20
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-vite'), options.appProjectRoot, {
|
|
@@ -113,7 +115,7 @@ async function setupBundler(tree, options) {
|
|
|
113
115
|
}
|
|
114
116
|
else if (options.bundler === 'none') {
|
|
115
117
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
116
|
-
(0,
|
|
118
|
+
(0, target_defaults_utils_1.addBuildTargetDefaults)(tree, `@nx/js:${options.compiler}`);
|
|
117
119
|
project.targets.build = {
|
|
118
120
|
executor: `@nx/js:${options.compiler}`,
|
|
119
121
|
outputs: ['{options.outputPath}'],
|
|
@@ -237,6 +239,22 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
237
239
|
});
|
|
238
240
|
tasks.push(lintTask);
|
|
239
241
|
}
|
|
242
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
243
|
+
let hasPlugin;
|
|
244
|
+
let buildPlugin;
|
|
245
|
+
let buildConfigFile;
|
|
246
|
+
if (options.bundler === 'webpack' || options.bundler === 'vite') {
|
|
247
|
+
buildPlugin = `@nx/${options.bundler}/plugin`;
|
|
248
|
+
buildConfigFile =
|
|
249
|
+
options.bundler === 'webpack' ? 'webpack.config.js' : `vite.config.ts`;
|
|
250
|
+
hasPlugin = nxJson.plugins?.find((p) => typeof p === 'string' ? p === buildPlugin : p.plugin === buildPlugin);
|
|
251
|
+
}
|
|
252
|
+
if (!hasPlugin) {
|
|
253
|
+
await (0, static_serve_configuration_1.default)(host, {
|
|
254
|
+
buildTarget: `${options.projectName}:build`,
|
|
255
|
+
spa: true,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
240
258
|
if (options.e2eTestRunner === 'cypress') {
|
|
241
259
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
242
260
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -254,7 +272,30 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
254
272
|
baseUrl: options.e2eWebServerAddress,
|
|
255
273
|
directory: 'src',
|
|
256
274
|
skipFormat: true,
|
|
275
|
+
webServerCommands: hasPlugin
|
|
276
|
+
? {
|
|
277
|
+
default: `nx run ${options.projectName}:${options.e2eWebServerTarget}`,
|
|
278
|
+
production: `nx run ${options.projectName}:preview`,
|
|
279
|
+
}
|
|
280
|
+
: undefined,
|
|
281
|
+
ciWebServerCommand: hasPlugin
|
|
282
|
+
? `nx run ${options.projectName}:${options.e2eCiWebServerTarget}`
|
|
283
|
+
: undefined,
|
|
284
|
+
ciBaseUrl: options.bundler === 'vite' ? options.e2eCiBaseUrl : undefined,
|
|
257
285
|
});
|
|
286
|
+
if (options.addPlugin ||
|
|
287
|
+
(0, devkit_1.readNxJson)(host).plugins?.find((p) => typeof p === 'string'
|
|
288
|
+
? p === '@nx/cypress/plugin'
|
|
289
|
+
: p.plugin === '@nx/cypress/plugin')) {
|
|
290
|
+
let buildTarget = '^build';
|
|
291
|
+
if (hasPlugin) {
|
|
292
|
+
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, buildPlugin, (0, devkit_1.joinPathFragments)(options.appProjectRoot, buildConfigFile));
|
|
293
|
+
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
294
|
+
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/cypress/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `cypress.config.ts`));
|
|
298
|
+
}
|
|
258
299
|
tasks.push(cypressTask);
|
|
259
300
|
}
|
|
260
301
|
else if (options.e2eTestRunner === 'playwright') {
|
|
@@ -275,10 +316,23 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
275
316
|
js: false,
|
|
276
317
|
linter: options.linter,
|
|
277
318
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
278
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.
|
|
279
|
-
webServerAddress: options.
|
|
319
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx run ${options.projectName}:${options.e2eCiWebServerTarget}`,
|
|
320
|
+
webServerAddress: options.e2eCiBaseUrl,
|
|
280
321
|
addPlugin: options.addPlugin,
|
|
281
322
|
});
|
|
323
|
+
if (options.addPlugin ||
|
|
324
|
+
(0, devkit_1.readNxJson)(host).plugins?.find((p) => typeof p === 'string'
|
|
325
|
+
? p === '@nx/playwright/plugin'
|
|
326
|
+
: p.plugin === '@nx/playwright/plugin')) {
|
|
327
|
+
let buildTarget = '^build';
|
|
328
|
+
if (hasPlugin) {
|
|
329
|
+
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, buildPlugin, (0, devkit_1.joinPathFragments)(options.appProjectRoot, buildConfigFile));
|
|
330
|
+
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
331
|
+
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/playwright/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `playwright.config.ts`));
|
|
335
|
+
}
|
|
282
336
|
tasks.push(playwrightTask);
|
|
283
337
|
}
|
|
284
338
|
if (options.unitTestRunner === 'jest') {
|
|
@@ -333,28 +387,35 @@ async function normalizeOptions(host, options) {
|
|
|
333
387
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
334
388
|
nxJson.useInferencePlugins !== false;
|
|
335
389
|
options.addPlugin ??= addPluginDefault;
|
|
390
|
+
let e2ePort = 4200;
|
|
336
391
|
let e2eWebServerTarget = 'serve';
|
|
392
|
+
let e2eCiWebServerTarget = options.bundler === 'vite' ? 'preview' : 'serve-static';
|
|
337
393
|
if (options.addPlugin) {
|
|
338
394
|
if (nxJson.plugins) {
|
|
339
395
|
for (const plugin of nxJson.plugins) {
|
|
340
396
|
if (options.bundler === 'vite' &&
|
|
341
397
|
typeof plugin === 'object' &&
|
|
342
|
-
plugin.plugin === '@nx/vite/plugin'
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
398
|
+
plugin.plugin === '@nx/vite/plugin') {
|
|
399
|
+
e2eCiWebServerTarget =
|
|
400
|
+
plugin.options?.previewTargetName ??
|
|
401
|
+
e2eCiWebServerTarget;
|
|
402
|
+
e2eWebServerTarget =
|
|
403
|
+
plugin.options?.serveTargetName ??
|
|
404
|
+
e2eWebServerTarget;
|
|
346
405
|
}
|
|
347
406
|
else if (options.bundler === 'webpack' &&
|
|
348
407
|
typeof plugin === 'object' &&
|
|
349
|
-
plugin.plugin === '@nx/webpack/plugin'
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
408
|
+
plugin.plugin === '@nx/webpack/plugin') {
|
|
409
|
+
e2eCiWebServerTarget =
|
|
410
|
+
plugin.options?.serveStaticTargetName ??
|
|
411
|
+
e2eCiWebServerTarget;
|
|
412
|
+
e2eWebServerTarget =
|
|
413
|
+
plugin.options?.serveTargetName ??
|
|
414
|
+
e2eWebServerTarget;
|
|
353
415
|
}
|
|
354
416
|
}
|
|
355
417
|
}
|
|
356
418
|
}
|
|
357
|
-
let e2ePort = 4200;
|
|
358
419
|
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
359
420
|
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
360
421
|
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
|
|
@@ -362,6 +423,9 @@ async function normalizeOptions(host, options) {
|
|
|
362
423
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
363
424
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
364
425
|
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
426
|
+
const e2eCiBaseUrl = options.bundler === 'vite'
|
|
427
|
+
? 'http://localhost:4300'
|
|
428
|
+
: `http://localhost:${e2ePort}`;
|
|
365
429
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
366
430
|
const parsedTags = options.tags
|
|
367
431
|
? options.tags.split(',').map((s) => s.trim())
|
|
@@ -383,6 +447,8 @@ async function normalizeOptions(host, options) {
|
|
|
383
447
|
e2eProjectName,
|
|
384
448
|
e2eWebServerAddress,
|
|
385
449
|
e2eWebServerTarget,
|
|
450
|
+
e2eCiWebServerTarget,
|
|
451
|
+
e2eCiBaseUrl,
|
|
386
452
|
e2ePort,
|
|
387
453
|
parsedTags,
|
|
388
454
|
};
|
|
@@ -20,6 +20,7 @@ async function normalizeOptions(tree, options) {
|
|
|
20
20
|
targetName: options.targetName || 'serve-static',
|
|
21
21
|
projectName: target.project,
|
|
22
22
|
spa: options.spa ?? true,
|
|
23
|
+
parsedBuildTarget: target.target,
|
|
23
24
|
};
|
|
24
25
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, target.project);
|
|
25
26
|
const buildTargetConfig = projectConfig?.targets?.[target.target];
|
|
@@ -69,6 +70,7 @@ function addStaticConfig(tree, opts) {
|
|
|
69
70
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.projectName);
|
|
70
71
|
const staticServeOptions = {
|
|
71
72
|
executor: '@nx/web:file-server',
|
|
73
|
+
dependsOn: [opts.parsedBuildTarget],
|
|
72
74
|
options: {
|
|
73
75
|
buildTarget: opts.buildTarget,
|
|
74
76
|
staticFilePath: opts.outputPath,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasVitePlugin = hasVitePlugin;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function hasVitePlugin(tree) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
+
? p === '@nx/vite/plugin'
|
|
9
|
+
: p.plugin === '@nx/vite/plugin');
|
|
10
|
+
}
|