@stencil/core 2.17.2-0 → 2.17.4

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 (40) hide show
  1. package/cli/index.cjs +101 -68
  2. package/cli/index.d.ts +1 -1
  3. package/cli/index.js +101 -68
  4. package/cli/package.json +1 -1
  5. package/compiler/package.json +1 -1
  6. package/compiler/stencil.js +363 -63
  7. package/compiler/stencil.min.js +2 -2
  8. package/dependencies.json +1 -1
  9. package/dev-server/client/index.js +1 -1
  10. package/dev-server/client/package.json +1 -1
  11. package/dev-server/connector.html +2 -2
  12. package/dev-server/index.js +1 -1
  13. package/dev-server/package.json +1 -1
  14. package/dev-server/server-process.js +2 -2
  15. package/internal/app-data/package.json +1 -1
  16. package/internal/client/css-shim.js +1 -1
  17. package/internal/client/dom.js +1 -1
  18. package/internal/client/index.js +1 -1
  19. package/internal/client/package.json +1 -1
  20. package/internal/client/patch-browser.js +1 -1
  21. package/internal/client/patch-esm.js +1 -1
  22. package/internal/client/shadow-css.js +1 -1
  23. package/internal/hydrate/package.json +1 -1
  24. package/internal/package.json +1 -1
  25. package/internal/stencil-private.d.ts +12 -2
  26. package/internal/stencil-public-compiler.d.ts +1 -1
  27. package/internal/testing/package.json +1 -1
  28. package/mock-doc/index.cjs +16 -1
  29. package/mock-doc/index.d.ts +5 -0
  30. package/mock-doc/index.js +16 -1
  31. package/mock-doc/package.json +1 -1
  32. package/package.json +1 -1
  33. package/screenshot/package.json +1 -1
  34. package/sys/node/index.js +1 -1
  35. package/sys/node/package.json +1 -1
  36. package/sys/node/worker.js +1 -1
  37. package/testing/index.js +40 -29
  38. package/testing/jest/jest-config.d.ts +1 -1
  39. package/testing/mocks.d.ts +7 -6
  40. package/testing/package.json +1 -1
package/cli/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI (CommonJS) v2.17.2-0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI (CommonJS) v2.17.4 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  'use strict';
5
5
 
@@ -543,11 +543,12 @@ const createConfigFlags = (init = {}) => {
543
543
  /**
544
544
  * Parse command line arguments into a structured `ConfigFlags` object
545
545
  *
546
- * @param args an array of config flags
547
- * @param sys an optional compiler system
546
+ * @param args an array of CLI flags
547
+ * @param _sys an optional compiler system
548
548
  * @returns a structured ConfigFlags object
549
549
  */
550
- const parseFlags = (args, sys) => {
550
+ const parseFlags = (args, _sys) => {
551
+ // TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3)
551
552
  const flags = createConfigFlags();
552
553
  // cmd line has more priority over npm scripts cmd
553
554
  flags.args = Array.isArray(args) ? args.slice() : [];
@@ -555,24 +556,19 @@ const parseFlags = (args, sys) => {
555
556
  flags.task = flags.args[0];
556
557
  }
557
558
  parseArgs(flags, flags.args);
558
- if (sys && sys.name === 'node') {
559
- const envArgs = getNpmConfigEnvArgs(sys);
560
- parseArgs(flags, envArgs);
561
- envArgs.forEach((envArg) => {
562
- if (!flags.args.includes(envArg)) {
563
- flags.args.push(envArg);
564
- }
565
- });
566
- }
567
559
  if (flags.task != null) {
568
560
  const i = flags.args.indexOf(flags.task);
569
561
  if (i > -1) {
570
562
  flags.args.splice(i, 1);
571
563
  }
572
564
  }
573
- flags.unknownArgs = flags.args.filter((arg) => {
574
- return !flags.knownArgs.includes(arg);
575
- });
565
+ // to find unknown / unrecognized arguments we filter `args`, including only
566
+ // arguments whose normalized form is not found in `knownArgs`. `knownArgs`
567
+ // is populated during the call to `parseArgs` above. For arguments like
568
+ // `--foobar` the string `"--foobar"` will be added, while for more
569
+ // complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
570
+ // string `"--bizBoz"` will be added.
571
+ flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
576
572
  return flags;
577
573
  };
578
574
  /**
@@ -758,17 +754,17 @@ const getValue = (args, configCaseName) => {
758
754
  let matchingArg;
759
755
  args.forEach((arg, i) => {
760
756
  if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
761
- value = getEqualsValue(arg);
762
- matchingArg = arg;
757
+ // our argument was passed at the command-line in the format --argName=arg-value
758
+ [matchingArg, value] = parseEqualsArg(arg);
763
759
  }
764
760
  else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
761
+ // the next value in the array is assumed to be a value for this argument
765
762
  value = args[i + 1];
766
763
  matchingArg = arg;
767
764
  }
768
765
  else if (alias) {
769
766
  if (arg.startsWith(`-${alias}=`)) {
770
- value = getEqualsValue(arg);
771
- matchingArg = arg;
767
+ [matchingArg, value] = parseEqualsArg(arg);
772
768
  }
773
769
  else if (arg === `-${alias}`) {
774
770
  value = args[i + 1];
@@ -779,13 +775,42 @@ const getValue = (args, configCaseName) => {
779
775
  return { value, matchingArg };
780
776
  };
781
777
  /**
782
- * When a parameter is set in the format `--foobar=12` at the CLI (as opposed to
783
- * `--foobar 12`) we want to get the value after the `=` sign
778
+ * Parse an 'equals' argument, which is a CLI argument-value pair in the
779
+ * format `--foobar=12` (as opposed to a space-separated format like
780
+ * `--foobar 12`).
784
781
  *
785
- * @param commandArgument the arg in question
786
- * @returns the value after the `=`
782
+ * To parse this we split on the `=`, returning the first part as the argument
783
+ * name and the second part as the value. We join the value on `"="` in case
784
+ * there is another `"="` in the argument.
785
+ *
786
+ * This function is safe to call with any arg, and can therefore be used as
787
+ * an argument 'normalizer'. If CLI argument is not an 'equals' argument then
788
+ * the return value will be a tuple of the original argument and an empty
789
+ * string `""` for the value.
790
+ *
791
+ * In code terms, if you do:
792
+ *
793
+ * ```ts
794
+ * const [arg, value] = parseEqualsArg("--myArgument")
795
+ * ```
796
+ *
797
+ * Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
798
+ * you do:
799
+ *
800
+ *
801
+ * ```ts
802
+ * const [arg, value] = parseEqualsArg("--myArgument=myValue")
803
+ * ```
804
+ *
805
+ * Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
806
+ *
807
+ * @param arg the arg in question
808
+ * @returns a tuple containing the arg name and the value (if present)
787
809
  */
788
- const getEqualsValue = (commandArgument) => commandArgument.split('=').slice(1).join('=');
810
+ const parseEqualsArg = (arg) => {
811
+ const [originalArg, ...value] = arg.split('=');
812
+ return [originalArg, value.join('=')];
813
+ };
789
814
  /**
790
815
  * Small helper for getting type-system-level assurance that a `string` can be
791
816
  * narrowed to a `LogLevel`
@@ -800,27 +825,11 @@ const isLogLevel = (maybeLogLevel) =>
800
825
  //
801
826
  // see microsoft/TypeScript#31018 for some discussion of this
802
827
  LOG_LEVELS.includes(maybeLogLevel);
803
- const getNpmConfigEnvArgs = (sys) => {
804
- // process.env.npm_config_argv
805
- // {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
806
- let args = [];
807
- try {
808
- const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
809
- if (npmConfigArgs) {
810
- args = JSON.parse(npmConfigArgs).original;
811
- if (args[0] === 'run') {
812
- args = args.slice(2);
813
- }
814
- }
815
- }
816
- catch (e) { }
817
- return args;
818
- };
819
828
 
820
829
  const dependencies = [
821
830
  {
822
831
  name: "@stencil/core",
823
- version: "2.17.2-0",
832
+ version: "2.17.4",
824
833
  main: "compiler/stencil.js",
825
834
  resources: [
826
835
  "package.json",
@@ -928,6 +937,11 @@ const dependencies = [
928
937
  }
929
938
  ];
930
939
 
940
+ /**
941
+ * Attempt to find a Stencil configuration file on the file system
942
+ * @param opts the options needed to find the configuration file
943
+ * @returns the results of attempting to find a configuration file on disk
944
+ */
931
945
  const findConfig = async (opts) => {
932
946
  const sys = opts.sys;
933
947
  const cwd = sys.getCurrentDirectory();
@@ -939,7 +953,7 @@ const findConfig = async (opts) => {
939
953
  let configPath = opts.configPath;
940
954
  if (isString(configPath)) {
941
955
  if (!sys.platformPath.isAbsolute(configPath)) {
942
- // passed in a custom stencil config location
956
+ // passed in a custom stencil config location,
943
957
  // but it's relative, so prefix the cwd
944
958
  configPath = normalizePath(sys.platformPath.join(cwd, configPath));
945
959
  }
@@ -1316,6 +1330,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
1316
1330
  throw error;
1317
1331
  }
1318
1332
  }
1333
+ /**
1334
+ * Helper function to determine if a Stencil configuration builds an application.
1335
+ *
1336
+ * This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
1337
+ * contents of the project's `stencil.config.ts` file.
1338
+ *
1339
+ * @param config the configuration used by the Stencil project
1340
+ * @returns true if we believe the project generates an application, false otherwise
1341
+ */
1319
1342
  function hasAppTarget(config) {
1320
1343
  return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
1321
1344
  }
@@ -1323,7 +1346,15 @@ function isUsingYarn(sys) {
1323
1346
  var _a;
1324
1347
  return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
1325
1348
  }
1326
- async function getActiveTargets(config) {
1349
+ /**
1350
+ * Build a list of the different types of output targets used in a Stencil configuration.
1351
+ *
1352
+ * Duplicate entries will not be returned from the list
1353
+ *
1354
+ * @param config the configuration used by the Stencil project
1355
+ * @returns a unique list of output target types found in the Stencil configuration
1356
+ */
1357
+ function getActiveTargets(config) {
1327
1358
  const result = config.outputTargets.map((t) => t.type);
1328
1359
  return Array.from(new Set(result));
1329
1360
  }
@@ -1340,7 +1371,7 @@ async function getActiveTargets(config) {
1340
1371
  const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
1341
1372
  const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
1342
1373
  const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
1343
- const targets = await getActiveTargets(config);
1374
+ const targets = getActiveTargets(config);
1344
1375
  const yarn = isUsingYarn(sys);
1345
1376
  const stencil = coreCompiler.version || 'unknown';
1346
1377
  const system = `${sys.name} ${sys.version}`;
@@ -1403,14 +1434,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
1403
1434
  * @returns an anonymized copy of the same config
1404
1435
  */
1405
1436
  const anonymizeConfigForTelemetry = (config) => {
1406
- var _a;
1407
1437
  const anonymizedConfig = { ...config };
1408
1438
  for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
1409
1439
  if (anonymizedConfig[prop] !== undefined) {
1410
1440
  anonymizedConfig[prop] = 'omitted';
1411
1441
  }
1412
1442
  }
1413
- anonymizedConfig.outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).map((target) => {
1443
+ anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
1414
1444
  // Anonymize the outputTargets on our configuration, taking advantage of the
1415
1445
  // optional 2nd argument to `JSON.stringify`. If anything is not a string
1416
1446
  // we retain it so that any nested properties are handled, else we check
@@ -1631,7 +1661,7 @@ function getMajorVersion(version) {
1631
1661
  return parts[0];
1632
1662
  }
1633
1663
 
1634
- const taskBuild = async (coreCompiler, config, sys) => {
1664
+ const taskBuild = async (coreCompiler, config) => {
1635
1665
  if (config.flags.watch) {
1636
1666
  // watch build
1637
1667
  await taskWatch(coreCompiler, config);
@@ -1644,10 +1674,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
1644
1674
  const versionChecker = startCheckVersion(config, coreCompiler.version);
1645
1675
  const compiler = await coreCompiler.createCompiler(config);
1646
1676
  const results = await compiler.build();
1647
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1648
- if (sys) {
1649
- await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
1650
- }
1677
+ await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
1651
1678
  await compiler.destroy();
1652
1679
  if (results.hasError) {
1653
1680
  exitCode = 1;
@@ -2013,10 +2040,7 @@ const taskHelp = async (flags, logger, sys) => {
2013
2040
  ${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
2014
2041
 
2015
2042
  `);
2016
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2017
- if (sys) {
2018
- await taskTelemetry(flags, sys, logger);
2019
- }
2043
+ await taskTelemetry(flags, sys, logger);
2020
2044
  console.log(`
2021
2045
  ${logger.bold('Examples:')}
2022
2046
 
@@ -2214,7 +2238,7 @@ const BLUE = `#3498db`;
2214
2238
  const run = async (init) => {
2215
2239
  const { args, logger, sys } = init;
2216
2240
  try {
2217
- const flags = parseFlags(args, sys);
2241
+ const flags = parseFlags(args);
2218
2242
  const task = flags.task;
2219
2243
  if (flags.debug || flags.verbose) {
2220
2244
  logger.setLevel('debug');
@@ -2252,9 +2276,7 @@ const run = async (init) => {
2252
2276
  startupLogVersion(logger, task, coreCompiler);
2253
2277
  loadedCompilerLog(sys, logger, flags, coreCompiler);
2254
2278
  if (task === 'info') {
2255
- await telemetryAction(sys, { flags: createConfigFlags({ task: 'info' }), logger }, coreCompiler, async () => {
2256
- await taskInfo(coreCompiler, sys, logger);
2257
- });
2279
+ taskInfo(coreCompiler, sys, logger);
2258
2280
  return;
2259
2281
  }
2260
2282
  const validated = await coreCompiler.loadConfig({
@@ -2287,14 +2309,28 @@ const run = async (init) => {
2287
2309
  }
2288
2310
  }
2289
2311
  };
2312
+ /**
2313
+ * Run a specified task
2314
+ * @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
2315
+ * @param config a configuration for the Stencil project to apply to the task run
2316
+ * @param task the task to run
2317
+ * @param sys the {@link CompilerSystem} for interacting with the operating system
2318
+ * @public
2319
+ */
2290
2320
  const runTask = async (coreCompiler, config, task, sys) => {
2291
- var _a, _b;
2321
+ var _a, _b, _c, _d, _e;
2292
2322
  const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
2293
- const strictConfig = { ...config, flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }), logger };
2294
- strictConfig.outputTargets = strictConfig.outputTargets || [];
2323
+ const strictConfig = {
2324
+ ...config,
2325
+ flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
2326
+ logger,
2327
+ outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
2328
+ sys: (_d = sys !== null && sys !== void 0 ? sys : config.sys) !== null && _d !== void 0 ? _d : coreCompiler.createSystem({ logger }),
2329
+ testing: (_e = config.testing) !== null && _e !== void 0 ? _e : {},
2330
+ };
2295
2331
  switch (task) {
2296
2332
  case 'build':
2297
- await taskBuild(coreCompiler, strictConfig, sys);
2333
+ await taskBuild(coreCompiler, strictConfig);
2298
2334
  break;
2299
2335
  case 'docs':
2300
2336
  await taskDocs(coreCompiler, strictConfig);
@@ -2313,10 +2349,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
2313
2349
  await taskServe(strictConfig);
2314
2350
  break;
2315
2351
  case 'telemetry':
2316
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2317
- if (sys) {
2318
- await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2319
- }
2352
+ await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2320
2353
  break;
2321
2354
  case 'test':
2322
2355
  await taskTest(strictConfig);
package/cli/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export declare function run(init: CliInitOptions): Promise<void>;
12
12
  * @param task The task command to run, such as `build`.
13
13
  */
14
14
  export declare function runTask(coreCompiler: any, config: Config, task: TaskCommand): Promise<void>;
15
- export declare function parseFlags(args: string[], sys?: CompilerSystem): ConfigFlags;
15
+ export declare function parseFlags(args: string[], _sys?: CompilerSystem): ConfigFlags;
16
16
  export { CompilerSystem, Config, ConfigFlags, Logger, TaskCommand };
package/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil CLI v2.17.2-0 | MIT Licensed | https://stenciljs.com
2
+ Stencil CLI v2.17.4 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  /**
5
5
  * This sets the log level hierarchy for our terminal logger, ranging from
@@ -519,11 +519,12 @@ const createConfigFlags = (init = {}) => {
519
519
  /**
520
520
  * Parse command line arguments into a structured `ConfigFlags` object
521
521
  *
522
- * @param args an array of config flags
523
- * @param sys an optional compiler system
522
+ * @param args an array of CLI flags
523
+ * @param _sys an optional compiler system
524
524
  * @returns a structured ConfigFlags object
525
525
  */
526
- const parseFlags = (args, sys) => {
526
+ const parseFlags = (args, _sys) => {
527
+ // TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3)
527
528
  const flags = createConfigFlags();
528
529
  // cmd line has more priority over npm scripts cmd
529
530
  flags.args = Array.isArray(args) ? args.slice() : [];
@@ -531,24 +532,19 @@ const parseFlags = (args, sys) => {
531
532
  flags.task = flags.args[0];
532
533
  }
533
534
  parseArgs(flags, flags.args);
534
- if (sys && sys.name === 'node') {
535
- const envArgs = getNpmConfigEnvArgs(sys);
536
- parseArgs(flags, envArgs);
537
- envArgs.forEach((envArg) => {
538
- if (!flags.args.includes(envArg)) {
539
- flags.args.push(envArg);
540
- }
541
- });
542
- }
543
535
  if (flags.task != null) {
544
536
  const i = flags.args.indexOf(flags.task);
545
537
  if (i > -1) {
546
538
  flags.args.splice(i, 1);
547
539
  }
548
540
  }
549
- flags.unknownArgs = flags.args.filter((arg) => {
550
- return !flags.knownArgs.includes(arg);
551
- });
541
+ // to find unknown / unrecognized arguments we filter `args`, including only
542
+ // arguments whose normalized form is not found in `knownArgs`. `knownArgs`
543
+ // is populated during the call to `parseArgs` above. For arguments like
544
+ // `--foobar` the string `"--foobar"` will be added, while for more
545
+ // complicated arguments like `--bizBoz=bop` or `--bizBoz bop` just the
546
+ // string `"--bizBoz"` will be added.
547
+ flags.unknownArgs = flags.args.filter((arg) => !flags.knownArgs.includes(parseEqualsArg(arg)[0]));
552
548
  return flags;
553
549
  };
554
550
  /**
@@ -734,17 +730,17 @@ const getValue = (args, configCaseName) => {
734
730
  let matchingArg;
735
731
  args.forEach((arg, i) => {
736
732
  if (arg.startsWith(`--${dashCaseName}=`) || arg.startsWith(`--${configCaseName}=`)) {
737
- value = getEqualsValue(arg);
738
- matchingArg = arg;
733
+ // our argument was passed at the command-line in the format --argName=arg-value
734
+ [matchingArg, value] = parseEqualsArg(arg);
739
735
  }
740
736
  else if (arg === `--${dashCaseName}` || arg === `--${configCaseName}`) {
737
+ // the next value in the array is assumed to be a value for this argument
741
738
  value = args[i + 1];
742
739
  matchingArg = arg;
743
740
  }
744
741
  else if (alias) {
745
742
  if (arg.startsWith(`-${alias}=`)) {
746
- value = getEqualsValue(arg);
747
- matchingArg = arg;
743
+ [matchingArg, value] = parseEqualsArg(arg);
748
744
  }
749
745
  else if (arg === `-${alias}`) {
750
746
  value = args[i + 1];
@@ -755,13 +751,42 @@ const getValue = (args, configCaseName) => {
755
751
  return { value, matchingArg };
756
752
  };
757
753
  /**
758
- * When a parameter is set in the format `--foobar=12` at the CLI (as opposed to
759
- * `--foobar 12`) we want to get the value after the `=` sign
754
+ * Parse an 'equals' argument, which is a CLI argument-value pair in the
755
+ * format `--foobar=12` (as opposed to a space-separated format like
756
+ * `--foobar 12`).
760
757
  *
761
- * @param commandArgument the arg in question
762
- * @returns the value after the `=`
758
+ * To parse this we split on the `=`, returning the first part as the argument
759
+ * name and the second part as the value. We join the value on `"="` in case
760
+ * there is another `"="` in the argument.
761
+ *
762
+ * This function is safe to call with any arg, and can therefore be used as
763
+ * an argument 'normalizer'. If CLI argument is not an 'equals' argument then
764
+ * the return value will be a tuple of the original argument and an empty
765
+ * string `""` for the value.
766
+ *
767
+ * In code terms, if you do:
768
+ *
769
+ * ```ts
770
+ * const [arg, value] = parseEqualsArg("--myArgument")
771
+ * ```
772
+ *
773
+ * Then `arg` will be `"--myArgument"` and `value` will be `""`, whereas if
774
+ * you do:
775
+ *
776
+ *
777
+ * ```ts
778
+ * const [arg, value] = parseEqualsArg("--myArgument=myValue")
779
+ * ```
780
+ *
781
+ * Then `arg` will be `"--myArgument"` and `value` will be `"myValue"`.
782
+ *
783
+ * @param arg the arg in question
784
+ * @returns a tuple containing the arg name and the value (if present)
763
785
  */
764
- const getEqualsValue = (commandArgument) => commandArgument.split('=').slice(1).join('=');
786
+ const parseEqualsArg = (arg) => {
787
+ const [originalArg, ...value] = arg.split('=');
788
+ return [originalArg, value.join('=')];
789
+ };
765
790
  /**
766
791
  * Small helper for getting type-system-level assurance that a `string` can be
767
792
  * narrowed to a `LogLevel`
@@ -776,27 +801,11 @@ const isLogLevel = (maybeLogLevel) =>
776
801
  //
777
802
  // see microsoft/TypeScript#31018 for some discussion of this
778
803
  LOG_LEVELS.includes(maybeLogLevel);
779
- const getNpmConfigEnvArgs = (sys) => {
780
- // process.env.npm_config_argv
781
- // {"remain":["4444"],"cooked":["run","serve","--port","4444"],"original":["run","serve","--port","4444"]}
782
- let args = [];
783
- try {
784
- const npmConfigArgs = sys.getEnvironmentVar('npm_config_argv');
785
- if (npmConfigArgs) {
786
- args = JSON.parse(npmConfigArgs).original;
787
- if (args[0] === 'run') {
788
- args = args.slice(2);
789
- }
790
- }
791
- }
792
- catch (e) { }
793
- return args;
794
- };
795
804
 
796
805
  const dependencies = [
797
806
  {
798
807
  name: "@stencil/core",
799
- version: "2.17.2-0",
808
+ version: "2.17.4",
800
809
  main: "compiler/stencil.js",
801
810
  resources: [
802
811
  "package.json",
@@ -904,6 +913,11 @@ const dependencies = [
904
913
  }
905
914
  ];
906
915
 
916
+ /**
917
+ * Attempt to find a Stencil configuration file on the file system
918
+ * @param opts the options needed to find the configuration file
919
+ * @returns the results of attempting to find a configuration file on disk
920
+ */
907
921
  const findConfig = async (opts) => {
908
922
  const sys = opts.sys;
909
923
  const cwd = sys.getCurrentDirectory();
@@ -915,7 +929,7 @@ const findConfig = async (opts) => {
915
929
  let configPath = opts.configPath;
916
930
  if (isString(configPath)) {
917
931
  if (!sys.platformPath.isAbsolute(configPath)) {
918
- // passed in a custom stencil config location
932
+ // passed in a custom stencil config location,
919
933
  // but it's relative, so prefix the cwd
920
934
  configPath = normalizePath(sys.platformPath.join(cwd, configPath));
921
935
  }
@@ -1292,6 +1306,15 @@ async function telemetryAction(sys, config, coreCompiler, action) {
1292
1306
  throw error;
1293
1307
  }
1294
1308
  }
1309
+ /**
1310
+ * Helper function to determine if a Stencil configuration builds an application.
1311
+ *
1312
+ * This function is a rough approximation whether an application is generated as a part of a Stencil build, based on
1313
+ * contents of the project's `stencil.config.ts` file.
1314
+ *
1315
+ * @param config the configuration used by the Stencil project
1316
+ * @returns true if we believe the project generates an application, false otherwise
1317
+ */
1295
1318
  function hasAppTarget(config) {
1296
1319
  return config.outputTargets.some((target) => target.type === WWW && (!!target.serviceWorker || (!!target.baseUrl && target.baseUrl !== '/')));
1297
1320
  }
@@ -1299,7 +1322,15 @@ function isUsingYarn(sys) {
1299
1322
  var _a;
1300
1323
  return ((_a = sys.getEnvironmentVar('npm_execpath')) === null || _a === void 0 ? void 0 : _a.includes('yarn')) || false;
1301
1324
  }
1302
- async function getActiveTargets(config) {
1325
+ /**
1326
+ * Build a list of the different types of output targets used in a Stencil configuration.
1327
+ *
1328
+ * Duplicate entries will not be returned from the list
1329
+ *
1330
+ * @param config the configuration used by the Stencil project
1331
+ * @returns a unique list of output target types found in the Stencil configuration
1332
+ */
1333
+ function getActiveTargets(config) {
1303
1334
  const result = config.outputTargets.map((t) => t.type);
1304
1335
  return Array.from(new Set(result));
1305
1336
  }
@@ -1316,7 +1347,7 @@ async function getActiveTargets(config) {
1316
1347
  const prepareData = async (coreCompiler, config, sys, duration_ms, component_count = undefined) => {
1317
1348
  const { typescript, rollup } = coreCompiler.versions || { typescript: 'unknown', rollup: 'unknown' };
1318
1349
  const { packages, packagesNoVersions } = await getInstalledPackages(sys, config);
1319
- const targets = await getActiveTargets(config);
1350
+ const targets = getActiveTargets(config);
1320
1351
  const yarn = isUsingYarn(sys);
1321
1352
  const stencil = coreCompiler.version || 'unknown';
1322
1353
  const system = `${sys.name} ${sys.version}`;
@@ -1379,14 +1410,13 @@ const CONFIG_PROPS_TO_DELETE = ['sys', 'logger', 'tsCompilerOptions', 'devServer
1379
1410
  * @returns an anonymized copy of the same config
1380
1411
  */
1381
1412
  const anonymizeConfigForTelemetry = (config) => {
1382
- var _a;
1383
1413
  const anonymizedConfig = { ...config };
1384
1414
  for (const prop of CONFIG_PROPS_TO_ANONYMIZE) {
1385
1415
  if (anonymizedConfig[prop] !== undefined) {
1386
1416
  anonymizedConfig[prop] = 'omitted';
1387
1417
  }
1388
1418
  }
1389
- anonymizedConfig.outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).map((target) => {
1419
+ anonymizedConfig.outputTargets = config.outputTargets.map((target) => {
1390
1420
  // Anonymize the outputTargets on our configuration, taking advantage of the
1391
1421
  // optional 2nd argument to `JSON.stringify`. If anything is not a string
1392
1422
  // we retain it so that any nested properties are handled, else we check
@@ -1607,7 +1637,7 @@ function getMajorVersion(version) {
1607
1637
  return parts[0];
1608
1638
  }
1609
1639
 
1610
- const taskBuild = async (coreCompiler, config, sys) => {
1640
+ const taskBuild = async (coreCompiler, config) => {
1611
1641
  if (config.flags.watch) {
1612
1642
  // watch build
1613
1643
  await taskWatch(coreCompiler, config);
@@ -1620,10 +1650,7 @@ const taskBuild = async (coreCompiler, config, sys) => {
1620
1650
  const versionChecker = startCheckVersion(config, coreCompiler.version);
1621
1651
  const compiler = await coreCompiler.createCompiler(config);
1622
1652
  const results = await compiler.build();
1623
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1624
- if (sys) {
1625
- await telemetryBuildFinishedAction(sys, config, coreCompiler, results);
1626
- }
1653
+ await telemetryBuildFinishedAction(config.sys, config, coreCompiler, results);
1627
1654
  await compiler.destroy();
1628
1655
  if (results.hasError) {
1629
1656
  exitCode = 1;
@@ -1989,10 +2016,7 @@ const taskHelp = async (flags, logger, sys) => {
1989
2016
  ${prompt} ${logger.green('stencil generate')} or ${logger.green('stencil g')}
1990
2017
 
1991
2018
  `);
1992
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
1993
- if (sys) {
1994
- await taskTelemetry(flags, sys, logger);
1995
- }
2019
+ await taskTelemetry(flags, sys, logger);
1996
2020
  console.log(`
1997
2021
  ${logger.bold('Examples:')}
1998
2022
 
@@ -2190,7 +2214,7 @@ const BLUE = `#3498db`;
2190
2214
  const run = async (init) => {
2191
2215
  const { args, logger, sys } = init;
2192
2216
  try {
2193
- const flags = parseFlags(args, sys);
2217
+ const flags = parseFlags(args);
2194
2218
  const task = flags.task;
2195
2219
  if (flags.debug || flags.verbose) {
2196
2220
  logger.setLevel('debug');
@@ -2228,9 +2252,7 @@ const run = async (init) => {
2228
2252
  startupLogVersion(logger, task, coreCompiler);
2229
2253
  loadedCompilerLog(sys, logger, flags, coreCompiler);
2230
2254
  if (task === 'info') {
2231
- await telemetryAction(sys, { flags: createConfigFlags({ task: 'info' }), logger }, coreCompiler, async () => {
2232
- await taskInfo(coreCompiler, sys, logger);
2233
- });
2255
+ taskInfo(coreCompiler, sys, logger);
2234
2256
  return;
2235
2257
  }
2236
2258
  const validated = await coreCompiler.loadConfig({
@@ -2263,14 +2285,28 @@ const run = async (init) => {
2263
2285
  }
2264
2286
  }
2265
2287
  };
2288
+ /**
2289
+ * Run a specified task
2290
+ * @param coreCompiler an instance of a minimal, bootstrap compiler for running the specified task
2291
+ * @param config a configuration for the Stencil project to apply to the task run
2292
+ * @param task the task to run
2293
+ * @param sys the {@link CompilerSystem} for interacting with the operating system
2294
+ * @public
2295
+ */
2266
2296
  const runTask = async (coreCompiler, config, task, sys) => {
2267
- var _a, _b;
2297
+ var _a, _b, _c, _d, _e;
2268
2298
  const logger = (_a = config.logger) !== null && _a !== void 0 ? _a : createLogger();
2269
- const strictConfig = { ...config, flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }), logger };
2270
- strictConfig.outputTargets = strictConfig.outputTargets || [];
2299
+ const strictConfig = {
2300
+ ...config,
2301
+ flags: createConfigFlags((_b = config.flags) !== null && _b !== void 0 ? _b : { task }),
2302
+ logger,
2303
+ outputTargets: (_c = config.outputTargets) !== null && _c !== void 0 ? _c : [],
2304
+ sys: (_d = sys !== null && sys !== void 0 ? sys : config.sys) !== null && _d !== void 0 ? _d : coreCompiler.createSystem({ logger }),
2305
+ testing: (_e = config.testing) !== null && _e !== void 0 ? _e : {},
2306
+ };
2271
2307
  switch (task) {
2272
2308
  case 'build':
2273
- await taskBuild(coreCompiler, strictConfig, sys);
2309
+ await taskBuild(coreCompiler, strictConfig);
2274
2310
  break;
2275
2311
  case 'docs':
2276
2312
  await taskDocs(coreCompiler, strictConfig);
@@ -2289,10 +2325,7 @@ const runTask = async (coreCompiler, config, task, sys) => {
2289
2325
  await taskServe(strictConfig);
2290
2326
  break;
2291
2327
  case 'telemetry':
2292
- // TODO(STENCIL-148) make this parameter no longer optional, remove the surrounding if statement
2293
- if (sys) {
2294
- await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2295
- }
2328
+ await taskTelemetry(strictConfig.flags, sys, strictConfig.logger);
2296
2329
  break;
2297
2330
  case 'test':
2298
2331
  await taskTest(strictConfig);
package/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/cli",
3
- "version": "2.17.2-0",
3
+ "version": "2.17.4",
4
4
  "description": "Stencil CLI.",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core/compiler",
3
- "version": "2.17.2-0",
3
+ "version": "2.17.4",
4
4
  "description": "Stencil Compiler.",
5
5
  "main": "./stencil.js",
6
6
  "types": "./stencil.d.ts",