@nx/web 16.8.0-beta.3 → 16.8.0-beta.5
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 +5 -7
- package/src/executors/file-server/file-server.impl.js +90 -99
- package/src/generators/application/application.js +247 -228
- package/src/generators/init/init.js +35 -38
- package/src/generators/static-serve/static-serve-configuration.js +11 -8
- package/src/migrations/update-13-0-0/remove-deprecated-options-13-0-0.js +21 -25
- package/src/migrations/update-13-0-0/remove-node-sass-13-0-0.js +12 -15
- package/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.js +10 -14
- package/src/migrations/update-13-3-0/rename-build-to-webpack.js +9 -13
- package/src/migrations/update-13-3-0/rename-package-to-rollup.js +9 -13
- package/src/migrations/update-13-8-0/add-postcss-config-option.js +11 -15
- package/src/migrations/update-14-1-7/rollup-format-backwards-compatibility.js +13 -14
- package/src/migrations/update-14-7-6/update-webpack-executor.js +16 -20
- package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
- package/src/migrations/update-15-0-0/update-rollup-executor.js +26 -30
- package/src/migrations/update-15-5-4/update-babel-preset.js +24 -28
- package/src/migrations/update-15-9-1/add-dropped-dependencies.js +24 -28
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.js +27 -31
- package/src/utils/wait-for-port-open.js +3 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.5",
|
|
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,19 +30,17 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nrwl/web": "16.8.0-beta.
|
|
34
|
-
"@nx/devkit": "16.8.0-beta.
|
|
35
|
-
"@nx/js": "16.8.0-beta.
|
|
33
|
+
"@nrwl/web": "16.8.0-beta.5",
|
|
34
|
+
"@nx/devkit": "16.8.0-beta.5",
|
|
35
|
+
"@nx/js": "16.8.0-beta.5",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
|
-
"chokidar": "^3.5.1",
|
|
38
37
|
"detect-port": "^1.5.1",
|
|
39
38
|
"http-server": "^14.1.0",
|
|
40
|
-
"ignore": "^5.0.4",
|
|
41
39
|
"tslib": "^2.3.0"
|
|
42
40
|
},
|
|
43
41
|
"publishConfig": {
|
|
44
42
|
"access": "public"
|
|
45
43
|
},
|
|
46
44
|
"type": "commonjs",
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
|
|
48
46
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const child_process_1 = require("child_process");
|
|
5
4
|
const chalk = require("chalk");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const ignore_1 = require("ignore");
|
|
8
6
|
const fs_1 = require("fs");
|
|
9
|
-
const chokidar_1 = require("chokidar");
|
|
10
7
|
const os_1 = require("os");
|
|
11
8
|
const path_1 = require("path");
|
|
12
9
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
13
10
|
const detectPort = require("detect-port");
|
|
11
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
14
12
|
// platform specific command name
|
|
15
13
|
const pmCmd = (0, os_1.platform)() === 'win32' ? `npx.cmd` : 'npx';
|
|
16
14
|
function getHttpServerArgs(options) {
|
|
@@ -75,111 +73,104 @@ function getBuildTargetOutputPath(options, context) {
|
|
|
75
73
|
}
|
|
76
74
|
return outputPath;
|
|
77
75
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cwd: root,
|
|
94
|
-
ignoreInitial: true,
|
|
95
|
-
});
|
|
96
|
-
watcher.on('all', (_event, path) => {
|
|
97
|
-
if (ignoredGlobs.ignores(path))
|
|
98
|
-
return;
|
|
99
|
-
changeHandler();
|
|
76
|
+
function createFileWatcher(project, changeHandler) {
|
|
77
|
+
return client_1.daemonClient.registerFileWatcher({
|
|
78
|
+
watchProjects: project ? [project] : 'all',
|
|
79
|
+
includeGlobalWorkspaceFiles: true,
|
|
80
|
+
includeDependentProjects: true,
|
|
81
|
+
}, async (error, { changedFiles }) => {
|
|
82
|
+
if (error === 'closed') {
|
|
83
|
+
throw new Error('Watch error: Daemon closed the connection');
|
|
84
|
+
}
|
|
85
|
+
else if (error) {
|
|
86
|
+
throw new Error(`Watch error: ${error?.message ?? 'Unknown'}`);
|
|
87
|
+
}
|
|
88
|
+
else if (changedFiles.length > 0) {
|
|
89
|
+
changeHandler();
|
|
90
|
+
}
|
|
100
91
|
});
|
|
101
|
-
return () => watcher.close();
|
|
102
92
|
}
|
|
103
|
-
function fileServerExecutor(options, context) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
running = false;
|
|
120
|
-
}
|
|
93
|
+
async function* fileServerExecutor(options, context) {
|
|
94
|
+
let running = false;
|
|
95
|
+
const run = () => {
|
|
96
|
+
if (!running) {
|
|
97
|
+
running = true;
|
|
98
|
+
try {
|
|
99
|
+
const args = getBuildTargetCommand(options);
|
|
100
|
+
(0, child_process_1.execFileSync)(pmCmd, args, {
|
|
101
|
+
stdio: [0, 1, 2],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
|
|
121
106
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
107
|
+
finally {
|
|
108
|
+
running = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
let disposeWatch;
|
|
113
|
+
if (options.watch) {
|
|
114
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
115
|
+
disposeWatch = await createFileWatcher(context.projectName, run);
|
|
116
|
+
}
|
|
117
|
+
// perform initial run
|
|
118
|
+
run();
|
|
119
|
+
const outputPath = getBuildTargetOutputPath(options, context);
|
|
120
|
+
if (options.spa) {
|
|
121
|
+
const src = (0, path_1.join)(outputPath, 'index.html');
|
|
122
|
+
const dst = (0, path_1.join)(outputPath, '404.html');
|
|
123
|
+
// See: https://github.com/http-party/http-server#magic-files
|
|
124
|
+
(0, fs_1.copyFileSync)(src, dst);
|
|
125
|
+
}
|
|
126
|
+
const args = getHttpServerArgs(options);
|
|
127
|
+
const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
|
|
128
|
+
const pathToHttpServerBin = packageJson.bin['http-server'];
|
|
129
|
+
const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
|
|
130
|
+
// detect port as close to when used to prevent port being used by another process
|
|
131
|
+
// when running in parallel
|
|
132
|
+
const port = await detectPort(options.port || 8080);
|
|
133
|
+
args.push(`-p=${port}`);
|
|
134
|
+
const serve = (0, child_process_1.fork)(pathToHttpServer, [outputPath, ...args], {
|
|
135
|
+
stdio: 'pipe',
|
|
136
|
+
cwd: context.root,
|
|
137
|
+
env: {
|
|
138
|
+
FORCE_COLOR: 'true',
|
|
139
|
+
...process.env,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const processExitListener = () => {
|
|
143
|
+
serve.kill();
|
|
144
|
+
if (disposeWatch) {
|
|
145
|
+
disposeWatch();
|
|
127
146
|
}
|
|
128
|
-
// perform initial run
|
|
129
|
-
run();
|
|
130
|
-
const outputPath = getBuildTargetOutputPath(options, context);
|
|
131
147
|
if (options.spa) {
|
|
132
|
-
|
|
133
|
-
const dst = (0, path_1.join)(outputPath, '404.html');
|
|
134
|
-
// See: https://github.com/http-party/http-server#magic-files
|
|
135
|
-
(0, fs_1.copyFileSync)(src, dst);
|
|
148
|
+
(0, fs_1.unlinkSync)((0, path_1.join)(outputPath, '404.html'));
|
|
136
149
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
(0, fs_1.unlinkSync)((0, path_1.join)(outputPath, '404.html'));
|
|
150
|
+
};
|
|
151
|
+
process.on('exit', processExitListener);
|
|
152
|
+
process.on('SIGTERM', processExitListener);
|
|
153
|
+
serve.stdout.on('data', (chunk) => {
|
|
154
|
+
if (chunk.toString().indexOf('GET') === -1) {
|
|
155
|
+
process.stdout.write(chunk);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
serve.stderr.on('data', (chunk) => {
|
|
159
|
+
process.stderr.write(chunk);
|
|
160
|
+
});
|
|
161
|
+
yield {
|
|
162
|
+
success: true,
|
|
163
|
+
baseUrl: `${options.ssl ? 'https' : 'http'}://${options.host}:${port}`,
|
|
164
|
+
};
|
|
165
|
+
return new Promise((res) => {
|
|
166
|
+
serve.on('exit', (code) => {
|
|
167
|
+
if (code == 0) {
|
|
168
|
+
res({ success: true });
|
|
157
169
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
process.on('SIGTERM', processExitListener);
|
|
161
|
-
serve.stdout.on('data', (chunk) => {
|
|
162
|
-
if (chunk.toString().indexOf('GET') === -1) {
|
|
163
|
-
process.stdout.write(chunk);
|
|
170
|
+
else {
|
|
171
|
+
res({ success: false });
|
|
164
172
|
}
|
|
165
173
|
});
|
|
166
|
-
serve.stderr.on('data', (chunk) => {
|
|
167
|
-
process.stderr.write(chunk);
|
|
168
|
-
});
|
|
169
|
-
yield yield tslib_1.__await({
|
|
170
|
-
success: true,
|
|
171
|
-
baseUrl: `${options.ssl ? 'https' : 'http'}://${options.host}:${port}`,
|
|
172
|
-
});
|
|
173
|
-
return yield tslib_1.__await(new Promise((res) => {
|
|
174
|
-
serve.on('exit', (code) => {
|
|
175
|
-
if (code == 0) {
|
|
176
|
-
res({ success: true });
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
res({ success: false });
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}));
|
|
183
174
|
});
|
|
184
175
|
}
|
|
185
176
|
exports.default = fileServerExecutor;
|