@nx/web 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba
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/LICENSE +1 -1
- package/README.md +1 -1
- package/migrations.json +0 -24
- package/package.json +8 -7
- package/src/executors/file-server/file-server.impl.js +24 -19
- package/src/executors/file-server/schema.json +4 -3
- package/src/generators/application/application.js +46 -8
- package/src/generators/application/files/app-webpack/webpack.config.js__tmpl__ +2 -2
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +7 -2
- package/src/generators/static-serve/schema.json +5 -0
- package/src/generators/static-serve/static-serve-configuration.d.ts +3 -2
- package/src/generators/static-serve/static-serve-configuration.js +14 -5
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/add-babel-inputs.js +0 -9
- package/src/migrations/update-15-0-0/update-rollup-executor.d.ts +0 -2
- package/src/migrations/update-15-0-0/update-rollup-executor.js +0 -33
- package/src/migrations/update-15-5-4/update-babel-preset.d.ts +0 -2
- package/src/migrations/update-15-5-4/update-babel-preset.js +0 -32
- package/src/migrations/update-15-9-1/add-dropped-dependencies.d.ts +0 -2
- package/src/migrations/update-15-9-1/add-dropped-dependencies.js +0 -35
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
26
26
|
|
|
27
|
-
This package is a [Web plugin for Nx](https://nx.dev/
|
|
27
|
+
This package is a [Web plugin for Nx](https://nx.dev/nx-api/web).
|
|
28
28
|
|
|
29
29
|
## Getting Started
|
|
30
30
|
|
package/migrations.json
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"add-babel-inputs": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "15.0.0-beta.0",
|
|
6
|
-
"description": "Adds babel.config.json to the hash of all tasks",
|
|
7
|
-
"factory": "./src/migrations/update-15-0-0/add-babel-inputs"
|
|
8
|
-
},
|
|
9
|
-
"update-rollup-executor": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "15.0.0-beta.1",
|
|
12
|
-
"description": "Update usages of rollup executors to @nrwl/rollup",
|
|
13
|
-
"factory": "./src/migrations/update-15-0-0/update-rollup-executor"
|
|
14
|
-
},
|
|
15
|
-
"update-babel-preset": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "15.5.4-beta.0",
|
|
18
|
-
"description": "Update `@nrwl/web/babel` preset to `@nrwl/js/babel` for projects that have a .babelrc file.",
|
|
19
|
-
"factory": "./src/migrations/update-15-5-4/update-babel-preset"
|
|
20
|
-
},
|
|
21
|
-
"add-dropped-dependencies": {
|
|
22
|
-
"cli": "nx",
|
|
23
|
-
"version": "15.9.1",
|
|
24
|
-
"description": "Add @nrwl/linter, @nrwl/cypress, @nrwl/jest, @nrwl/rollup if they are used",
|
|
25
|
-
"factory": "./src/migrations/update-15-9-1/add-dropped-dependencies"
|
|
26
|
-
},
|
|
27
3
|
"update-16-0-0-add-nx-packages": {
|
|
28
4
|
"cli": "nx",
|
|
29
5
|
"version": "16.0.0-beta.1",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26482-ebe2dba",
|
|
4
4
|
"private": false,
|
|
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.",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/nrwl/nx.git",
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
"Web",
|
|
14
14
|
"Jest",
|
|
15
15
|
"Cypress",
|
|
16
|
-
"CLI"
|
|
16
|
+
"CLI",
|
|
17
|
+
"Front-end"
|
|
17
18
|
],
|
|
18
|
-
"main": "./index
|
|
19
|
+
"main": "./index",
|
|
19
20
|
"typings": "./index.d.ts",
|
|
20
21
|
"author": "Victor Savkin",
|
|
21
22
|
"license": "MIT",
|
|
@@ -34,9 +35,9 @@
|
|
|
34
35
|
"detect-port": "^1.5.1",
|
|
35
36
|
"http-server": "^14.1.0",
|
|
36
37
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/devkit": "0.0.0-pr-
|
|
38
|
-
"@nx/js": "0.0.0-pr-
|
|
39
|
-
"@nrwl/web": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-26482-ebe2dba",
|
|
39
|
+
"@nx/js": "0.0.0-pr-26482-ebe2dba",
|
|
40
|
+
"@nrwl/web": "0.0.0-pr-26482-ebe2dba"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|
|
@@ -13,32 +13,32 @@ const utils_1 = require("nx/src/tasks-runner/utils");
|
|
|
13
13
|
// platform specific command name
|
|
14
14
|
const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
15
15
|
function getHttpServerArgs(options) {
|
|
16
|
+
const { buildTarget, parallel, host, proxyUrl, ssl, sslCert, sslKey, proxyOptions, watch, spa, cacheSeconds, ...rest } = options;
|
|
16
17
|
const args = [`-c${options.cacheSeconds}`];
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
19
|
+
if (typeof value === 'boolean' && value) {
|
|
20
|
+
args.push(`--${key}`);
|
|
21
|
+
}
|
|
22
|
+
else if (typeof value === 'string') {
|
|
23
|
+
args.push(`--${key}=${value}`);
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
|
-
if (
|
|
21
|
-
args.push(`-a=${
|
|
26
|
+
if (host) {
|
|
27
|
+
args.push(`-a=${host}`);
|
|
22
28
|
}
|
|
23
|
-
if (
|
|
29
|
+
if (ssl) {
|
|
24
30
|
args.push(`-S`);
|
|
25
31
|
}
|
|
26
|
-
if (
|
|
27
|
-
args.push(`-C=${
|
|
28
|
-
}
|
|
29
|
-
if (options.sslKey) {
|
|
30
|
-
args.push(`-K=${options.sslKey}`);
|
|
32
|
+
if (sslCert) {
|
|
33
|
+
args.push(`-C=${sslCert}`);
|
|
31
34
|
}
|
|
32
|
-
if (
|
|
33
|
-
args.push(`-
|
|
35
|
+
if (sslKey) {
|
|
36
|
+
args.push(`-K=${sslKey}`);
|
|
34
37
|
}
|
|
35
|
-
if (
|
|
36
|
-
args.push(
|
|
38
|
+
if (proxyUrl) {
|
|
39
|
+
args.push(`-P=${proxyUrl}`);
|
|
37
40
|
}
|
|
38
|
-
if (
|
|
39
|
-
args.push('-b');
|
|
40
|
-
}
|
|
41
|
-
if (options.proxyOptions) {
|
|
41
|
+
if (proxyOptions) {
|
|
42
42
|
Object.keys(options.proxyOptions).forEach((key) => {
|
|
43
43
|
args.push(`--proxy-options.${key}=${options.proxyOptions[key]}`);
|
|
44
44
|
});
|
|
@@ -132,6 +132,8 @@ async function* fileServerExecutor(options, context) {
|
|
|
132
132
|
const args = getBuildTargetCommand(options, context);
|
|
133
133
|
(0, child_process_1.execFileSync)(pmCmd, args, {
|
|
134
134
|
stdio: [0, 1, 2],
|
|
135
|
+
shell: true,
|
|
136
|
+
windowsHide: true,
|
|
135
137
|
});
|
|
136
138
|
}
|
|
137
139
|
catch {
|
|
@@ -150,12 +152,16 @@ async function* fileServerExecutor(options, context) {
|
|
|
150
152
|
// perform initial run
|
|
151
153
|
run();
|
|
152
154
|
}
|
|
155
|
+
const port = await detectPort(options.port || 8080);
|
|
153
156
|
const outputPath = getBuildTargetOutputPath(options, context);
|
|
154
157
|
if (options.spa) {
|
|
155
158
|
const src = (0, path_1.join)(outputPath, 'index.html');
|
|
156
159
|
const dst = (0, path_1.join)(outputPath, '404.html');
|
|
157
160
|
// See: https://github.com/http-party/http-server#magic-files
|
|
158
161
|
(0, fs_1.copyFileSync)(src, dst);
|
|
162
|
+
// We also need to ensure the proxyUrl is set, otherwise the browser will continue to throw a 404 error
|
|
163
|
+
// This can cause unexpected behaviors and failures especially in automated test suites
|
|
164
|
+
options.proxyUrl ??= `http${options.ssl ? 's' : ''}://localhost:${port}?`;
|
|
159
165
|
}
|
|
160
166
|
const args = getHttpServerArgs(options);
|
|
161
167
|
const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
|
|
@@ -163,7 +169,6 @@ async function* fileServerExecutor(options, context) {
|
|
|
163
169
|
const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
|
|
164
170
|
// detect port as close to when used to prevent port being used by another process
|
|
165
171
|
// when running in parallel
|
|
166
|
-
const port = await detectPort(options.port || 8080);
|
|
167
172
|
args.push(`-p=${port}`);
|
|
168
173
|
const serve = (0, child_process_1.fork)(pathToHttpServer, [outputPath, ...args], {
|
|
169
174
|
stdio: 'pipe',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 2,
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"title": "File Server",
|
|
5
|
-
"description": "Serve a web application from a folder.",
|
|
5
|
+
"description": "Serve a web application from a folder. This executor is a wrapper around the [http-server](https://www.npmjs.com/package/http-server) package.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"cli": "nx",
|
|
8
8
|
"properties": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"proxyUrl": {
|
|
46
46
|
"type": "string",
|
|
47
|
-
"description": "URL to proxy unhandled requests to."
|
|
47
|
+
"description": "URL to proxy unhandled requests to. _Note: If the 'spa' flag is set to true, manually setting this value will override the catch-all redirect functionality from http-server which may lead to unexpected behavior._"
|
|
48
48
|
},
|
|
49
49
|
"proxyOptions": {
|
|
50
50
|
"type": "object",
|
|
@@ -94,5 +94,6 @@
|
|
|
94
94
|
"default": -1
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
-
"additionalProperties":
|
|
97
|
+
"additionalProperties": true,
|
|
98
|
+
"examplesFile": "../../../docs/file-server-examples.md"
|
|
98
99
|
}
|
|
@@ -49,6 +49,15 @@ function createApplicationFiles(tree, options) {
|
|
|
49
49
|
tree.delete((0, path_1.join)(options.appProjectRoot, './src/app/app.element.spec.ts'));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
|
|
53
|
+
return {
|
|
54
|
+
...json,
|
|
55
|
+
compilerOptions: {
|
|
56
|
+
...(json.compilerOptions || {}),
|
|
57
|
+
strict: options.strict,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
62
|
async function setupBundler(tree, options) {
|
|
54
63
|
const main = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/main.ts');
|
|
@@ -241,8 +250,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
241
250
|
const cypressTask = await configurationGenerator(host, {
|
|
242
251
|
...options,
|
|
243
252
|
project: options.e2eProjectName,
|
|
244
|
-
devServerTarget: `${options.projectName}
|
|
245
|
-
baseUrl:
|
|
253
|
+
devServerTarget: `${options.projectName}:${options.e2eWebServerTarget}`,
|
|
254
|
+
baseUrl: options.e2eWebServerAddress,
|
|
246
255
|
directory: 'src',
|
|
247
256
|
skipFormat: true,
|
|
248
257
|
});
|
|
@@ -255,6 +264,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
255
264
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
256
265
|
projectType: 'application',
|
|
257
266
|
targets: {},
|
|
267
|
+
tags: [],
|
|
258
268
|
implicitDependencies: [options.projectName],
|
|
259
269
|
});
|
|
260
270
|
const playwrightTask = await playwrightConfigGenerator(host, {
|
|
@@ -265,8 +275,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
265
275
|
js: false,
|
|
266
276
|
linter: options.linter,
|
|
267
277
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
268
|
-
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx
|
|
269
|
-
webServerAddress:
|
|
278
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx ${options.e2eWebServerTarget} ${options.name}`,
|
|
279
|
+
webServerAddress: options.e2eWebServerAddress,
|
|
270
280
|
addPlugin: options.addPlugin,
|
|
271
281
|
});
|
|
272
282
|
tasks.push(playwrightTask);
|
|
@@ -324,19 +334,43 @@ async function normalizeOptions(host, options) {
|
|
|
324
334
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
325
335
|
nxJson.useInferencePlugins !== false;
|
|
326
336
|
options.addPlugin ??= addPluginDefault;
|
|
337
|
+
let e2eWebServerTarget = 'serve';
|
|
338
|
+
if (options.addPlugin) {
|
|
339
|
+
if (nxJson.plugins) {
|
|
340
|
+
for (const plugin of nxJson.plugins) {
|
|
341
|
+
if (options.bundler === 'vite' &&
|
|
342
|
+
typeof plugin === 'object' &&
|
|
343
|
+
plugin.plugin === '@nx/vite/plugin' &&
|
|
344
|
+
plugin.options.serveTargetName) {
|
|
345
|
+
e2eWebServerTarget = plugin.options
|
|
346
|
+
.serveTargetName;
|
|
347
|
+
}
|
|
348
|
+
else if (options.bundler === 'webpack' &&
|
|
349
|
+
typeof plugin === 'object' &&
|
|
350
|
+
plugin.plugin === '@nx/webpack/plugin' &&
|
|
351
|
+
plugin.options.serveTargetName) {
|
|
352
|
+
e2eWebServerTarget = plugin.options
|
|
353
|
+
.serveTargetName;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
let e2ePort = 4200;
|
|
359
|
+
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
360
|
+
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
361
|
+
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
|
|
362
|
+
}
|
|
327
363
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
328
364
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
365
|
+
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
329
366
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
330
367
|
const parsedTags = options.tags
|
|
331
368
|
? options.tags.split(',').map((s) => s.trim())
|
|
332
369
|
: [];
|
|
333
|
-
if (options.bundler === 'vite' && options.unitTestRunner !== 'none') {
|
|
334
|
-
options.unitTestRunner = 'vitest';
|
|
335
|
-
}
|
|
336
370
|
options.style = options.style || 'css';
|
|
337
371
|
options.linter = options.linter || 'eslint';
|
|
338
372
|
options.unitTestRunner = options.unitTestRunner || 'jest';
|
|
339
|
-
options.e2eTestRunner = options.e2eTestRunner || '
|
|
373
|
+
options.e2eTestRunner = options.e2eTestRunner || 'playwright';
|
|
340
374
|
return {
|
|
341
375
|
...options,
|
|
342
376
|
prefix: options.prefix ?? npmScope ?? 'app',
|
|
@@ -344,9 +378,13 @@ async function normalizeOptions(host, options) {
|
|
|
344
378
|
compiler: options.compiler ?? 'babel',
|
|
345
379
|
bundler: options.bundler ?? 'webpack',
|
|
346
380
|
projectName: appProjectName,
|
|
381
|
+
strict: options.strict ?? true,
|
|
347
382
|
appProjectRoot,
|
|
348
383
|
e2eProjectRoot,
|
|
349
384
|
e2eProjectName,
|
|
385
|
+
e2eWebServerAddress,
|
|
386
|
+
e2eWebServerTarget,
|
|
387
|
+
e2ePort,
|
|
350
388
|
parsedTags,
|
|
351
389
|
};
|
|
352
390
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% if (webpackPluginOptions) { %>
|
|
2
|
-
const {
|
|
2
|
+
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
|
|
3
3
|
const { join } = require('path');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
|
10
10
|
port: 4200
|
|
11
11
|
},
|
|
12
12
|
plugins: [
|
|
13
|
-
new
|
|
13
|
+
new NxAppWebpackPlugin({
|
|
14
14
|
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
|
|
15
15
|
compiler: '<%= webpackPluginOptions.compiler %>',
|
|
16
16
|
main: '<%= webpackPluginOptions.main %>',
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
},
|
|
88
88
|
"e2eTestRunner": {
|
|
89
89
|
"type": "string",
|
|
90
|
-
"enum": ["
|
|
90
|
+
"enum": ["playwright", "cypress", "none"],
|
|
91
91
|
"x-prompt": "Which E2E test runner would you like to use?",
|
|
92
92
|
"description": "Test runner to use for end to end (e2e) tests",
|
|
93
|
-
"default": "
|
|
93
|
+
"default": "playwright"
|
|
94
94
|
},
|
|
95
95
|
"tags": {
|
|
96
96
|
"type": "string",
|
|
@@ -101,6 +101,11 @@
|
|
|
101
101
|
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
102
102
|
"default": false
|
|
103
103
|
},
|
|
104
|
+
"strict": {
|
|
105
|
+
"type": "boolean",
|
|
106
|
+
"description": "Creates an application with strict mode and strict type checking.",
|
|
107
|
+
"default": true
|
|
108
|
+
},
|
|
104
109
|
"standaloneConfig": {
|
|
105
110
|
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside workspace.json",
|
|
106
111
|
"type": "boolean",
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "Name of the serve target to add. Defaults to 'serve-static'.",
|
|
20
20
|
"default": "serve-static"
|
|
21
|
+
},
|
|
22
|
+
"spa": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "Whether to set the 'spa' flag on the generated target.",
|
|
25
|
+
"default": true
|
|
21
26
|
}
|
|
22
27
|
},
|
|
23
28
|
"required": ["buildTarget"]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
2
|
interface WebStaticServeSchema {
|
|
3
3
|
buildTarget: string;
|
|
4
4
|
outputPath?: string;
|
|
5
5
|
targetName?: string;
|
|
6
|
+
spa?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare function webStaticServeGenerator(tree: Tree, options: WebStaticServeSchema): void
|
|
8
|
+
export declare function webStaticServeGenerator(tree: Tree, options: WebStaticServeSchema): Promise<void>;
|
|
8
9
|
export default webStaticServeGenerator;
|
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webStaticServeGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function webStaticServeGenerator(tree, options) {
|
|
6
|
-
const opts = normalizeOptions(tree, options);
|
|
5
|
+
async function webStaticServeGenerator(tree, options) {
|
|
6
|
+
const opts = await normalizeOptions(tree, options);
|
|
7
7
|
addStaticConfig(tree, opts);
|
|
8
8
|
}
|
|
9
9
|
exports.webStaticServeGenerator = webStaticServeGenerator;
|
|
10
|
-
function normalizeOptions(tree, options) {
|
|
11
|
-
|
|
10
|
+
async function normalizeOptions(tree, options) {
|
|
11
|
+
let projectGraph;
|
|
12
|
+
try {
|
|
13
|
+
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
17
|
+
}
|
|
18
|
+
const target = (0, devkit_1.parseTargetString)(options.buildTarget, projectGraph);
|
|
12
19
|
const opts = {
|
|
13
20
|
...options,
|
|
14
21
|
targetName: options.targetName || 'serve-static',
|
|
15
22
|
projectName: target.project,
|
|
23
|
+
spa: options.spa ?? true,
|
|
16
24
|
};
|
|
17
25
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, target.project);
|
|
18
26
|
const buildTargetConfig = projectConfig?.targets?.[target.target];
|
|
@@ -27,7 +35,7 @@ Optionally, you can provide a different name with the --target-name option other
|
|
|
27
35
|
}
|
|
28
36
|
// NOTE: @nx/web:file-server only looks for the outputPath option
|
|
29
37
|
if (!buildTargetConfig.options?.outputPath && !opts.outputPath) {
|
|
30
|
-
// attempt to find the
|
|
38
|
+
// attempt to find the suitable path from the outputs
|
|
31
39
|
let maybeOutputValue;
|
|
32
40
|
for (const o of buildTargetConfig?.outputs || []) {
|
|
33
41
|
const isInterpolatedOutput = o.trim().startsWith('{options.');
|
|
@@ -65,6 +73,7 @@ function addStaticConfig(tree, opts) {
|
|
|
65
73
|
options: {
|
|
66
74
|
buildTarget: opts.buildTarget,
|
|
67
75
|
staticFilePath: opts.outputPath,
|
|
76
|
+
spa: opts.spa,
|
|
68
77
|
},
|
|
69
78
|
};
|
|
70
79
|
projectConfig.targets[opts.targetName] = staticServeOptions;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
|
|
5
|
-
async function default_1(tree) {
|
|
6
|
-
(0, add_babel_inputs_1.addBabelInputs)(tree);
|
|
7
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
8
|
-
}
|
|
9
|
-
exports.default = default_1;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
async function update(host) {
|
|
5
|
-
const projects = (0, devkit_1.getProjects)(host);
|
|
6
|
-
for (const [name, config] of projects.entries()) {
|
|
7
|
-
let updated = false;
|
|
8
|
-
if (config?.targets?.build?.executor === '@nrwl/web:rollup') {
|
|
9
|
-
config.targets.build.executor = '@nrwl/rollup:rollup';
|
|
10
|
-
updated = true;
|
|
11
|
-
}
|
|
12
|
-
if (config?.targets?.build?.options?.formats?.includes('umd')) {
|
|
13
|
-
config.targets.build.options.formats =
|
|
14
|
-
config.targets.build.options.formats.reduce((acc, x) => {
|
|
15
|
-
const format = x === 'umd' ? 'cjs' : x;
|
|
16
|
-
if (format === 'cjs') {
|
|
17
|
-
if (!acc.includes('cjs'))
|
|
18
|
-
acc.push(format);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
acc.push(format);
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}, []);
|
|
25
|
-
updated = true;
|
|
26
|
-
}
|
|
27
|
-
if (updated) {
|
|
28
|
-
(0, devkit_1.updateProjectConfiguration)(host, name, config);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
await (0, devkit_1.formatFiles)(host);
|
|
32
|
-
}
|
|
33
|
-
exports.default = update;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const versions_1 = require("../../utils/versions");
|
|
5
|
-
/* Updates @nrwl/web/babel to @nrwl/js/babel because web package is no longer necessary to use webpack/rollup + babel. */
|
|
6
|
-
async function update(tree) {
|
|
7
|
-
// Add `@nrwl/js` in case it was missing before.
|
|
8
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
9
|
-
'@nrwl/js': versions_1.nxVersion,
|
|
10
|
-
});
|
|
11
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
12
|
-
projects.forEach((config, name) => {
|
|
13
|
-
const babelrcPath = (0, devkit_1.joinPathFragments)(config.root, '.babelrc');
|
|
14
|
-
if (!tree.exists(babelrcPath))
|
|
15
|
-
return;
|
|
16
|
-
const babelrc = (0, devkit_1.readJson)(tree, babelrcPath);
|
|
17
|
-
const idx = babelrc?.presets?.findIndex((p) => typeof p === 'string'
|
|
18
|
-
? p === '@nrwl/web/babel'
|
|
19
|
-
: p[0] === '@nrwl/web/babel');
|
|
20
|
-
if (idx === -1)
|
|
21
|
-
return;
|
|
22
|
-
const preset = babelrc.presets[idx];
|
|
23
|
-
if (typeof preset === 'string') {
|
|
24
|
-
babelrc.presets.splice(idx, 1, '@nrwl/js/babel');
|
|
25
|
-
}
|
|
26
|
-
else if (Array.isArray(preset)) {
|
|
27
|
-
babelrc.presets.splice(idx, 1, ['@nrwl/js/babel', preset[1]]);
|
|
28
|
-
}
|
|
29
|
-
(0, devkit_1.writeJson)(tree, babelrcPath, babelrc);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
exports.default = update;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
async function addDroppedDependencies(tree) {
|
|
5
|
-
const devDependencies = {};
|
|
6
|
-
const droppedDependencies = [
|
|
7
|
-
'@nrwl/linter',
|
|
8
|
-
'@nrwl/cypress',
|
|
9
|
-
'@nrwl/jest',
|
|
10
|
-
'@nrwl/rollup',
|
|
11
|
-
];
|
|
12
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
13
|
-
for (const [_, projectConfiguration] of projects) {
|
|
14
|
-
for (const [_, targetConfiguration] of Object.entries(projectConfiguration.targets ?? {})) {
|
|
15
|
-
for (const droppedDependency of droppedDependencies) {
|
|
16
|
-
if (targetConfiguration?.['executor']?.startsWith(droppedDependency + ':')) {
|
|
17
|
-
devDependencies[droppedDependency] = devkit_1.NX_VERSION;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
23
|
-
for (const [_, targetConfiguration] of Object.entries(nxJson?.targetDefaults ?? {})) {
|
|
24
|
-
for (const droppedDependency of droppedDependencies) {
|
|
25
|
-
if (targetConfiguration?.['executor']?.startsWith(droppedDependency + ':')) {
|
|
26
|
-
devDependencies[droppedDependency] = devkit_1.NX_VERSION;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (Object.keys(devDependencies).length > 0) {
|
|
31
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
|
|
32
|
-
}
|
|
33
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
-
}
|
|
35
|
-
exports.default = addDroppedDependencies;
|