parcel 2.11.0 → 2.13.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 +60 -7
  2. package/package.json +18 -17
  3. package/src/cli.js +64 -2
package/lib/cli.js CHANGED
@@ -71,7 +71,14 @@ function _getPort() {
71
71
  return data;
72
72
  }
73
73
  var _package = require("../package.json");
74
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
74
+ function _featureFlags() {
75
+ const data = require("@parcel/feature-flags");
76
+ _featureFlags = function () {
77
+ return data;
78
+ };
79
+ return data;
80
+ }
81
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
75
82
  const program = new (_commander().default.Command)();
76
83
 
77
84
  // Exit codes in response to signals are traditionally
@@ -124,14 +131,42 @@ process.on('unhandledRejection', handleUncaughtException);
124
131
  program.storeOptionsAsProperties();
125
132
  program.version(_package.version);
126
133
 
134
+ // Only display choices available to callers OS
135
+ let watcherBackendChoices = ['brute-force'];
136
+ switch (process.platform) {
137
+ case 'darwin':
138
+ {
139
+ watcherBackendChoices.push('watchman', 'fs-events');
140
+ break;
141
+ }
142
+ case 'linux':
143
+ {
144
+ watcherBackendChoices.push('watchman', 'inotify');
145
+ break;
146
+ }
147
+ case 'win32':
148
+ {
149
+ watcherBackendChoices.push('watchman', 'windows');
150
+ break;
151
+ }
152
+ case 'freebsd' || 'openbsd':
153
+ {
154
+ watcherBackendChoices.push('watchman');
155
+ break;
156
+ }
157
+ default:
158
+ break;
159
+ }
160
+
127
161
  // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
128
162
  // --no-content-hash, --experimental-scope-hoisting, --detailed-report
129
-
130
163
  const commonOptions = {
131
164
  '--no-cache': 'disable the filesystem cache',
132
165
  '--config <path>': 'specify which config to use. can be a path or a package name',
133
166
  '--cache-dir <path>': 'set the cache directory. defaults to ".parcel-cache"',
134
167
  '--watch-dir <path>': 'set the root watch directory. defaults to nearest lockfile or source control dir.',
168
+ '--watch-ignore [path]': [`list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`, dirs => dirs.split(',')],
169
+ '--watch-backend': new (_commander().default.Option)('--watch-backend <name>', 'set watcher backend').choices(watcherBackendChoices),
135
170
  '--no-source-maps': 'disable sourcemaps',
136
171
  '--target [name]': ['only build given target(s)', (val, list) => list.concat([val]), []],
137
172
  '--log-level <level>': new (_commander().default.Option)('--log-level <level>', 'set the log level').choices(['none', 'error', 'warn', 'info', 'verbose']),
@@ -144,7 +179,23 @@ const commonOptions = {
144
179
  '--reporter <name>': ['additional reporters to run', (val, acc) => {
145
180
  acc.push(val);
146
181
  return acc;
147
- }, []]
182
+ }, []],
183
+ '--feature-flag <name=value>': ['sets the value of a feature flag', (value, previousValue) => {
184
+ let [name, val] = value.split('=');
185
+ if (name in _featureFlags().DEFAULT_FEATURE_FLAGS) {
186
+ let featureFlagValue;
187
+ if (typeof _featureFlags().DEFAULT_FEATURE_FLAGS[name] === 'boolean') {
188
+ if (val !== 'true' && val !== 'false') {
189
+ throw new Error(`Feature flag ${name} must be set to true or false`);
190
+ }
191
+ featureFlagValue = val === 'true';
192
+ }
193
+ previousValue[name] = featureFlagValue ?? String(val);
194
+ } else {
195
+ _logger().INTERNAL_ORIGINAL_CONSOLE.warn(`Unknown feature flag ${name} specified, it will be ignored`);
196
+ }
197
+ return previousValue;
198
+ }, {}]
148
199
  };
149
200
  var hmrOptions = {
150
201
  '--no-hmr': 'disable hot module replacement',
@@ -331,7 +382,6 @@ function parseOptionInt(value) {
331
382
  return parsedValue;
332
383
  }
333
384
  async function normalizeOptions(command, inputFS) {
334
- var _command$autoinstall, _command$sourceMaps;
335
385
  let nodeEnv;
336
386
  if (command.name() === 'build') {
337
387
  nodeEnv = process.env.NODE_ENV || 'production';
@@ -430,13 +480,15 @@ async function normalizeOptions(command, inputFS) {
430
480
  shouldDisableCache: command.cache === false,
431
481
  cacheDir: command.cacheDir,
432
482
  watchDir: command.watchDir,
483
+ watchBackend: command.watchBackend,
484
+ watchIgnore: command.watchIgnore,
433
485
  config: command.config,
434
486
  mode,
435
487
  hmrOptions,
436
488
  shouldContentHash: hmrOptions ? false : command.contentHash,
437
489
  serveOptions,
438
490
  targets: command.target.length > 0 ? command.target : null,
439
- shouldAutoInstall: (_command$autoinstall = command.autoinstall) !== null && _command$autoinstall !== void 0 ? _command$autoinstall : true,
491
+ shouldAutoInstall: command.autoinstall ?? true,
440
492
  logLevel: command.logLevel,
441
493
  shouldProfile: command.profile,
442
494
  shouldTrace: command.trace,
@@ -453,10 +505,11 @@ async function normalizeOptions(command, inputFS) {
453
505
  additionalReporters,
454
506
  defaultTargetOptions: {
455
507
  shouldOptimize: command.optimize != null ? command.optimize : mode === 'production',
456
- sourceMaps: (_command$sourceMaps = command.sourceMaps) !== null && _command$sourceMaps !== void 0 ? _command$sourceMaps : true,
508
+ sourceMaps: command.sourceMaps ?? true,
457
509
  shouldScopeHoist: command.scopeHoist,
458
510
  publicUrl: command.publicUrl,
459
511
  distDir: command.distDir
460
- }
512
+ },
513
+ featureFlags: command.featureFlag
461
514
  };
462
515
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parcel",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -18,27 +18,28 @@
18
18
  "main": "lib/bin.js",
19
19
  "source": "src/bin.js",
20
20
  "engines": {
21
- "node": ">= 12.0.0"
21
+ "node": ">= 16.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@parcel/config-default": "2.11.0",
25
- "@parcel/core": "2.11.0",
26
- "@parcel/diagnostic": "2.11.0",
27
- "@parcel/events": "2.11.0",
28
- "@parcel/fs": "2.11.0",
29
- "@parcel/logger": "2.11.0",
30
- "@parcel/package-manager": "2.11.0",
31
- "@parcel/reporter-cli": "2.11.0",
32
- "@parcel/reporter-dev-server": "2.11.0",
33
- "@parcel/reporter-tracer": "2.11.0",
34
- "@parcel/utils": "2.11.0",
35
- "chalk": "^4.1.0",
36
- "commander": "^7.0.0",
24
+ "@parcel/config-default": "2.13.0",
25
+ "@parcel/core": "2.13.0",
26
+ "@parcel/diagnostic": "2.13.0",
27
+ "@parcel/events": "2.13.0",
28
+ "@parcel/feature-flags": "2.13.0",
29
+ "@parcel/fs": "2.13.0",
30
+ "@parcel/logger": "2.13.0",
31
+ "@parcel/package-manager": "2.13.0",
32
+ "@parcel/reporter-cli": "2.13.0",
33
+ "@parcel/reporter-dev-server": "2.13.0",
34
+ "@parcel/reporter-tracer": "2.13.0",
35
+ "@parcel/utils": "2.13.0",
36
+ "chalk": "^4.1.2",
37
+ "commander": "^12.1.0",
37
38
  "get-port": "^4.2.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@babel/core": "^7.22.11",
41
- "@parcel/babel-register": "2.11.0"
42
+ "@parcel/babel-register": "2.13.0"
42
43
  },
43
- "gitHead": "f8076f1644cabc944695b5ec82602c8ae32bcf21"
44
+ "gitHead": "a53f8f3ba1025c7ea8653e9719e0a61ef9717079"
44
45
  }
package/src/cli.js CHANGED
@@ -12,6 +12,7 @@ import commander from 'commander';
12
12
  import path from 'path';
13
13
  import getPort from 'get-port';
14
14
  import {version} from '../package.json';
15
+ import {DEFAULT_FEATURE_FLAGS} from '@parcel/feature-flags';
15
16
 
16
17
  const program = new commander.Command();
17
18
 
@@ -65,9 +66,31 @@ process.on('unhandledRejection', handleUncaughtException);
65
66
  program.storeOptionsAsProperties();
66
67
  program.version(version);
67
68
 
69
+ // Only display choices available to callers OS
70
+ let watcherBackendChoices = ['brute-force'];
71
+ switch (process.platform) {
72
+ case 'darwin': {
73
+ watcherBackendChoices.push('watchman', 'fs-events');
74
+ break;
75
+ }
76
+ case 'linux': {
77
+ watcherBackendChoices.push('watchman', 'inotify');
78
+ break;
79
+ }
80
+ case 'win32': {
81
+ watcherBackendChoices.push('watchman', 'windows');
82
+ break;
83
+ }
84
+ case 'freebsd' || 'openbsd': {
85
+ watcherBackendChoices.push('watchman');
86
+ break;
87
+ }
88
+ default:
89
+ break;
90
+ }
91
+
68
92
  // --no-cache, --cache-dir, --no-source-maps, --no-autoinstall, --global?, --public-url, --log-level
69
93
  // --no-content-hash, --experimental-scope-hoisting, --detailed-report
70
-
71
94
  const commonOptions = {
72
95
  '--no-cache': 'disable the filesystem cache',
73
96
  '--config <path>':
@@ -75,6 +98,14 @@ const commonOptions = {
75
98
  '--cache-dir <path>': 'set the cache directory. defaults to ".parcel-cache"',
76
99
  '--watch-dir <path>':
77
100
  'set the root watch directory. defaults to nearest lockfile or source control dir.',
101
+ '--watch-ignore [path]': [
102
+ `list of directories watcher should not be tracking for changes. defaults to ['.git', '.hg']`,
103
+ dirs => dirs.split(','),
104
+ ],
105
+ '--watch-backend': new commander.Option(
106
+ '--watch-backend <name>',
107
+ 'set watcher backend',
108
+ ).choices(watcherBackendChoices),
78
109
  '--no-source-maps': 'disable sourcemaps',
79
110
  '--target [name]': [
80
111
  'only build given target(s)',
@@ -103,6 +134,30 @@ const commonOptions = {
103
134
  },
104
135
  [],
105
136
  ],
137
+ '--feature-flag <name=value>': [
138
+ 'sets the value of a feature flag',
139
+ (value, previousValue) => {
140
+ let [name, val] = value.split('=');
141
+ if (name in DEFAULT_FEATURE_FLAGS) {
142
+ let featureFlagValue;
143
+ if (typeof DEFAULT_FEATURE_FLAGS[name] === 'boolean') {
144
+ if (val !== 'true' && val !== 'false') {
145
+ throw new Error(
146
+ `Feature flag ${name} must be set to true or false`,
147
+ );
148
+ }
149
+ featureFlagValue = val === 'true';
150
+ }
151
+ previousValue[name] = featureFlagValue ?? String(val);
152
+ } else {
153
+ INTERNAL_ORIGINAL_CONSOLE.warn(
154
+ `Unknown feature flag ${name} specified, it will be ignored`,
155
+ );
156
+ }
157
+ return previousValue;
158
+ },
159
+ {},
160
+ ],
106
161
  };
107
162
 
108
163
  var hmrOptions = {
@@ -444,7 +499,10 @@ async function normalizeOptions(
444
499
  let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port;
445
500
  let hmrhost = command.hmrHost ? command.hmrHost : host;
446
501
 
447
- hmrOptions = {port: hmrport, host: hmrhost};
502
+ hmrOptions = {
503
+ port: hmrport,
504
+ host: hmrhost,
505
+ };
448
506
  }
449
507
 
450
508
  if (command.detailedReport === true) {
@@ -472,10 +530,13 @@ async function normalizeOptions(
472
530
  if (typeof input !== 'string') return [];
473
531
  return input.split(',').map(value => value.trim());
474
532
  };
533
+
475
534
  return {
476
535
  shouldDisableCache: command.cache === false,
477
536
  cacheDir: command.cacheDir,
478
537
  watchDir: command.watchDir,
538
+ watchBackend: command.watchBackend,
539
+ watchIgnore: command.watchIgnore,
479
540
  config: command.config,
480
541
  mode,
481
542
  hmrOptions,
@@ -509,5 +570,6 @@ async function normalizeOptions(
509
570
  publicUrl: command.publicUrl,
510
571
  distDir: command.distDir,
511
572
  },
573
+ featureFlags: command.featureFlag,
512
574
  };
513
575
  }