@nx/web 16.8.0-beta.4 → 16.8.0-beta.6

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": "16.8.0-beta.4",
3
+ "version": "16.8.0-beta.6",
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.4",
34
- "@nx/devkit": "16.8.0-beta.4",
35
- "@nx/js": "16.8.0-beta.4",
33
+ "@nrwl/web": "16.8.0-beta.6",
34
+ "@nx/devkit": "16.8.0-beta.6",
35
+ "@nx/js": "16.8.0-beta.6",
36
36
  "chalk": "^4.1.0",
37
37
  "detect-port": "^1.5.1",
38
38
  "http-server": "^14.1.0",
@@ -42,5 +42,5 @@
42
42
  "access": "public"
43
43
  },
44
44
  "type": "commonjs",
45
- "gitHead": "c9aad2dc8c2b34531cf61549bff872e68c481e4e"
45
+ "gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
46
46
  }
@@ -1,6 +1,5 @@
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");
@@ -79,99 +78,99 @@ function createFileWatcher(project, changeHandler) {
79
78
  watchProjects: project ? [project] : 'all',
80
79
  includeGlobalWorkspaceFiles: true,
81
80
  includeDependentProjects: true,
82
- }, (error, { changedFiles }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
83
- var _a;
81
+ }, async (error, { changedFiles }) => {
84
82
  if (error === 'closed') {
85
83
  throw new Error('Watch error: Daemon closed the connection');
86
84
  }
87
85
  else if (error) {
88
- throw new Error(`Watch error: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
86
+ throw new Error(`Watch error: ${error?.message ?? 'Unknown'}`);
89
87
  }
90
88
  else if (changedFiles.length > 0) {
91
89
  changeHandler();
92
90
  }
93
- }));
91
+ });
94
92
  }
95
- function fileServerExecutor(options, context) {
96
- return tslib_1.__asyncGenerator(this, arguments, function* fileServerExecutor_1() {
97
- let running = false;
98
- const run = () => {
99
- if (!running) {
100
- running = true;
101
- try {
102
- const args = getBuildTargetCommand(options);
103
- (0, child_process_1.execFileSync)(pmCmd, args, {
104
- stdio: [0, 1, 2],
105
- });
106
- }
107
- catch (_a) {
108
- throw new Error(`Build target failed: ${chalk.bold(options.buildTarget)}`);
109
- }
110
- finally {
111
- running = false;
112
- }
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)}`);
113
106
  }
114
- };
115
- let disposeWatch;
116
- if (options.watch) {
117
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
118
- disposeWatch = yield tslib_1.__await(createFileWatcher(context.projectName, run));
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();
119
146
  }
120
- // perform initial run
121
- run();
122
- const outputPath = getBuildTargetOutputPath(options, context);
123
147
  if (options.spa) {
124
- const src = (0, path_1.join)(outputPath, 'index.html');
125
- const dst = (0, path_1.join)(outputPath, '404.html');
126
- // See: https://github.com/http-party/http-server#magic-files
127
- (0, fs_1.copyFileSync)(src, dst);
148
+ (0, fs_1.unlinkSync)((0, path_1.join)(outputPath, '404.html'));
128
149
  }
129
- const args = getHttpServerArgs(options);
130
- const { path: pathToHttpServerPkgJson, packageJson } = (0, package_json_1.readModulePackageJson)('http-server', module.paths);
131
- const pathToHttpServerBin = packageJson.bin['http-server'];
132
- const pathToHttpServer = (0, path_1.resolve)(pathToHttpServerPkgJson.replace('package.json', ''), pathToHttpServerBin);
133
- // detect port as close to when used to prevent port being used by another process
134
- // when running in parallel
135
- const port = yield tslib_1.__await(detectPort(options.port || 8080));
136
- args.push(`-p=${port}`);
137
- const serve = (0, child_process_1.fork)(pathToHttpServer, [outputPath, ...args], {
138
- stdio: 'pipe',
139
- cwd: context.root,
140
- env: Object.assign({ FORCE_COLOR: 'true' }, process.env),
141
- });
142
- const processExitListener = () => {
143
- serve.kill();
144
- if (disposeWatch) {
145
- disposeWatch();
146
- }
147
- if (options.spa) {
148
- (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 });
149
169
  }
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);
170
+ else {
171
+ res({ success: false });
156
172
  }
157
173
  });
158
- serve.stderr.on('data', (chunk) => {
159
- process.stderr.write(chunk);
160
- });
161
- yield yield tslib_1.__await({
162
- success: true,
163
- baseUrl: `${options.ssl ? 'https' : 'http'}://${options.host}:${port}`,
164
- });
165
- return yield tslib_1.__await(new Promise((res) => {
166
- serve.on('exit', (code) => {
167
- if (code == 0) {
168
- res({ success: true });
169
- }
170
- else {
171
- res({ success: false });
172
- }
173
- });
174
- }));
175
174
  });
176
175
  }
177
176
  exports.default = fileServerExecutor;