parcel 2.0.0-beta.2 → 2.0.0-nightly.1000
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/README.md +36 -1519
- package/lib/cli.js +46 -41
- package/package.json +13 -13
- package/src/bin.js +4 -1
- package/src/cli.js +39 -21
package/lib/cli.js
CHANGED
|
@@ -10,16 +10,6 @@ function _core() {
|
|
|
10
10
|
return data;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function _packageManager() {
|
|
14
|
-
const data = require("@parcel/package-manager");
|
|
15
|
-
|
|
16
|
-
_packageManager = function () {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
function _fs() {
|
|
24
14
|
const data = require("@parcel/fs");
|
|
25
15
|
|
|
@@ -110,15 +100,7 @@ function _getPort() {
|
|
|
110
100
|
return data;
|
|
111
101
|
}
|
|
112
102
|
|
|
113
|
-
|
|
114
|
-
const data = require("../package.json");
|
|
115
|
-
|
|
116
|
-
_package = function () {
|
|
117
|
-
return data;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
return data;
|
|
121
|
-
}
|
|
103
|
+
var _package = require("../package.json");
|
|
122
104
|
|
|
123
105
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
124
106
|
|
|
@@ -133,14 +115,34 @@ const SIGINT_EXIT_CODE = 130;
|
|
|
133
115
|
async function logUncaughtError(e) {
|
|
134
116
|
if (e instanceof _diagnostic().default) {
|
|
135
117
|
for (let diagnostic of e.diagnostics) {
|
|
136
|
-
let
|
|
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
|
+
}
|
|
131
|
+
|
|
132
|
+
_logger().INTERNAL_ORIGINAL_CONSOLE.error(codeframe);
|
|
133
|
+
|
|
134
|
+
_logger().INTERNAL_ORIGINAL_CONSOLE.error(stack);
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
if ((stack || codeframe) && hints.length > 0) {
|
|
137
|
+
_logger().INTERNAL_ORIGINAL_CONSOLE.error('');
|
|
138
|
+
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
for (let h of hints) {
|
|
141
|
+
_logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.blue(h));
|
|
142
|
+
}
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
_logger().INTERNAL_ORIGINAL_CONSOLE.error(
|
|
144
|
+
if (documentation) {
|
|
145
|
+
_logger().INTERNAL_ORIGINAL_CONSOLE.error(_chalk().default.magenta.bold(documentation));
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
148
|
} else {
|
|
@@ -164,7 +166,7 @@ const handleUncaughtException = async exception => {
|
|
|
164
166
|
|
|
165
167
|
process.on('unhandledRejection', handleUncaughtException);
|
|
166
168
|
program.storeOptionsAsProperties();
|
|
167
|
-
program.version(_package
|
|
169
|
+
program.version(_package.version); // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
|
|
168
170
|
// --no-content-hash, --experimental-scope-hoisting, --detailed-report
|
|
169
171
|
|
|
170
172
|
const commonOptions = {
|
|
@@ -178,7 +180,7 @@ const commonOptions = {
|
|
|
178
180
|
'--no-autoinstall': 'disable autoinstall',
|
|
179
181
|
'--profile': 'enable build profiling',
|
|
180
182
|
'-V, --version': 'output the version number',
|
|
181
|
-
'--detailed-report [count]': ['print the asset timings and sizes in the build report', parseOptionInt
|
|
183
|
+
'--detailed-report [count]': ['print the asset timings and sizes in the build report', parseOptionInt],
|
|
182
184
|
'--reporter <name>': ['additional reporters to run', (val, acc) => {
|
|
183
185
|
acc.push(val);
|
|
184
186
|
return acc;
|
|
@@ -250,23 +252,18 @@ function runCommand(...args) {
|
|
|
250
252
|
|
|
251
253
|
async function run(entries, _opts, // using pre v7 Commander options as properties
|
|
252
254
|
command) {
|
|
253
|
-
entries = entries.map(entry => _path().default.resolve(entry));
|
|
254
|
-
|
|
255
255
|
if (entries.length === 0) {
|
|
256
|
-
|
|
257
|
-
_logger().INTERNAL_ORIGINAL_CONSOLE.log('No entries found');
|
|
258
|
-
|
|
259
|
-
return;
|
|
256
|
+
entries = ['.'];
|
|
260
257
|
}
|
|
261
258
|
|
|
259
|
+
entries = entries.map(entry => _path().default.resolve(entry));
|
|
260
|
+
|
|
262
261
|
let Parcel = require('@parcel/core').default;
|
|
263
262
|
|
|
264
263
|
let fs = new (_fs().NodeFS)();
|
|
265
264
|
let options = await normalizeOptions(command, fs);
|
|
266
|
-
let packageManager = new (_packageManager().NodePackageManager)(fs);
|
|
267
265
|
let parcel = new Parcel({
|
|
268
266
|
entries,
|
|
269
|
-
packageManager,
|
|
270
267
|
// $FlowFixMe[extra-arg] - flow doesn't know about the `paths` option (added in Node v8.9.0)
|
|
271
268
|
defaultConfig: require.resolve('@parcel/config-default', {
|
|
272
269
|
paths: [fs.cwd(), __dirname]
|
|
@@ -443,10 +440,20 @@ async function normalizeOptions(command, inputFS) {
|
|
|
443
440
|
let originalPort = port;
|
|
444
441
|
|
|
445
442
|
if (command.name() === 'serve' || command.hmr) {
|
|
446
|
-
|
|
447
|
-
port,
|
|
448
|
-
|
|
449
|
-
|
|
443
|
+
try {
|
|
444
|
+
port = await (0, _getPort().default)({
|
|
445
|
+
port,
|
|
446
|
+
host
|
|
447
|
+
});
|
|
448
|
+
} catch (err) {
|
|
449
|
+
throw new (_diagnostic().default)({
|
|
450
|
+
diagnostic: {
|
|
451
|
+
message: `Could not get available port: ${err.message}`,
|
|
452
|
+
origin: 'parcel',
|
|
453
|
+
stack: err.stack
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
450
457
|
|
|
451
458
|
if (port !== originalPort) {
|
|
452
459
|
let errorMessage = `Port "${originalPort}" could not be used`;
|
|
@@ -490,9 +497,6 @@ async function normalizeOptions(command, inputFS) {
|
|
|
490
497
|
let additionalReporters = [{
|
|
491
498
|
packageName: '@parcel/reporter-cli',
|
|
492
499
|
resolveFrom: __filename
|
|
493
|
-
}, {
|
|
494
|
-
packageName: '@parcel/reporter-dev-server',
|
|
495
|
-
resolveFrom: __filename
|
|
496
500
|
}, ...command.reporter.map(packageName => ({
|
|
497
501
|
packageName,
|
|
498
502
|
resolveFrom: _path().default.join(inputFS.cwd(), 'index')
|
|
@@ -501,6 +505,7 @@ async function normalizeOptions(command, inputFS) {
|
|
|
501
505
|
return {
|
|
502
506
|
shouldDisableCache: command.cache === false,
|
|
503
507
|
cacheDir: command.cacheDir,
|
|
508
|
+
config: command.config,
|
|
504
509
|
mode,
|
|
505
510
|
hmrOptions,
|
|
506
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-
|
|
3
|
+
"version": "2.0.0-nightly.1000+5530a6ef",
|
|
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-
|
|
25
|
-
"@parcel/core": "2.0.0-
|
|
26
|
-
"@parcel/diagnostic": "2.0.0-
|
|
27
|
-
"@parcel/events": "2.0.0-
|
|
28
|
-
"@parcel/fs": "2.0.0-
|
|
29
|
-
"@parcel/logger": "2.0.0-
|
|
30
|
-
"@parcel/package-manager": "2.0.0-
|
|
31
|
-
"@parcel/reporter-cli": "2.0.0-
|
|
32
|
-
"@parcel/reporter-dev-server": "2.0.0-
|
|
33
|
-
"@parcel/utils": "2.0.0-
|
|
24
|
+
"@parcel/config-default": "2.0.0-nightly.1002+5530a6ef",
|
|
25
|
+
"@parcel/core": "2.0.0-nightly.1000+5530a6ef",
|
|
26
|
+
"@parcel/diagnostic": "2.0.0-nightly.1002+5530a6ef",
|
|
27
|
+
"@parcel/events": "2.0.0-nightly.1002+5530a6ef",
|
|
28
|
+
"@parcel/fs": "2.0.0-nightly.1002+5530a6ef",
|
|
29
|
+
"@parcel/logger": "2.0.0-nightly.1002+5530a6ef",
|
|
30
|
+
"@parcel/package-manager": "2.0.0-nightly.1002+5530a6ef",
|
|
31
|
+
"@parcel/reporter-cli": "2.0.0-nightly.1002+5530a6ef",
|
|
32
|
+
"@parcel/reporter-dev-server": "2.0.0-nightly.1002+5530a6ef",
|
|
33
|
+
"@parcel/utils": "2.0.0-nightly.1002+5530a6ef",
|
|
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.
|
|
40
|
+
"@parcel/babel-register": "2.3.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "5530a6eff8b619873353baeb0457ae4ec591e9fa"
|
|
43
43
|
}
|
package/src/bin.js
CHANGED
package/src/cli.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import type {InitialParcelOptions} from '@parcel/types';
|
|
4
4
|
import {BuildError} from '@parcel/core';
|
|
5
|
-
import {NodePackageManager} from '@parcel/package-manager';
|
|
6
5
|
import {NodeFS} from '@parcel/fs';
|
|
7
6
|
import ThrowableDiagnostic from '@parcel/diagnostic';
|
|
8
7
|
import {prettyDiagnostic, openInBrowser} from '@parcel/utils';
|
|
@@ -26,11 +25,22 @@ const SIGINT_EXIT_CODE = 130;
|
|
|
26
25
|
async function logUncaughtError(e: mixed) {
|
|
27
26
|
if (e instanceof ThrowableDiagnostic) {
|
|
28
27
|
for (let diagnostic of e.diagnostics) {
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
INTERNAL_ORIGINAL_CONSOLE.error(
|
|
32
|
-
|
|
33
|
-
INTERNAL_ORIGINAL_CONSOLE.error(
|
|
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 {
|
|
@@ -83,7 +93,6 @@ const commonOptions = {
|
|
|
83
93
|
'--detailed-report [count]': [
|
|
84
94
|
'print the asset timings and sizes in the build report',
|
|
85
95
|
parseOptionInt,
|
|
86
|
-
'10',
|
|
87
96
|
],
|
|
88
97
|
'--reporter <name>': [
|
|
89
98
|
'additional reporters to run',
|
|
@@ -163,12 +172,12 @@ applyOptions(build, commonOptions);
|
|
|
163
172
|
program
|
|
164
173
|
.command('help [command]')
|
|
165
174
|
.description('display help information for a command')
|
|
166
|
-
.action(function(command) {
|
|
175
|
+
.action(function (command) {
|
|
167
176
|
let cmd = program.commands.find(c => c.name() === command) || program;
|
|
168
177
|
cmd.help();
|
|
169
178
|
});
|
|
170
179
|
|
|
171
|
-
program.on('--help', function() {
|
|
180
|
+
program.on('--help', function () {
|
|
172
181
|
INTERNAL_ORIGINAL_CONSOLE.log('');
|
|
173
182
|
INTERNAL_ORIGINAL_CONSOLE.log(
|
|
174
183
|
' Run `' +
|
|
@@ -179,7 +188,7 @@ program.on('--help', function() {
|
|
|
179
188
|
});
|
|
180
189
|
|
|
181
190
|
// Override to output option description if argument was missing
|
|
182
|
-
commander.Command.prototype.optionMissingArgument = function(option) {
|
|
191
|
+
commander.Command.prototype.optionMissingArgument = function (option) {
|
|
183
192
|
INTERNAL_ORIGINAL_CONSOLE.error(
|
|
184
193
|
"error: option `%s' argument missing",
|
|
185
194
|
option.flags,
|
|
@@ -191,6 +200,7 @@ commander.Command.prototype.optionMissingArgument = function(option) {
|
|
|
191
200
|
// Make serve the default command except for --help
|
|
192
201
|
var args = process.argv;
|
|
193
202
|
if (args[2] === '--help' || args[2] === '-h') args[2] = 'help';
|
|
203
|
+
|
|
194
204
|
if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
|
|
195
205
|
args.splice(2, 0, 'serve');
|
|
196
206
|
}
|
|
@@ -206,20 +216,17 @@ 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
|
-
|
|
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);
|
|
219
|
-
let packageManager = new NodePackageManager(fs);
|
|
220
228
|
let parcel = new Parcel({
|
|
221
229
|
entries,
|
|
222
|
-
packageManager,
|
|
223
230
|
// $FlowFixMe[extra-arg] - flow doesn't know about the `paths` option (added in Node v8.9.0)
|
|
224
231
|
defaultConfig: require.resolve('@parcel/config-default', {
|
|
225
232
|
paths: [fs.cwd(), __dirname],
|
|
@@ -313,8 +320,9 @@ async function run(
|
|
|
313
320
|
|
|
314
321
|
if (command.open && options.serveOptions) {
|
|
315
322
|
await openInBrowser(
|
|
316
|
-
`${options.serveOptions.https ? 'https' : 'http'}://${
|
|
317
|
-
.serveOptions.host || 'localhost'
|
|
323
|
+
`${options.serveOptions.https ? 'https' : 'http'}://${
|
|
324
|
+
options.serveOptions.host || 'localhost'
|
|
325
|
+
}:${options.serveOptions.port}`,
|
|
318
326
|
command.open,
|
|
319
327
|
);
|
|
320
328
|
}
|
|
@@ -399,7 +407,17 @@ async function normalizeOptions(
|
|
|
399
407
|
let port = parsePort(command.port || '1234');
|
|
400
408
|
let originalPort = port;
|
|
401
409
|
if (command.name() === 'serve' || command.hmr) {
|
|
402
|
-
|
|
410
|
+
try {
|
|
411
|
+
port = await getPort({port, host});
|
|
412
|
+
} catch (err) {
|
|
413
|
+
throw new ThrowableDiagnostic({
|
|
414
|
+
diagnostic: {
|
|
415
|
+
message: `Could not get available port: ${err.message}`,
|
|
416
|
+
origin: 'parcel',
|
|
417
|
+
stack: err.stack,
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
}
|
|
403
421
|
|
|
404
422
|
if (port !== originalPort) {
|
|
405
423
|
let errorMessage = `Port "${originalPort}" could not be used`;
|
|
@@ -437,7 +455,6 @@ async function normalizeOptions(
|
|
|
437
455
|
|
|
438
456
|
let additionalReporters = [
|
|
439
457
|
{packageName: '@parcel/reporter-cli', resolveFrom: __filename},
|
|
440
|
-
{packageName: '@parcel/reporter-dev-server', resolveFrom: __filename},
|
|
441
458
|
...(command.reporter: Array<string>).map(packageName => ({
|
|
442
459
|
packageName,
|
|
443
460
|
resolveFrom: path.join(inputFS.cwd(), 'index'),
|
|
@@ -448,6 +465,7 @@ async function normalizeOptions(
|
|
|
448
465
|
return {
|
|
449
466
|
shouldDisableCache: command.cache === false,
|
|
450
467
|
cacheDir: command.cacheDir,
|
|
468
|
+
config: command.config,
|
|
451
469
|
mode,
|
|
452
470
|
hmrOptions,
|
|
453
471
|
shouldContentHash: hmrOptions ? false : command.contentHash,
|