@stencil/core 2.17.1 → 2.17.3

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/config-flags.d.ts +12 -4
  2. package/cli/index.cjs +110 -71
  3. package/cli/index.d.ts +1 -1
  4. package/cli/index.js +110 -71
  5. package/cli/package.json +1 -1
  6. package/compiler/package.json +1 -1
  7. package/compiler/stencil.js +343 -61
  8. package/compiler/stencil.min.js +2 -2
  9. package/dependencies.json +1 -1
  10. package/dev-server/client/index.js +1 -1
  11. package/dev-server/client/package.json +1 -1
  12. package/dev-server/connector.html +2 -2
  13. package/dev-server/index.js +1 -1
  14. package/dev-server/package.json +1 -1
  15. package/dev-server/server-process.js +2 -2
  16. package/internal/app-data/package.json +1 -1
  17. package/internal/client/css-shim.js +1 -1
  18. package/internal/client/dom.js +1 -1
  19. package/internal/client/index.js +1 -1
  20. package/internal/client/package.json +1 -1
  21. package/internal/client/patch-browser.js +1 -1
  22. package/internal/client/patch-esm.js +1 -1
  23. package/internal/client/shadow-css.js +1 -1
  24. package/internal/hydrate/package.json +1 -1
  25. package/internal/package.json +1 -1
  26. package/internal/stencil-private.d.ts +12 -2
  27. package/internal/stencil-public-compiler.d.ts +1 -1
  28. package/internal/testing/package.json +1 -1
  29. package/mock-doc/index.cjs +41 -3
  30. package/mock-doc/index.d.ts +15 -0
  31. package/mock-doc/index.js +41 -3
  32. package/mock-doc/package.json +1 -1
  33. package/package.json +1 -1
  34. package/screenshot/package.json +1 -1
  35. package/sys/node/index.js +1 -1
  36. package/sys/node/package.json +1 -1
  37. package/sys/node/worker.js +1 -1
  38. package/testing/index.js +37 -22
  39. package/testing/mocks.d.ts +7 -6
  40. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.17.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v2.17.3 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  (function(exports) {
5
5
  'use strict';
@@ -898,24 +898,37 @@ const buildWarn = (diagnostics) => {
898
898
  diagnostics.push(diagnostic);
899
899
  return diagnostic;
900
900
  };
901
- const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, pkgKey) => {
901
+ /**
902
+ * Create a diagnostic message suited for representing an error in a JSON
903
+ * file. This includes information about the exact lines in the JSON file which
904
+ * caused the error and the path to the file.
905
+ *
906
+ * @param compilerCtx the current compiler context
907
+ * @param diagnostics a list of diagnostics used as a return param
908
+ * @param jsonFilePath the path to the JSON file where the error occurred
909
+ * @param msg the error message
910
+ * @param jsonField the key for the field which caused the error, used for finding
911
+ * the error line in the original JSON file
912
+ * @returns a reference to the newly-created diagnostic
913
+ */
914
+ const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
902
915
  const err = buildError(diagnostics);
903
916
  err.messageText = msg;
904
917
  err.absFilePath = jsonFilePath;
905
- if (typeof pkgKey === 'string') {
918
+ if (typeof jsonField === 'string') {
906
919
  try {
907
920
  const jsonStr = compilerCtx.fs.readFileSync(jsonFilePath);
908
921
  const lines = jsonStr.replace(/\r/g, '\n').split('\n');
909
922
  for (let i = 0; i < lines.length; i++) {
910
923
  const txtLine = lines[i];
911
- const txtIndex = txtLine.indexOf(pkgKey);
924
+ const txtIndex = txtLine.indexOf(jsonField);
912
925
  if (txtIndex > -1) {
913
926
  const warnLine = {
914
927
  lineIndex: i,
915
928
  lineNumber: i + 1,
916
929
  text: txtLine,
917
930
  errorCharStart: txtIndex,
918
- errorLength: pkgKey.length,
931
+ errorLength: jsonField.length,
919
932
  };
920
933
  err.lineNumber = warnLine.lineNumber;
921
934
  err.columnNumber = txtIndex + 1;
@@ -4052,7 +4065,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
4052
4065
  };
4053
4066
  };
4054
4067
 
4055
- const buildId = '20220711170106';
4068
+ const buildId = '20220802224219';
4056
4069
  const minfyJsId = 'terser5.6.1_7';
4057
4070
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.13_7';
4058
4071
  const parse5Version = '6.0.1';
@@ -4060,8 +4073,8 @@ const rollupVersion = '2.42.3';
4060
4073
  const sizzleVersion = '2.42.3';
4061
4074
  const terserVersion = '5.6.1';
4062
4075
  const typescriptVersion = '4.5.4';
4063
- const vermoji = '😊';
4064
- const version$3 = '2.17.1';
4076
+ const vermoji = '🌭';
4077
+ const version$3 = '2.17.3';
4065
4078
  const versions = {
4066
4079
  stencil: version$3,
4067
4080
  parse5: parse5Version,
@@ -14939,6 +14952,25 @@ class MockMouseEvent extends MockEvent {
14939
14952
  }
14940
14953
  }
14941
14954
  }
14955
+ class MockUIEvent extends MockEvent {
14956
+ constructor(type, uiEventInitDic) {
14957
+ super(type);
14958
+ this.detail = null;
14959
+ this.view = null;
14960
+ if (uiEventInitDic != null) {
14961
+ Object.assign(this, uiEventInitDic);
14962
+ }
14963
+ }
14964
+ }
14965
+ class MockFocusEvent extends MockUIEvent {
14966
+ constructor(type, focusEventInitDic) {
14967
+ super(type);
14968
+ this.relatedTarget = null;
14969
+ if (focusEventInitDic != null) {
14970
+ Object.assign(this, focusEventInitDic);
14971
+ }
14972
+ }
14973
+ }
14942
14974
  class MockEventListener {
14943
14975
  constructor(type, handler) {
14944
14976
  this.type = type;
@@ -15852,7 +15884,7 @@ class MockElement extends MockNode {
15852
15884
  return shadowRoot;
15853
15885
  }
15854
15886
  blur() {
15855
- /**/
15887
+ dispatchEvent(this, new MockFocusEvent('blur', { relatedTarget: null, bubbles: true, cancelable: true, composed: true }));
15856
15888
  }
15857
15889
  get shadowRoot() {
15858
15890
  return this.__shadowRoot || null;
@@ -15922,7 +15954,9 @@ class MockElement extends MockNode {
15922
15954
  get firstElementChild() {
15923
15955
  return this.children[0] || null;
15924
15956
  }
15925
- focus(_options) { }
15957
+ focus(_options) {
15958
+ dispatchEvent(this, new MockFocusEvent('focus', { relatedTarget: null, bubbles: true, cancelable: true, composed: true }));
15959
+ }
15926
15960
  getAttribute(attrName) {
15927
15961
  if (attrName === 'style') {
15928
15962
  if (this.__style != null && this.__style.length > 0) {
@@ -16267,6 +16301,9 @@ class MockElement extends MockNode {
16267
16301
  set title(value) {
16268
16302
  this.setAttributeNS(null, 'title', value);
16269
16303
  }
16304
+ animate() {
16305
+ /**/
16306
+ }
16270
16307
  onanimationstart() {
16271
16308
  /**/
16272
16309
  }
@@ -16531,6 +16568,18 @@ class MockElement extends MockNode {
16531
16568
  onwheel() {
16532
16569
  /**/
16533
16570
  }
16571
+ requestFullscreen() {
16572
+ /**/
16573
+ }
16574
+ scrollBy() {
16575
+ /**/
16576
+ }
16577
+ scrollTo() {
16578
+ /**/
16579
+ }
16580
+ scrollIntoView() {
16581
+ /**/
16582
+ }
16534
16583
  toString(opts) {
16535
16584
  return serializeNodeToHtml(this, opts);
16536
16585
  }
@@ -17572,6 +17621,7 @@ const GLOBAL_CONSTRUCTORS = [
17572
17621
  ['CustomEvent', MockCustomEvent],
17573
17622
  ['Event', MockEvent],
17574
17623
  ['Headers', MockHeaders],
17624
+ ['FocusEvent', MockFocusEvent],
17575
17625
  ['KeyboardEvent', MockKeyboardEvent],
17576
17626
  ['MouseEvent', MockMouseEvent],
17577
17627
  ['Request', MockRequest],
@@ -54587,6 +54637,23 @@ const isMemberPrivate = (member) => {
54587
54637
  }
54588
54638
  return false;
54589
54639
  };
54640
+ /**
54641
+ * Convert a JavaScript value to the TypeScript Intermediate Representation
54642
+ * (IR) for a literal Abstract Syntax Tree (AST) node with that same value. The
54643
+ * value to convert may be a primitive type like `string`, `boolean`, etc or
54644
+ * may be an `Object`, `Array`, etc.
54645
+ *
54646
+ * Note that this function takes a param (`refs`) with a default value,
54647
+ * normally a value should _not_ be passed for this parameter since it is
54648
+ * intended to be used for recursive calls.
54649
+ *
54650
+ * @param val the value to convert
54651
+ * @param refs a set of references, used in recursive calls to avoid
54652
+ * circular references when creating object literal IR instances. **note that
54653
+ * you shouldn't pass this parameter unless you know what you're doing!**
54654
+ * @returns TypeScript IR for a literal corresponding to the JavaScript value
54655
+ * with which the function was called
54656
+ */
54590
54657
  const convertValueToLiteral = (val, refs = null) => {
54591
54658
  if (refs == null) {
54592
54659
  refs = new WeakSet();
@@ -54617,12 +54684,39 @@ const convertValueToLiteral = (val, refs = null) => {
54617
54684
  }
54618
54685
  return t.createLiteral(val);
54619
54686
  };
54687
+ /**
54688
+ * Convert a JavaScript Array instance to TypeScript's Intermediate
54689
+ * Representation (IR) for an array literal. This is done by recursively using
54690
+ * {@link convertValueToLiteral} to create a new array consisting of the
54691
+ * TypeScript IR of each element in the array to be converted, and then creating
54692
+ * the TypeScript IR for _that_ array.
54693
+ *
54694
+ * @param list the array instance to convert
54695
+ * @param refs a set of references to objects, used when converting objects to
54696
+ * avoid circular references
54697
+ * @returns TypeScript IR for the array we want to convert
54698
+ */
54620
54699
  const arrayToArrayLiteral = (list, refs) => {
54621
54700
  const newList = list.map((l) => {
54622
54701
  return convertValueToLiteral(l, refs);
54623
54702
  });
54624
54703
  return t.createArrayLiteral(newList);
54625
54704
  };
54705
+ /**
54706
+ * Convert a JavaScript object (i.e. an object existing at runtime) to the
54707
+ * corresponding TypeScript Intermediate Representation (IR)
54708
+ * ({@see ts.ObjectLiteralExpression}) for an object literal. This function
54709
+ * takes an argument holding a `WeakSet` of references to objects which is
54710
+ * used to avoid circular references. Objects that are converted in this
54711
+ * function are added to the set, and if an object is already present then an
54712
+ * `undefined` literal (in TypeScript IR) is returned instead of another
54713
+ * object literal, as continuing to convert a circular reference would, well,
54714
+ * never end!
54715
+ *
54716
+ * @param obj the JavaScript object to convert to TypeScript IR
54717
+ * @param refs a set of references to objects, used to avoid circular references
54718
+ * @returns a TypeScript object literal expression
54719
+ */
54626
54720
  const objectToObjectLiteral = (obj, refs) => {
54627
54721
  if (refs.has(obj)) {
54628
54722
  return t.createIdentifier('undefined');
@@ -55990,17 +56084,16 @@ const KEEP_IMPORTS = new Set([
55990
56084
  * which do actual work of generating the rollup configuration, creating an
55991
56085
  * entry chunk, running, the build, etc.
55992
56086
  *
55993
- * @param config the user-supplied compiler configuration we're using
56087
+ * @param config the validated compiler configuration we're using
55994
56088
  * @param compilerCtx the current compiler context
55995
56089
  * @param buildCtx the current build context
55996
56090
  * @returns an empty Promise which won't resolve until the work is done!
55997
56091
  */
55998
56092
  const outputCustomElements = async (config, compilerCtx, buildCtx) => {
55999
- var _a;
56000
56093
  if (!config.buildDist) {
56001
56094
  return;
56002
56095
  }
56003
- const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
56096
+ const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
56004
56097
  if (outputTargets.length === 0) {
56005
56098
  return;
56006
56099
  }
@@ -56013,7 +56106,7 @@ const outputCustomElements = async (config, compilerCtx, buildCtx) => {
56013
56106
  * Get bundle options for our current build and compiler context which we'll use
56014
56107
  * to generate a Rollup build and so on.
56015
56108
  *
56016
- * @param config user-supplied Stencil configuration
56109
+ * @param config a validated Stencil configuration object
56017
56110
  * @param buildCtx the current build context
56018
56111
  * @param compilerCtx the current compiler context
56019
56112
  * @param outputTarget the outputTarget we're currently dealing with
@@ -56044,9 +56137,10 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
56044
56137
  /**
56045
56138
  * Get bundle options for rollup, run the rollup build, optionally minify the
56046
56139
  * output, and write files to disk.
56047
- * @param config user-supplied Stencil configuration
56048
- * @param buildCtx the current build context
56140
+ *
56141
+ * @param config the validated Stencil configuration we're using
56049
56142
  * @param compilerCtx the current compiler context
56143
+ * @param buildCtx the current build context
56050
56144
  * @param outputTarget the outputTarget we're currently dealing with
56051
56145
  * @returns an empty promise
56052
56146
  */
@@ -56135,7 +56229,7 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
56135
56229
  exp.push(`import { ${importName} as ${importAs}, defineCustomElement as cmpDefCustomEle } from '${cmp.sourceFilePath}';`);
56136
56230
  exp.push(`export const ${exportName} = ${importAs};`);
56137
56231
  exp.push(`export const defineCustomElement = cmpDefCustomEle;`);
56138
- // Here we push an export (with a rename for `defineCustomElement` for
56232
+ // Here we push an export (with a rename for `defineCustomElement`) for
56139
56233
  // this component onto our array which references the `coreKey` (prefixed
56140
56234
  // with `\0`). We have to do this so that our import is referencing the
56141
56235
  // correct virtual module, if we instead referenced, for instance,
@@ -60170,8 +60264,7 @@ const relDts$1 = (fromPath, dtsPath) => {
60170
60264
  * @param typesDir the path to the directory where type declarations are saved
60171
60265
  */
60172
60266
  const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesDir) => {
60173
- var _a;
60174
- const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
60267
+ const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
60175
60268
  await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, typesDir, outputTarget)));
60176
60269
  };
60177
60270
  /**
@@ -60187,7 +60280,7 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
60187
60280
  // the path where we're going to write the typedef for the whole dist-custom-elements output
60188
60281
  const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
60189
60282
  // the directory where types for the individual components are written
60190
- const componentsTypeDirectoryPath = relative$1(outputTarget.dir, join(typesDir, 'components'));
60283
+ const componentsTypeDirectoryRelPath = relative$1(outputTarget.dir, typesDir);
60191
60284
  const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
60192
60285
  const code = [
60193
60286
  `/* ${config.namespace} custom elements */`,
@@ -60196,7 +60289,14 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
60196
60289
  const importName = component.componentClassName;
60197
60290
  // typedefs for individual components can be found under paths like
60198
60291
  // $TYPES_DIR/components/my-component/my-component.d.ts
60199
- const componentDTSPath = join(componentsTypeDirectoryPath, component.tagName, component.tagName);
60292
+ //
60293
+ // To construct this path we:
60294
+ //
60295
+ // - get the relative path to the component's source file from the source directory
60296
+ // - join that relative path to the relative path from the `index.d.ts` file to the
60297
+ // directory where typedefs are saved
60298
+ const componentSourceRelPath = relative$1(config.srcDir, component.sourceFilePath).replace('.tsx', '');
60299
+ const componentDTSPath = join(componentsTypeDirectoryRelPath, componentSourceRelPath);
60200
60300
  return `export { ${importName} as ${exportName} } from '${componentDTSPath}';`;
60201
60301
  }),
60202
60302
  ``,
@@ -62099,6 +62199,16 @@ const parseModuleImport = (config, compilerCtx, buildCtx, moduleFile, dirPath, i
62099
62199
  }
62100
62200
  };
62101
62201
 
62202
+ /**
62203
+ * Update an instance of TypeScript's Intermediate Representation (IR) for a
62204
+ * class declaration ({@link ts.ClassDeclaration}) with a static getter for the
62205
+ * compiler metadata that we produce as part of the compilation process.
62206
+ *
62207
+ * @param cmpNode an instance of the TypeScript IR for a class declaration (i.e.
62208
+ * a stencil component) to be updated
62209
+ * @param cmpMeta the component metadata corresponding to that component
62210
+ * @returns the updated typescript class declaration
62211
+ */
62102
62212
  const addComponentMetaStatic = (cmpNode, cmpMeta) => {
62103
62213
  const publicCompilerMeta = getPublicCompilerMeta(cmpMeta);
62104
62214
  const cmpMetaStaticProp = createStaticGetter('COMPILER_META', convertValueToLiteral(publicCompilerMeta));
@@ -62230,6 +62340,14 @@ const parseStaticEvents = (staticMembers) => {
62230
62340
  });
62231
62341
  };
62232
62342
 
62343
+ /**
62344
+ * Parse a list of {@link ts.ClassElement} objects representing static props
62345
+ * into a list of our own Intermediate Representation (IR) of properties on
62346
+ * components.
62347
+ *
62348
+ * @param staticMembers TypeScript IR for the properties on our component
62349
+ * @returns a manifest of compiler properties in our own Stencil IR
62350
+ */
62233
62351
  const parseStaticProps = (staticMembers) => {
62234
62352
  const parsedProps = getStaticValue(staticMembers, 'properties');
62235
62353
  if (!parsedProps) {
@@ -62466,7 +62584,22 @@ const setComponentBuildConditionals = (cmpMeta) => {
62466
62584
  !cmpMeta.hasMember && !cmpMeta.hasStyle && !cmpMeta.hasLifecycle && !cmpMeta.hasListener && !cmpMeta.hasVdomRender;
62467
62585
  };
62468
62586
 
62469
- const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile, nodeMap, transformOpts) => {
62587
+ /**
62588
+ * Given an instance of TypeScript's Intermediate Representation (IR) for a
62589
+ * class declaration ({@see ts.ClassDeclaration}) which represents a Stencil
62590
+ * component class declaration, parse and format various pieces of data about
62591
+ * static class members which we use in the compilation process
62592
+ *
62593
+ * @param compilerCtx the current compiler context
62594
+ * @param typeChecker a TypeScript type checker instance
62595
+ * @param cmpNode the TypeScript class declaration for the component
62596
+ * @param moduleFile Stencil's IR for a module, used here as an out param
62597
+ * @param transformOpts options which control various aspects of the
62598
+ * transformation
62599
+ * @returns the TypeScript class declaration IR instance with which the
62600
+ * function was called
62601
+ */
62602
+ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile, transformOpts) => {
62470
62603
  if (cmpNode.members == null) {
62471
62604
  return cmpNode;
62472
62605
  }
@@ -62583,7 +62716,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
62583
62716
  // add to module map
62584
62717
  moduleFile.cmps.push(cmp);
62585
62718
  // add to node map
62586
- nodeMap.set(cmpNode, cmp);
62719
+ compilerCtx.nodeMap.set(cmpNode, cmp);
62587
62720
  return cmpNode;
62588
62721
  };
62589
62722
  const parseVirtualProps = (docs) => {
@@ -62651,7 +62784,7 @@ const updateModule = (config, compilerCtx, buildCtx, tsSourceFile, sourceFileTex
62651
62784
  compilerCtx.changedModules.add(moduleFile.sourceFilePath);
62652
62785
  const visitNode = (node) => {
62653
62786
  if (t.isClassDeclaration(node)) {
62654
- parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile, compilerCtx.nodeMap);
62787
+ parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile);
62655
62788
  return;
62656
62789
  }
62657
62790
  else if (t.isImportDeclaration(node)) {
@@ -62812,6 +62945,15 @@ const outputServiceWorkers = async (config, buildCtx) => {
62812
62945
  }
62813
62946
  };
62814
62947
 
62948
+ /**
62949
+ * Validate the package.json file for a project, checking that various fields
62950
+ * are set correctly for the currently-configured output targets.
62951
+ *
62952
+ * @param config the user-supplied Stencil config
62953
+ * @param compilerCtx the compiler context
62954
+ * @param buildCtx the build context
62955
+ * @returns an empty Promise
62956
+ */
62815
62957
  const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
62816
62958
  if (config.watch) {
62817
62959
  return;
@@ -62819,26 +62961,41 @@ const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
62819
62961
  if (buildCtx.packageJson == null) {
62820
62962
  return;
62821
62963
  }
62822
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
62964
+ const distCollectionOutputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
62823
62965
  const typesOutputTargets = config.outputTargets.filter(isOutputTargetDistTypes);
62824
62966
  await Promise.all([
62825
- ...outputTargets.map((outputsTarget) => {
62826
- return validatePackageJsonOutput(config, compilerCtx, buildCtx, outputsTarget);
62827
- }),
62828
- ...typesOutputTargets.map((outputTarget) => {
62829
- return validateTypes(config, compilerCtx, buildCtx, outputTarget);
62830
- }),
62967
+ ...distCollectionOutputTargets.map((distCollectionOT) => validateDistCollectionPkgJson(config, compilerCtx, buildCtx, distCollectionOT)),
62968
+ ...typesOutputTargets.map((typesOT) => validateTypes(config, compilerCtx, buildCtx, typesOT)),
62969
+ validateModule(config, compilerCtx, buildCtx),
62831
62970
  ]);
62832
62971
  };
62833
- const validatePackageJsonOutput = async (config, compilerCtx, buildCtx, outputTarget) => {
62972
+ /**
62973
+ * Validate package.json contents for the `DIST_COLLECTION` output target,
62974
+ * checking that various fields like `files`, `main`, and so on are set
62975
+ * correctly.
62976
+ *
62977
+ * @param config the stencil config
62978
+ * @param compilerCtx the current compiler context
62979
+ * @param buildCtx the current build context
62980
+ * @param outputTarget a DIST_COLLECTION output target
62981
+ */
62982
+ const validateDistCollectionPkgJson = async (config, compilerCtx, buildCtx, outputTarget) => {
62834
62983
  await Promise.all([
62835
62984
  validatePackageFiles(config, compilerCtx, buildCtx, outputTarget),
62836
62985
  validateMain(config, compilerCtx, buildCtx, outputTarget),
62837
- validateModule(config, compilerCtx, buildCtx, outputTarget),
62838
62986
  validateCollection$1(config, compilerCtx, buildCtx, outputTarget),
62839
62987
  validateBrowser(config, compilerCtx, buildCtx),
62840
62988
  ]);
62841
62989
  };
62990
+ /**
62991
+ * Validate that the `files` field in `package.json` contains directories and
62992
+ * files that are necessary for the `DIST_COLLECTION` output target.
62993
+ *
62994
+ * @param config the stencil config
62995
+ * @param compilerCtx the current compiler context
62996
+ * @param buildCtx the current build context
62997
+ * @param outputTarget a DIST_COLLECTION output target
62998
+ */
62842
62999
  const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget) => {
62843
63000
  if (!config.devMode && Array.isArray(buildCtx.packageJson.files)) {
62844
63001
  const actualDistDir = normalizePath$1(relative$1(config.rootDir, outputTarget.dir));
@@ -62862,6 +63019,15 @@ const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget)
62862
63019
  }));
62863
63020
  }
62864
63021
  };
63022
+ /**
63023
+ * Check that the `main` field is set correctly in `package.json` for the
63024
+ * `DIST_COLLECTION` output target.
63025
+ *
63026
+ * @param config the stencil config
63027
+ * @param compilerCtx the current compiler context
63028
+ * @param buildCtx the current build context
63029
+ * @param outputTarget a DIST_COLLECTION output target
63030
+ */
62865
63031
  const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
62866
63032
  const mainAbs = join(outputTarget.dir, 'index.cjs.js');
62867
63033
  const mainRel = relative$1(config.rootDir, mainAbs);
@@ -62874,26 +63040,71 @@ const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
62874
63040
  packageJsonWarn(config, compilerCtx, buildCtx, msg, `"main"`);
62875
63041
  }
62876
63042
  };
62877
- const validateModule = (config, compilerCtx, buildCtx, outputTarget) => {
62878
- const customElementsOutput = config.outputTargets.find(isOutputTargetDistCustomElementsBundle);
63043
+ /**
63044
+ * Validate the package.json 'module' field, taking into account output targets
63045
+ * and other configuration details. This will look for a value for the `module`
63046
+ * field. If not present it will set a relevant warning message with an
63047
+ * output-target specific recommended value. If it is present and is not equal
63048
+ * to that recommended value it will set a different warning message.
63049
+ *
63050
+ * @param config the current user-supplied configuration
63051
+ * @param compilerCtx the compiler context
63052
+ * @param buildCtx the build context
63053
+ * @returns an empty Promise
63054
+ */
63055
+ const validateModule = async (config, compilerCtx, buildCtx) => {
62879
63056
  const currentModule = buildCtx.packageJson.module;
62880
- const distAbs = join(outputTarget.dir, 'index.js');
62881
- const distRel = relative$1(config.rootDir, distAbs);
62882
- let recommendedRelPath = distRel;
62883
- if (customElementsOutput) {
62884
- const customElementsAbs = join(customElementsOutput.dir, 'index.js');
62885
- recommendedRelPath = relative$1(config.rootDir, customElementsAbs);
62886
- }
63057
+ const recommendedRelPath = recommendedModulePath(config);
62887
63058
  if (!isString$1(currentModule)) {
62888
- const msg = `package.json "module" property is required when generating a distribution. It's recommended to set the "module" property to: ${recommendedRelPath}`;
63059
+ let msg = 'package.json "module" property is required when generating a distribution.';
63060
+ if (recommendedRelPath !== null) {
63061
+ msg += ` It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
63062
+ }
62889
63063
  packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
63064
+ return;
62890
63065
  }
62891
- else if (normalizePath$1(currentModule) !== normalizePath$1(recommendedRelPath) &&
62892
- normalizePath$1(currentModule) !== normalizePath$1(distRel)) {
62893
- const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${recommendedRelPath}`;
63066
+ if (recommendedRelPath !== null && normalizePath$1(recommendedRelPath) !== normalizePath$1(currentModule)) {
63067
+ const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
62894
63068
  packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
62895
63069
  }
62896
63070
  };
63071
+ // TODO(STENCIL-516): Investigate the hierarchy of these output targets
63072
+ /**
63073
+ * Get the recommended `"module"` path for `package.json` given the output
63074
+ * targets that a user has set on their config.
63075
+ *
63076
+ * @param config the user-supplied Stencil configuration
63077
+ * @returns a recommended module path or a null value to indicate no default
63078
+ * value is supplied
63079
+ */
63080
+ function recommendedModulePath(config) {
63081
+ const customElementsBundleOT = config.outputTargets.find(isOutputTargetDistCustomElementsBundle);
63082
+ const customElementsOT = config.outputTargets.find(isOutputTargetDistCustomElements);
63083
+ const distCollectionOT = config.outputTargets.find(isOutputTargetDistCollection);
63084
+ if (distCollectionOT) {
63085
+ return relative$1(config.rootDir, join(distCollectionOT.dir, 'index.js'));
63086
+ }
63087
+ if (customElementsOT) {
63088
+ const componentsIndexAbs = join(customElementsOT.dir, 'index.js');
63089
+ return relative$1(config.rootDir, componentsIndexAbs);
63090
+ }
63091
+ if (customElementsBundleOT) {
63092
+ const customElementsAbs = join(customElementsBundleOT.dir, 'index.js');
63093
+ return relative$1(config.rootDir, customElementsAbs);
63094
+ }
63095
+ // if no output target for which we define a recommended output target is set
63096
+ // we return `null`
63097
+ return null;
63098
+ }
63099
+ /**
63100
+ * Check that the `types` field is set correctly in `package.json` for the
63101
+ * `DIST_COLLECTION` output target.
63102
+ *
63103
+ * @param config the stencil config
63104
+ * @param compilerCtx the current compiler context
63105
+ * @param buildCtx the current build context
63106
+ * @param outputTarget a DIST_COLLECTION output target
63107
+ */
62897
63108
  const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
62898
63109
  const typesAbs = getComponentsDtsTypesFilePath(outputTarget);
62899
63110
  const recommendedPath = relative$1(config.rootDir, typesAbs);
@@ -62917,6 +63128,15 @@ const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
62917
63128
  }
62918
63129
  }
62919
63130
  };
63131
+ /**
63132
+ * Check that the `collection` field is set correctly in `package.json` for the
63133
+ * `DIST_COLLECTION` output target.
63134
+ *
63135
+ * @param config the stencil config
63136
+ * @param compilerCtx the current compiler context
63137
+ * @param buildCtx the current build context
63138
+ * @param outputTarget a DIST_COLLECTION output target
63139
+ */
62920
63140
  const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
62921
63141
  if (outputTarget.collectionDir) {
62922
63142
  const collectionRel = join(relative$1(config.rootDir, outputTarget.collectionDir), COLLECTION_MANIFEST_FILE_NAME);
@@ -62926,19 +63146,51 @@ const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
62926
63146
  }
62927
63147
  }
62928
63148
  };
63149
+ /**
63150
+ * Check that the `browser` field is set correctly in `package.json` for the
63151
+ * `DIST_COLLECTION` output target.
63152
+ *
63153
+ * @param config the stencil config
63154
+ * @param compilerCtx the current compiler context
63155
+ * @param buildCtx the current build context
63156
+ */
62929
63157
  const validateBrowser = (config, compilerCtx, buildCtx) => {
62930
63158
  if (isString$1(buildCtx.packageJson.browser)) {
62931
63159
  const msg = `package.json "browser" property is set to "${buildCtx.packageJson.browser}". However, for maximum compatibility with all bundlers it's recommended to not set the "browser" property and instead ensure both "module" and "main" properties are set.`;
62932
63160
  packageJsonWarn(config, compilerCtx, buildCtx, msg, `"browser"`);
62933
63161
  }
62934
63162
  };
62935
- const packageJsonError = (config, compilerCtx, buildCtx, msg, warnKey) => {
62936
- const err = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, warnKey);
63163
+ /**
63164
+ * Build a diagnostic for an error resulting from a particular field in a
63165
+ * package.json file
63166
+ *
63167
+ * @param config the stencil config
63168
+ * @param compilerCtx the current compiler context
63169
+ * @param buildCtx the current build context
63170
+ * @param msg an error string
63171
+ * @param jsonField the key for the field which caused the error, used for
63172
+ * finding the error line in the original JSON file
63173
+ * @returns a diagnostic object
63174
+ */
63175
+ const packageJsonError = (config, compilerCtx, buildCtx, msg, jsonField) => {
63176
+ const err = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
62937
63177
  err.header = `Package Json`;
62938
63178
  return err;
62939
63179
  };
62940
- const packageJsonWarn = (config, compilerCtx, buildCtx, msg, warnKey) => {
62941
- const warn = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, warnKey);
63180
+ /**
63181
+ * Build a diagnostic for a warning resulting from a particular field in a
63182
+ * package.json file
63183
+ *
63184
+ * @param config the stencil config
63185
+ * @param compilerCtx the current compiler context
63186
+ * @param buildCtx the current build context
63187
+ * @param msg an error string
63188
+ * @param jsonField the key for the field which caused the error, used for
63189
+ * finding the error line in the original JSON file
63190
+ * @returns a diagnostic object
63191
+ */
63192
+ const packageJsonWarn = (config, compilerCtx, buildCtx, msg, jsonField) => {
63193
+ const warn = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
62942
63194
  warn.header = `Package Json`;
62943
63195
  warn.level = 'warn';
62944
63196
  return warn;
@@ -64397,14 +64649,37 @@ const updateCompilerCtxCache = (config, compilerCtx, path, kind) => {
64397
64649
  }
64398
64650
  };
64399
64651
 
64652
+ /**
64653
+ * All the Boolean options supported by the Stencil CLI
64654
+ */
64655
+ /**
64656
+ * Helper function for initializing a `ConfigFlags` object. Provide any overrides
64657
+ * for default values and off you go!
64658
+ *
64659
+ * @param init an object with any overrides for default values
64660
+ * @returns a complete CLI flag object
64661
+ */
64662
+ const createConfigFlags = (init = {}) => {
64663
+ const flags = {
64664
+ task: null,
64665
+ args: [],
64666
+ knownArgs: [],
64667
+ unknownArgs: [],
64668
+ ...init,
64669
+ };
64670
+ return flags;
64671
+ };
64672
+
64400
64673
  const getConfig = (userConfig) => {
64401
- var _a, _b;
64402
- const flags = (_a = userConfig.flags) !== null && _a !== void 0 ? _a : {};
64403
- const logger = (_b = userConfig.logger) !== null && _b !== void 0 ? _b : createLogger();
64404
- const config = { ...userConfig, flags, logger };
64405
- if (!config.sys) {
64406
- config.sys = createSystem({ logger: config.logger });
64407
- }
64674
+ var _a, _b, _c, _d;
64675
+ const logger = (_a = userConfig.logger) !== null && _a !== void 0 ? _a : createLogger();
64676
+ const config = {
64677
+ ...userConfig,
64678
+ flags: createConfigFlags((_b = userConfig.flags) !== null && _b !== void 0 ? _b : {}),
64679
+ logger,
64680
+ outputTargets: (_c = userConfig.outputTargets) !== null && _c !== void 0 ? _c : [],
64681
+ sys: (_d = userConfig.sys) !== null && _d !== void 0 ? _d : createSystem({ logger }),
64682
+ };
64408
64683
  setPlatformPath(config.sys.platformPath);
64409
64684
  if (config.flags.debug || config.flags.verbose) {
64410
64685
  config.logLevel = 'debug';
@@ -65110,7 +65385,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
65110
65385
  const dependencies = [
65111
65386
  {
65112
65387
  name: "@stencil/core",
65113
- version: "2.17.1",
65388
+ version: "2.17.3",
65114
65389
  main: "compiler/stencil.js",
65115
65390
  resources: [
65116
65391
  "package.json",
@@ -66463,7 +66738,8 @@ const validateWorkers = (config) => {
66463
66738
  * @returns an object with config and diagnostics props
66464
66739
  */
66465
66740
  const validateConfig = (userConfig = {}, bootstrapConfig) => {
66466
- const config = Object.assign({}, userConfig || {}); // not positive it's json safe
66741
+ var _a, _b, _c;
66742
+ const config = Object.assign({}, userConfig); // not positive it's json safe
66467
66743
  const diagnostics = [];
66468
66744
  const logger = bootstrapConfig.logger || config.logger || createLogger();
66469
66745
  const validatedConfig = {
@@ -66471,6 +66747,8 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
66471
66747
  // flags _should_ be JSON safe
66472
66748
  flags: JSON.parse(JSON.stringify(config.flags || {})),
66473
66749
  logger,
66750
+ outputTargets: (_a = config.outputTargets) !== null && _a !== void 0 ? _a : [],
66751
+ sys: (_c = (_b = config.sys) !== null && _b !== void 0 ? _b : bootstrapConfig.sys) !== null && _c !== void 0 ? _c : createSystem({ logger }),
66474
66752
  };
66475
66753
  // default devMode false
66476
66754
  if (validatedConfig.flags.prod) {
@@ -66737,6 +67015,7 @@ const hasStencilConfigInclude = (includeProp) => Array.isArray(includeProp) && i
66737
67015
  * @public
66738
67016
  */
66739
67017
  const loadConfig = async (init = {}) => {
67018
+ var _a;
66740
67019
  const results = {
66741
67020
  config: null,
66742
67021
  diagnostics: [],
@@ -66751,9 +67030,12 @@ const loadConfig = async (init = {}) => {
66751
67030
  };
66752
67031
  const unknownConfig = {};
66753
67032
  try {
66754
- const sys = init.sys || createSystem();
66755
67033
  const config = init.config || {};
66756
67034
  let configPath = init.configPath || config.configPath;
67035
+ // Pull the {@link CompilerSystem} out of the initialization object, or create one if it does not exist.
67036
+ // This entity is needed to load the project's configuration (and therefore needs to be created before it can be
67037
+ // attached to a configuration entity, validated or otherwise)
67038
+ const sys = (_a = init.sys) !== null && _a !== void 0 ? _a : createSystem();
66757
67039
  const loadedConfigFile = await loadConfigFile(sys, results.diagnostics, configPath);
66758
67040
  if (hasError(results.diagnostics)) {
66759
67041
  return results;
@@ -67045,7 +67327,7 @@ const convertStaticToMeta = (config, compilerCtx, buildCtx, typeChecker, collect
67045
67327
  let moduleFile;
67046
67328
  const visitNode = (node) => {
67047
67329
  if (t.isClassDeclaration(node)) {
67048
- return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile, compilerCtx.nodeMap, transformOpts);
67330
+ return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile, transformOpts);
67049
67331
  }
67050
67332
  else if (t.isImportDeclaration(node)) {
67051
67333
  parseModuleImport(config, compilerCtx, buildCtx, moduleFile, dirPath, node, !transformOpts.isolatedModules);