parcel 2.8.4-nightly.0 → 2.9.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.
Files changed (3) hide show
  1. package/lib/cli.js +30 -117
  2. package/package.json +14 -14
  3. package/src/cli.js +1 -1
package/lib/cli.js CHANGED
@@ -2,114 +2,82 @@
2
2
 
3
3
  function _core() {
4
4
  const data = require("@parcel/core");
5
-
6
5
  _core = function () {
7
6
  return data;
8
7
  };
9
-
10
8
  return data;
11
9
  }
12
-
13
10
  function _fs() {
14
11
  const data = require("@parcel/fs");
15
-
16
12
  _fs = function () {
17
13
  return data;
18
14
  };
19
-
20
15
  return data;
21
16
  }
22
-
23
17
  function _diagnostic() {
24
18
  const data = _interopRequireDefault(require("@parcel/diagnostic"));
25
-
26
19
  _diagnostic = function () {
27
20
  return data;
28
21
  };
29
-
30
22
  return data;
31
23
  }
32
-
33
24
  function _utils() {
34
25
  const data = require("@parcel/utils");
35
-
36
26
  _utils = function () {
37
27
  return data;
38
28
  };
39
-
40
29
  return data;
41
30
  }
42
-
43
31
  function _events() {
44
32
  const data = require("@parcel/events");
45
-
46
33
  _events = function () {
47
34
  return data;
48
35
  };
49
-
50
36
  return data;
51
37
  }
52
-
53
38
  function _logger() {
54
39
  const data = require("@parcel/logger");
55
-
56
40
  _logger = function () {
57
41
  return data;
58
42
  };
59
-
60
43
  return data;
61
44
  }
62
-
63
45
  function _chalk() {
64
46
  const data = _interopRequireDefault(require("chalk"));
65
-
66
47
  _chalk = function () {
67
48
  return data;
68
49
  };
69
-
70
50
  return data;
71
51
  }
72
-
73
52
  function _commander() {
74
53
  const data = _interopRequireDefault(require("commander"));
75
-
76
54
  _commander = function () {
77
55
  return data;
78
56
  };
79
-
80
57
  return data;
81
58
  }
82
-
83
59
  function _path() {
84
60
  const data = _interopRequireDefault(require("path"));
85
-
86
61
  _path = function () {
87
62
  return data;
88
63
  };
89
-
90
64
  return data;
91
65
  }
92
-
93
66
  function _getPort() {
94
67
  const data = _interopRequireDefault(require("get-port"));
95
-
96
68
  _getPort = function () {
97
69
  return data;
98
70
  };
99
-
100
71
  return data;
101
72
  }
102
-
103
73
  var _package = require("../package.json");
104
-
105
74
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75
+ const program = new (_commander().default.Command)();
106
76
 
107
- const program = new (_commander().default.Command)(); // Exit codes in response to signals are traditionally
77
+ // Exit codes in response to signals are traditionally
108
78
  // 128 + signal value
109
79
  // https://tldp.org/LDP/abs/html/exitcodes.html
110
-
111
80
  const SIGINT_EXIT_CODE = 130;
112
-
113
81
  async function logUncaughtError(e) {
114
82
  if (e instanceof _diagnostic().default) {
115
83
  for (let diagnostic of e.diagnostics) {
@@ -120,37 +88,29 @@ async function logUncaughtError(e) {
120
88
  hints,
121
89
  documentation
122
90
  } = await (0, _utils().prettyDiagnostic)(diagnostic);
123
-
124
91
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.red(message));
125
-
126
92
  if (codeframe || stack) {
127
93
  _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
128
94
  }
129
-
130
95
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
131
-
132
96
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(stack);
133
-
134
97
  if ((stack || codeframe) && hints.length > 0) {
135
98
  _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
136
99
  }
137
-
138
100
  for (let h of hints) {
139
101
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.blue(h));
140
102
  }
141
-
142
103
  if (documentation) {
143
104
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.magenta.bold(documentation));
144
105
  }
145
106
  }
146
107
  } else {
147
108
  _logger().INTERNAL_ORIGINAL_CONSOLE.error(e);
148
- } // A hack to definitely ensure we logged the uncaught exception
149
-
109
+ }
150
110
 
111
+ // A hack to definitely ensure we logged the uncaught exception
151
112
  await new Promise(resolve => setTimeout(resolve, 100));
152
113
  }
153
-
154
114
  const handleUncaughtException = async exception => {
155
115
  try {
156
116
  await logUncaughtError(exception);
@@ -158,13 +118,13 @@ const handleUncaughtException = async exception => {
158
118
  console.error(exception);
159
119
  console.error(err);
160
120
  }
161
-
162
121
  process.exit(1);
163
122
  };
164
-
165
123
  process.on('unhandledRejection', handleUncaughtException);
166
124
  program.storeOptionsAsProperties();
167
- program.version(_package.version); // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
125
+ program.version(_package.version);
126
+
127
+ // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
168
128
  // --no-content-hash, --experimental-scope-hoisting, --detailed-report
169
129
 
170
130
  const commonOptions = {
@@ -195,11 +155,9 @@ var hmrOptions = {
195
155
  '--hmr-port <port>': ['hot module replacement port', process.env.HMR_PORT],
196
156
  '--hmr-host <host>': ['hot module replacement host', process.env.HMR_HOST]
197
157
  };
198
-
199
158
  function applyOptions(cmd, options) {
200
159
  for (let opt in options) {
201
160
  const option = options[opt];
202
-
203
161
  if (option instanceof _commander().default.Option) {
204
162
  cmd.addOption(option);
205
163
  } else {
@@ -207,7 +165,6 @@ function applyOptions(cmd, options) {
207
165
  }
208
166
  }
209
167
  }
210
-
211
168
  let serve = program.command('serve [input...]').description('starts a development server').option('--public-url <url>', 'the path prefix for absolute urls').option('--open [browser]', 'automatically open in specified browser, defaults to default browser').option('--watch-for-stdin', 'exit when stdin closes').option('--lazy', 'Build async bundles on demand, when requested in the browser').action(runCommand);
212
169
  applyOptions(serve, hmrOptions);
213
170
  applyOptions(serve, commonOptions);
@@ -222,45 +179,36 @@ program.command('help [command]').description('display help information for a co
222
179
  });
223
180
  program.on('--help', function () {
224
181
  _logger().INTERNAL_ORIGINAL_CONSOLE.log('');
225
-
226
182
  _logger().INTERNAL_ORIGINAL_CONSOLE.log(' Run `' + _chalk().default.bold('parcel help <command>') + '` for more information on specific commands');
227
-
228
183
  _logger().INTERNAL_ORIGINAL_CONSOLE.log('');
229
- }); // Override to output option description if argument was missing
230
- // $FlowFixMe[prop-missing]
184
+ });
231
185
 
186
+ // Override to output option description if argument was missing
187
+ // $FlowFixMe[prop-missing]
232
188
  _commander().default.Command.prototype.optionMissingArgument = function (option) {
233
189
  _logger().INTERNAL_ORIGINAL_CONSOLE.error("error: option `%s' argument missing", option.flags);
234
-
235
190
  _logger().INTERNAL_ORIGINAL_CONSOLE.log(program.createHelp().optionDescription(option));
236
-
237
191
  process.exit(1);
238
- }; // Make serve the default command except for --help
239
-
192
+ };
240
193
 
194
+ // Make serve the default command except for --help
241
195
  var args = process.argv;
242
196
  if (args[2] === '--help' || args[2] === '-h') args[2] = 'help';
243
-
244
197
  if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
245
198
  args.splice(2, 0, 'serve');
246
199
  }
247
-
248
200
  program.parse(args);
249
-
250
201
  function runCommand(...args) {
251
202
  run(...args).catch(handleUncaughtException);
252
203
  }
253
-
254
- async function run(entries, _opts, // using pre v7 Commander options as properties
204
+ async function run(entries, _opts,
205
+ // using pre v7 Commander options as properties
255
206
  command) {
256
207
  if (entries.length === 0) {
257
208
  entries = ['.'];
258
209
  }
259
-
260
210
  entries = entries.map(entry => _path().default.resolve(entry));
261
-
262
211
  let Parcel = require('@parcel/core').default;
263
-
264
212
  let fs = new (_fs().NodeFS)();
265
213
  let options = await normalizeOptions(command, fs);
266
214
  let parcel = new Parcel({
@@ -269,48 +217,38 @@ command) {
269
217
  defaultConfig: require.resolve('@parcel/config-default', {
270
218
  paths: [fs.cwd(), __dirname]
271
219
  }),
272
- shouldPatchConsole: true,
220
+ shouldPatchConsole: false,
273
221
  ...options
274
222
  });
275
223
  let disposable = new (_events().Disposable)();
276
224
  let unsubscribe;
277
225
  let isExiting;
278
-
279
226
  async function exit(exitCode = 0) {
280
227
  if (isExiting) {
281
228
  return;
282
229
  }
283
-
284
230
  isExiting = true;
285
-
286
231
  if (unsubscribe != null) {
287
232
  await unsubscribe();
288
233
  } else if (parcel.isProfiling) {
289
234
  await parcel.stopProfiling();
290
235
  }
291
-
292
236
  if (process.stdin.isTTY && process.stdin.isRaw) {
293
237
  // $FlowFixMe
294
238
  process.stdin.setRawMode(false);
295
239
  }
296
-
297
240
  disposable.dispose();
298
241
  process.exit(exitCode);
299
242
  }
300
-
301
243
  const isWatching = command.name() === 'watch' || command.name() === 'serve';
302
-
303
244
  if (process.stdin.isTTY) {
304
245
  // $FlowFixMe
305
246
  process.stdin.setRawMode(true);
306
-
307
247
  require('readline').emitKeypressEvents(process.stdin);
308
-
309
248
  let stream = process.stdin.on('keypress', async (char, key) => {
310
249
  if (!key.ctrl) {
311
250
  return;
312
251
  }
313
-
314
252
  switch (key.name) {
315
253
  case 'c':
316
254
  // Detect the ctrl+c key, and gracefully exit after writing the asset graph to the cache.
@@ -322,18 +260,17 @@ command) {
322
260
  // We don't use the SIGINT event for this because when run inside yarn, the parent
323
261
  // yarn process ends before Parcel and it appears that Parcel has ended while it may still
324
262
  // be cleaning up. Handling events from stdin prevents this impression.
263
+
325
264
  // Enqueue a busy message to be shown if Parcel doesn't shut down
326
265
  // within the timeout.
327
- setTimeout(() => _logger().INTERNAL_ORIGINAL_CONSOLE.log(_chalk().default.bold.yellowBright('Parcel is shutting down...')), 500); // When watching, a 0 success code is acceptable when Parcel is interrupted with ctrl-c.
266
+ setTimeout(() => _logger().INTERNAL_ORIGINAL_CONSOLE.log(_chalk().default.bold.yellowBright('Parcel is shutting down...')), 500);
267
+ // When watching, a 0 success code is acceptable when Parcel is interrupted with ctrl-c.
328
268
  // When building, fail with a code as if we received a SIGINT.
329
-
330
269
  await exit(isWatching ? 0 : SIGINT_EXIT_CODE);
331
270
  break;
332
-
333
271
  case 'e':
334
272
  await (parcel.isProfiling ? parcel.stopProfiling() : parcel.startProfiling());
335
273
  break;
336
-
337
274
  case 'y':
338
275
  await parcel.takeHeapSnapshot();
339
276
  break;
@@ -343,7 +280,6 @@ command) {
343
280
  stream.destroy();
344
281
  });
345
282
  }
346
-
347
283
  if (isWatching) {
348
284
  ({
349
285
  unsubscribe
@@ -352,22 +288,19 @@ command) {
352
288
  throw err;
353
289
  }
354
290
  }));
355
-
356
291
  if (command.open && options.serveOptions) {
357
292
  await (0, _utils().openInBrowser)(`${options.serveOptions.https ? 'https' : 'http'}://${options.serveOptions.host || 'localhost'}:${options.serveOptions.port}`, command.open);
358
293
  }
359
-
360
294
  if (command.watchForStdin) {
361
295
  process.stdin.on('end', async () => {
362
296
  _logger().INTERNAL_ORIGINAL_CONSOLE.log('STDIN closed, ending');
363
-
364
297
  await exit();
365
298
  });
366
299
  process.stdin.resume();
367
- } // In non-tty cases, respond to SIGINT by cleaning up. Since we're watching,
368
- // a 0 success code is acceptable.
369
-
300
+ }
370
301
 
302
+ // In non-tty cases, respond to SIGINT by cleaning up. Since we're watching,
303
+ // a 0 success code is acceptable.
371
304
  process.on('SIGINT', exit);
372
305
  process.on('SIGTERM', exit);
373
306
  } else {
@@ -379,67 +312,56 @@ command) {
379
312
  if (!(err instanceof _core().BuildError)) {
380
313
  await logUncaughtError(err);
381
314
  }
382
-
383
315
  await exit(1);
384
316
  }
385
-
386
317
  await exit();
387
318
  }
388
319
  }
389
-
390
320
  function parsePort(portValue) {
391
- let parsedPort = Number(portValue); // Throw an error if port value is invalid...
321
+ let parsedPort = Number(portValue);
392
322
 
323
+ // Throw an error if port value is invalid...
393
324
  if (!Number.isInteger(parsedPort)) {
394
325
  throw new Error(`Port ${portValue} is not a valid integer.`);
395
326
  }
396
-
397
327
  return parsedPort;
398
328
  }
399
-
400
329
  function parseOptionInt(value) {
401
330
  const parsedValue = parseInt(value, 10);
402
-
403
331
  if (isNaN(parsedValue)) {
404
332
  throw new (_commander().default.InvalidOptionArgumentError)('Must be an integer.');
405
333
  }
406
-
407
334
  return parsedValue;
408
335
  }
409
-
410
336
  async function normalizeOptions(command, inputFS) {
411
337
  var _command$autoinstall, _command$sourceMaps;
412
-
413
338
  let nodeEnv;
414
-
415
339
  if (command.name() === 'build') {
416
- nodeEnv = process.env.NODE_ENV || 'production'; // Autoinstall unless explicitly disabled or we detect a CI environment.
417
-
340
+ nodeEnv = process.env.NODE_ENV || 'production';
341
+ // Autoinstall unless explicitly disabled or we detect a CI environment.
418
342
  command.autoinstall = !(command.autoinstall === false || process.env.CI);
419
343
  } else {
420
344
  nodeEnv = process.env.NODE_ENV || 'development';
421
- } // Set process.env.NODE_ENV to a default if undefined so that it is
422
- // available in JS configs and plugins.
423
-
345
+ }
424
346
 
347
+ // Set process.env.NODE_ENV to a default if undefined so that it is
348
+ // available in JS configs and plugins.
425
349
  process.env.NODE_ENV = nodeEnv;
426
350
  let https = !!command.https;
427
-
428
351
  if (command.cert && command.key) {
429
352
  https = {
430
353
  cert: command.cert,
431
354
  key: command.key
432
355
  };
433
356
  }
434
-
435
357
  let serveOptions = false;
436
358
  let {
437
359
  host
438
- } = command; // Ensure port is valid and available
360
+ } = command;
439
361
 
362
+ // Ensure port is valid and available
440
363
  let port = parsePort(command.port || '1234');
441
364
  let originalPort = port;
442
-
443
365
  if (command.name() === 'serve' || command.hmr) {
444
366
  try {
445
367
  port = await (0, _getPort().default)({
@@ -455,10 +377,8 @@ async function normalizeOptions(command, inputFS) {
455
377
  }
456
378
  });
457
379
  }
458
-
459
380
  if (port !== originalPort) {
460
381
  let errorMessage = `Port "${originalPort}" could not be used`;
461
-
462
382
  if (command.port != null) {
463
383
  // Throw the error if the user defined a custom port
464
384
  throw new Error(errorMessage);
@@ -468,7 +388,6 @@ async function normalizeOptions(command, inputFS) {
468
388
  }
469
389
  }
470
390
  }
471
-
472
391
  if (command.name() === 'serve') {
473
392
  let {
474
393
  publicUrl
@@ -480,9 +399,7 @@ async function normalizeOptions(command, inputFS) {
480
399
  publicUrl
481
400
  };
482
401
  }
483
-
484
402
  let hmrOptions = null;
485
-
486
403
  if (command.name() !== 'build' && command.hmr !== false) {
487
404
  let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port;
488
405
  let hmrhost = command.hmrHost ? command.hmrHost : host;
@@ -491,11 +408,9 @@ async function normalizeOptions(command, inputFS) {
491
408
  host: hmrhost
492
409
  };
493
410
  }
494
-
495
411
  if (command.detailedReport === true) {
496
412
  command.detailedReport = '10';
497
413
  }
498
-
499
414
  let additionalReporters = [{
500
415
  packageName: '@parcel/reporter-cli',
501
416
  resolveFrom: __filename
@@ -503,14 +418,12 @@ async function normalizeOptions(command, inputFS) {
503
418
  packageName,
504
419
  resolveFrom: _path().default.join(inputFS.cwd(), 'index')
505
420
  }))];
506
-
507
421
  if (command.trace) {
508
422
  additionalReporters.unshift({
509
423
  packageName: '@parcel/reporter-tracer',
510
424
  resolveFrom: __filename
511
425
  });
512
426
  }
513
-
514
427
  let mode = command.name() === 'build' ? 'production' : 'development';
515
428
  return {
516
429
  shouldDisableCache: command.cache === false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parcel",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,24 +21,24 @@
21
21
  "node": ">= 12.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@parcel/config-default": "2.8.4-nightly.0+7b79c6d",
25
- "@parcel/core": "2.8.4-nightly.0+7b79c6d",
26
- "@parcel/diagnostic": "2.8.4-nightly.0+7b79c6d",
27
- "@parcel/events": "2.8.4-nightly.0+7b79c6d",
28
- "@parcel/fs": "2.8.4-nightly.0+7b79c6d",
29
- "@parcel/logger": "2.8.4-nightly.0+7b79c6d",
30
- "@parcel/package-manager": "2.8.4-nightly.0+7b79c6d",
31
- "@parcel/reporter-cli": "2.8.4-nightly.0+7b79c6d",
32
- "@parcel/reporter-dev-server": "2.8.4-nightly.0+7b79c6d",
33
- "@parcel/reporter-tracer": "2.8.4-nightly.0+7b79c6d",
34
- "@parcel/utils": "2.8.4-nightly.0+7b79c6d",
24
+ "@parcel/config-default": "2.9.0",
25
+ "@parcel/core": "2.9.0",
26
+ "@parcel/diagnostic": "2.9.0",
27
+ "@parcel/events": "2.9.0",
28
+ "@parcel/fs": "2.9.0",
29
+ "@parcel/logger": "2.9.0",
30
+ "@parcel/package-manager": "2.9.0",
31
+ "@parcel/reporter-cli": "2.9.0",
32
+ "@parcel/reporter-dev-server": "2.9.0",
33
+ "@parcel/reporter-tracer": "2.9.0",
34
+ "@parcel/utils": "2.9.0",
35
35
  "chalk": "^4.1.0",
36
36
  "commander": "^7.0.0",
37
37
  "get-port": "^4.2.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@babel/core": "^7.0.0",
41
- "@parcel/babel-register": "2.8.3"
41
+ "@parcel/babel-register": "2.9.0"
42
42
  },
43
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
43
+ "gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
44
44
  }
package/src/cli.js CHANGED
@@ -232,7 +232,7 @@ async function run(
232
232
  defaultConfig: require.resolve('@parcel/config-default', {
233
233
  paths: [fs.cwd(), __dirname],
234
234
  }),
235
- shouldPatchConsole: true,
235
+ shouldPatchConsole: false,
236
236
  ...options,
237
237
  });
238
238