parcel 2.0.0-beta.3 → 2.0.0-nightly.1002

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 (5) hide show
  1. package/README.md +36 -1510
  2. package/lib/cli.js +30 -23
  3. package/package.json +13 -13
  4. package/src/bin.js +4 -1
  5. package/src/cli.js +27 -17
package/lib/cli.js CHANGED
@@ -100,15 +100,7 @@ function _getPort() {
100
100
  return data;
101
101
  }
102
102
 
103
- function _package() {
104
- const data = require("../package.json");
105
-
106
- _package = function () {
107
- return data;
108
- };
109
-
110
- return data;
111
- }
103
+ var _package = require("../package.json");
112
104
 
113
105
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
114
106
 
@@ -123,16 +115,34 @@ const SIGINT_EXIT_CODE = 130;
123
115
  async function logUncaughtError(e) {
124
116
  if (e instanceof _diagnostic().default) {
125
117
  for (let diagnostic of e.diagnostics) {
126
- let out = await (0, _utils().prettyDiagnostic)(diagnostic);
118
+ let {
119
+ message,
120
+ codeframe,
121
+ stack,
122
+ hints,
123
+ documentation
124
+ } = await (0, _utils().prettyDiagnostic)(diagnostic);
125
+
126
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.red(message));
127
+
128
+ if (codeframe || stack) {
129
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
130
+ }
127
131
 
128
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(out.message);
132
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
129
133
 
130
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(out.codeframe);
134
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(stack);
131
135
 
132
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(out.stack);
136
+ if ((stack || codeframe) && hints.length > 0) {
137
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error('');
138
+ }
133
139
 
134
- for (let h of out.hints) {
135
- _logger().INTERNAL_ORIGINAL_CONSOLE.error(h);
140
+ for (let h of hints) {
141
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.blue(h));
142
+ }
143
+
144
+ if (documentation) {
145
+ _logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.magenta.bold(documentation));
136
146
  }
137
147
  }
138
148
  } else {
@@ -156,7 +166,7 @@ const handleUncaughtException = async exception => {
156
166
 
157
167
  process.on('unhandledRejection', handleUncaughtException);
158
168
  program.storeOptionsAsProperties();
159
- program.version(_package().version); // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
169
+ program.version(_package.version); // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
160
170
  // --no-content-hash, --experimental-scope-hoisting, --detailed-report
161
171
 
162
172
  const commonOptions = {
@@ -242,15 +252,12 @@ function runCommand(...args) {
242
252
 
243
253
  async function run(entries, _opts, // using pre v7 Commander options as properties
244
254
  command) {
245
- entries = entries.map(entry => _path().default.resolve(entry));
246
-
247
255
  if (entries.length === 0) {
248
- // TODO move this into core, a glob could still lead to no entries
249
- _logger().INTERNAL_ORIGINAL_CONSOLE.log('No entries found');
250
-
251
- return;
256
+ entries = ['.'];
252
257
  }
253
258
 
259
+ entries = entries.map(entry => _path().default.resolve(entry));
260
+
254
261
  let Parcel = require('@parcel/core').default;
255
262
 
256
263
  let fs = new (_fs().NodeFS)();
@@ -443,7 +450,6 @@ async function normalizeOptions(command, inputFS) {
443
450
  diagnostic: {
444
451
  message: `Could not get available port: ${err.message}`,
445
452
  origin: 'parcel',
446
- filePath: __filename,
447
453
  stack: err.stack
448
454
  }
449
455
  });
@@ -499,6 +505,7 @@ async function normalizeOptions(command, inputFS) {
499
505
  return {
500
506
  shouldDisableCache: command.cache === false,
501
507
  cacheDir: command.cacheDir,
508
+ config: command.config,
502
509
  mode,
503
510
  hmrOptions,
504
511
  shouldContentHash: hmrOptions ? false : command.contentHash,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parcel",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-nightly.1002+47379bf8",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,23 +21,23 @@
21
21
  "node": ">= 12.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@parcel/config-default": "2.0.0-beta.3",
25
- "@parcel/core": "2.0.0-beta.3",
26
- "@parcel/diagnostic": "2.0.0-beta.3",
27
- "@parcel/events": "2.0.0-beta.3",
28
- "@parcel/fs": "2.0.0-beta.3",
29
- "@parcel/logger": "2.0.0-beta.3",
30
- "@parcel/package-manager": "2.0.0-beta.3",
31
- "@parcel/reporter-cli": "2.0.0-beta.3",
32
- "@parcel/reporter-dev-server": "2.0.0-beta.3",
33
- "@parcel/utils": "2.0.0-beta.3",
24
+ "@parcel/config-default": "2.0.0-nightly.1004+47379bf8",
25
+ "@parcel/core": "2.0.0-nightly.1002+47379bf8",
26
+ "@parcel/diagnostic": "2.0.0-nightly.1004+47379bf8",
27
+ "@parcel/events": "2.0.0-nightly.1004+47379bf8",
28
+ "@parcel/fs": "2.0.0-nightly.1004+47379bf8",
29
+ "@parcel/logger": "2.0.0-nightly.1004+47379bf8",
30
+ "@parcel/package-manager": "2.0.0-nightly.1004+47379bf8",
31
+ "@parcel/reporter-cli": "2.0.0-nightly.1004+47379bf8",
32
+ "@parcel/reporter-dev-server": "2.0.0-nightly.1004+47379bf8",
33
+ "@parcel/utils": "2.0.0-nightly.1004+47379bf8",
34
34
  "chalk": "^4.1.0",
35
35
  "commander": "^7.0.0",
36
36
  "get-port": "^4.2.0",
37
37
  "v8-compile-cache": "^2.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@parcel/babel-register": "2.0.0-beta.3"
40
+ "@parcel/babel-register": "2.3.2"
41
41
  },
42
- "gitHead": "bf03f018093f8c7ca4c3a544524e15065a637b3b"
42
+ "gitHead": "47379bf8fabeb2cfe03ade8802d942388b153e5b"
43
43
  }
package/src/bin.js CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- if (process.env.PARCEL_BUILD_ENV !== 'production') {
5
+ if (
6
+ process.env.PARCEL_BUILD_ENV !== 'production' ||
7
+ process.env.PARCEL_SELF_BUILD
8
+ ) {
6
9
  require('@parcel/babel-register');
7
10
  }
8
11
 
package/src/cli.js CHANGED
@@ -25,12 +25,22 @@ const SIGINT_EXIT_CODE = 130;
25
25
  async function logUncaughtError(e: mixed) {
26
26
  if (e instanceof ThrowableDiagnostic) {
27
27
  for (let diagnostic of e.diagnostics) {
28
- let out = await prettyDiagnostic(diagnostic);
29
- INTERNAL_ORIGINAL_CONSOLE.error(out.message);
30
- INTERNAL_ORIGINAL_CONSOLE.error(out.codeframe);
31
- INTERNAL_ORIGINAL_CONSOLE.error(out.stack);
32
- for (let h of out.hints) {
33
- INTERNAL_ORIGINAL_CONSOLE.error(h);
28
+ let {message, codeframe, stack, hints, documentation} =
29
+ await prettyDiagnostic(diagnostic);
30
+ INTERNAL_ORIGINAL_CONSOLE.error(chalk.red(message));
31
+ if (codeframe || stack) {
32
+ INTERNAL_ORIGINAL_CONSOLE.error('');
33
+ }
34
+ INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
35
+ INTERNAL_ORIGINAL_CONSOLE.error(stack);
36
+ if ((stack || codeframe) && hints.length > 0) {
37
+ INTERNAL_ORIGINAL_CONSOLE.error('');
38
+ }
39
+ for (let h of hints) {
40
+ INTERNAL_ORIGINAL_CONSOLE.error(chalk.blue(h));
41
+ }
42
+ if (documentation) {
43
+ INTERNAL_ORIGINAL_CONSOLE.error(chalk.magenta.bold(documentation));
34
44
  }
35
45
  }
36
46
  } else {
@@ -162,12 +172,12 @@ applyOptions(build, commonOptions);
162
172
  program
163
173
  .command('help [command]')
164
174
  .description('display help information for a command')
165
- .action(function(command) {
175
+ .action(function (command) {
166
176
  let cmd = program.commands.find(c => c.name() === command) || program;
167
177
  cmd.help();
168
178
  });
169
179
 
170
- program.on('--help', function() {
180
+ program.on('--help', function () {
171
181
  INTERNAL_ORIGINAL_CONSOLE.log('');
172
182
  INTERNAL_ORIGINAL_CONSOLE.log(
173
183
  ' Run `' +
@@ -178,7 +188,7 @@ program.on('--help', function() {
178
188
  });
179
189
 
180
190
  // Override to output option description if argument was missing
181
- commander.Command.prototype.optionMissingArgument = function(option) {
191
+ commander.Command.prototype.optionMissingArgument = function (option) {
182
192
  INTERNAL_ORIGINAL_CONSOLE.error(
183
193
  "error: option `%s' argument missing",
184
194
  option.flags,
@@ -206,13 +216,12 @@ async function run(
206
216
  _opts: any, // using pre v7 Commander options as properties
207
217
  command: any,
208
218
  ) {
209
- entries = entries.map(entry => path.resolve(entry));
210
-
211
219
  if (entries.length === 0) {
212
- // TODO move this into core, a glob could still lead to no entries
213
- INTERNAL_ORIGINAL_CONSOLE.log('No entries found');
214
- return;
220
+ entries = ['.'];
215
221
  }
222
+
223
+ entries = entries.map(entry => path.resolve(entry));
224
+
216
225
  let Parcel = require('@parcel/core').default;
217
226
  let fs = new NodeFS();
218
227
  let options = await normalizeOptions(command, fs);
@@ -311,8 +320,9 @@ async function run(
311
320
 
312
321
  if (command.open && options.serveOptions) {
313
322
  await openInBrowser(
314
- `${options.serveOptions.https ? 'https' : 'http'}://${options
315
- .serveOptions.host || 'localhost'}:${options.serveOptions.port}`,
323
+ `${options.serveOptions.https ? 'https' : 'http'}://${
324
+ options.serveOptions.host || 'localhost'
325
+ }:${options.serveOptions.port}`,
316
326
  command.open,
317
327
  );
318
328
  }
@@ -404,7 +414,6 @@ async function normalizeOptions(
404
414
  diagnostic: {
405
415
  message: `Could not get available port: ${err.message}`,
406
416
  origin: 'parcel',
407
- filePath: __filename,
408
417
  stack: err.stack,
409
418
  },
410
419
  });
@@ -456,6 +465,7 @@ async function normalizeOptions(
456
465
  return {
457
466
  shouldDisableCache: command.cache === false,
458
467
  cacheDir: command.cacheDir,
468
+ config: command.config,
459
469
  mode,
460
470
  hmrOptions,
461
471
  shouldContentHash: hmrOptions ? false : command.contentHash,