@atlaspack/cli 2.12.1-canary.3443 → 2.12.1-canary.3444

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 +9 -6
  2. package/package.json +14 -14
  3. package/src/cli.js +15 -4
package/lib/cli.js CHANGED
@@ -217,10 +217,10 @@ function applyOptions(cmd, options) {
217
217
  }
218
218
  }
219
219
  }
220
- 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 [includes]', 'Build async bundles on demand, when requested in the browser. Defaults to all async bundles, unless a comma separated list of source file globs is provided. Only async bundles whose entry points match these globs will be built lazily').option('--lazy-exclude <excludes>', 'Can only be used in combination with --lazy. Comma separated list of source file globs, async bundles whose entry points match these globs will not be built lazily').action(runCommand);
220
+ 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 [includes]', 'Build async bundles on demand, when requested in the browser. Defaults to all async bundles, unless a comma separated list of source file globs is provided. Only async bundles whose entry points match these globs will be built lazily').option('--lazy-exclude <excludes>', 'Can only be used in combination with --lazy. Comma separated list of source file globs, async bundles whose entry points match these globs will not be built lazily').option('--production', 'Run with production mode defaults').action(runCommand);
221
221
  applyOptions(serve, hmrOptions);
222
222
  applyOptions(serve, commonOptions);
223
- let watch = program.command('watch [input...]').description('starts the bundler in watch mode').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').option('--watch-for-stdin', 'exit when stdin closes').action(runCommand);
223
+ let watch = program.command('watch [input...]').description('starts the bundler in watch mode').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').option('--watch-for-stdin', 'exit when stdin closes').option('--production', 'Run with production mode defaults').action(runCommand);
224
224
  applyOptions(watch, hmrOptions);
225
225
  applyOptions(watch, commonOptions);
226
226
  let build = program.command('build [input...]').description('bundles for production').option('--no-optimize', 'disable minification').option('--no-scope-hoist', 'disable scope-hoisting').option('--public-url <url>', 'the path prefix for absolute urls').option('--no-content-hash', 'disable content hashing').action(runCommand);
@@ -415,9 +415,12 @@ function parseOptionInt(value) {
415
415
  }
416
416
  return parsedValue;
417
417
  }
418
+ function shouldUseProductionDefaults(command) {
419
+ return command.name() === 'build' || command.production === true;
420
+ }
418
421
  async function normalizeOptions(command, inputFS) {
419
422
  let nodeEnv;
420
- if (command.name() === 'build') {
423
+ if (shouldUseProductionDefaults(command)) {
421
424
  nodeEnv = process.env.NODE_ENV || 'production';
422
425
  // Autoinstall unless explicitly disabled or we detect a CI environment.
423
426
  command.autoinstall = !(command.autoinstall === false || process.env.CI);
@@ -443,7 +446,7 @@ async function normalizeOptions(command, inputFS) {
443
446
  // Ensure port is valid and available
444
447
  let port = parsePort(command.port || '1234');
445
448
  let originalPort = port;
446
- if (command.name() === 'serve' || command.hmr) {
449
+ if (!shouldUseProductionDefaults(command) && (command.name() === 'serve' || command.hmr)) {
447
450
  try {
448
451
  port = await (0, _getPort().default)({
449
452
  port,
@@ -481,7 +484,7 @@ async function normalizeOptions(command, inputFS) {
481
484
  };
482
485
  }
483
486
  let hmrOptions = null;
484
- if (command.name() !== 'build' && command.hmr !== false) {
487
+ if (!shouldUseProductionDefaults(command) && command.hmr !== false) {
485
488
  let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port;
486
489
  let hmrhost = command.hmrHost ? command.hmrHost : host;
487
490
  hmrOptions = {
@@ -505,7 +508,7 @@ async function normalizeOptions(command, inputFS) {
505
508
  resolveFrom: __filename
506
509
  });
507
510
  }
508
- let mode = command.name() === 'build' ? 'production' : 'development';
511
+ let mode = shouldUseProductionDefaults(command) ? 'production' : 'development';
509
512
  const normalizeIncludeExcludeList = input => {
510
513
  if (typeof input !== 'string') return [];
511
514
  return input.split(',').map(value => value.trim());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/cli",
3
- "version": "2.12.1-canary.3443+15e45b97e",
3
+ "version": "2.12.1-canary.3444+f790d5759",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -23,18 +23,18 @@
23
23
  "node": ">= 16.0.0"
24
24
  },
25
25
  "dependencies": {
26
- "@atlaspack/config-default": "2.12.1-canary.3443+15e45b97e",
27
- "@atlaspack/core": "2.12.1-canary.3443+15e45b97e",
28
- "@atlaspack/diagnostic": "2.12.1-canary.3443+15e45b97e",
29
- "@atlaspack/events": "2.12.1-canary.3443+15e45b97e",
30
- "@atlaspack/feature-flags": "2.12.1-canary.3443+15e45b97e",
31
- "@atlaspack/fs": "2.12.1-canary.3443+15e45b97e",
32
- "@atlaspack/logger": "2.12.1-canary.3443+15e45b97e",
33
- "@atlaspack/package-manager": "2.12.1-canary.3443+15e45b97e",
34
- "@atlaspack/reporter-cli": "2.12.1-canary.3443+15e45b97e",
35
- "@atlaspack/reporter-dev-server": "2.12.1-canary.3443+15e45b97e",
36
- "@atlaspack/reporter-tracer": "2.12.1-canary.3443+15e45b97e",
37
- "@atlaspack/utils": "2.12.1-canary.3443+15e45b97e",
26
+ "@atlaspack/config-default": "2.12.1-canary.3444+f790d5759",
27
+ "@atlaspack/core": "2.12.1-canary.3444+f790d5759",
28
+ "@atlaspack/diagnostic": "2.12.1-canary.3444+f790d5759",
29
+ "@atlaspack/events": "2.12.1-canary.3444+f790d5759",
30
+ "@atlaspack/feature-flags": "2.12.1-canary.3444+f790d5759",
31
+ "@atlaspack/fs": "2.12.1-canary.3444+f790d5759",
32
+ "@atlaspack/logger": "2.12.1-canary.3444+f790d5759",
33
+ "@atlaspack/package-manager": "2.12.1-canary.3444+f790d5759",
34
+ "@atlaspack/reporter-cli": "2.12.1-canary.3444+f790d5759",
35
+ "@atlaspack/reporter-dev-server": "2.12.1-canary.3444+f790d5759",
36
+ "@atlaspack/reporter-tracer": "2.12.1-canary.3444+f790d5759",
37
+ "@atlaspack/utils": "2.12.1-canary.3444+f790d5759",
38
38
  "chalk": "^4.1.0",
39
39
  "commander": "^7.0.0",
40
40
  "get-port": "^4.2.0"
@@ -44,5 +44,5 @@
44
44
  "@babel/core": "^7.22.11",
45
45
  "rimraf": "^5.0.5"
46
46
  },
47
- "gitHead": "15e45b97efca8057803259d2b6362ac1f3e50567"
47
+ "gitHead": "f790d5759624f38c8a6663c1e146c59429f79327"
48
48
  }
package/src/cli.js CHANGED
@@ -203,6 +203,7 @@ let serve = program
203
203
  '--lazy-exclude <excludes>',
204
204
  'Can only be used in combination with --lazy. Comma separated list of source file globs, async bundles whose entry points match these globs will not be built lazily',
205
205
  )
206
+ .option('--production', 'Run with production mode defaults')
206
207
  .action(runCommand);
207
208
 
208
209
  applyOptions(serve, hmrOptions);
@@ -214,6 +215,7 @@ let watch = program
214
215
  .option('--public-url <url>', 'the path prefix for absolute urls')
215
216
  .option('--no-content-hash', 'disable content hashing')
216
217
  .option('--watch-for-stdin', 'exit when stdin closes')
218
+ .option('--production', 'Run with production mode defaults')
217
219
  .action(runCommand);
218
220
 
219
221
  applyOptions(watch, hmrOptions);
@@ -474,12 +476,16 @@ function parseOptionInt(value) {
474
476
  return parsedValue;
475
477
  }
476
478
 
479
+ function shouldUseProductionDefaults(command) {
480
+ return command.name() === 'build' || command.production === true;
481
+ }
482
+
477
483
  async function normalizeOptions(
478
484
  command,
479
485
  inputFS,
480
486
  ): Promise<InitialAtlaspackOptions> {
481
487
  let nodeEnv;
482
- if (command.name() === 'build') {
488
+ if (shouldUseProductionDefaults(command)) {
483
489
  nodeEnv = process.env.NODE_ENV || 'production';
484
490
  // Autoinstall unless explicitly disabled or we detect a CI environment.
485
491
  command.autoinstall = !(command.autoinstall === false || process.env.CI);
@@ -505,7 +511,10 @@ async function normalizeOptions(
505
511
  // Ensure port is valid and available
506
512
  let port = parsePort(command.port || '1234');
507
513
  let originalPort = port;
508
- if (command.name() === 'serve' || command.hmr) {
514
+ if (
515
+ !shouldUseProductionDefaults(command) &&
516
+ (command.name() === 'serve' || command.hmr)
517
+ ) {
509
518
  try {
510
519
  port = await getPort({port, host});
511
520
  } catch (err) {
@@ -542,7 +551,7 @@ async function normalizeOptions(
542
551
  }
543
552
 
544
553
  let hmrOptions = null;
545
- if (command.name() !== 'build' && command.hmr !== false) {
554
+ if (!shouldUseProductionDefaults(command) && command.hmr !== false) {
546
555
  let hmrport = command.hmrPort ? parsePort(command.hmrPort) : port;
547
556
  let hmrhost = command.hmrHost ? command.hmrHost : host;
548
557
 
@@ -571,7 +580,9 @@ async function normalizeOptions(
571
580
  });
572
581
  }
573
582
 
574
- let mode = command.name() === 'build' ? 'production' : 'development';
583
+ let mode = shouldUseProductionDefaults(command)
584
+ ? 'production'
585
+ : 'development';
575
586
 
576
587
  const normalizeIncludeExcludeList = (input?: string): string[] => {
577
588
  if (typeof input !== 'string') return [];