@stencil/core 2.17.0 → 2.17.1

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 (49) hide show
  1. package/cli/config-flags.d.ts +102 -0
  2. package/cli/index.cjs +603 -220
  3. package/cli/index.d.ts +2 -1
  4. package/cli/index.js +603 -220
  5. package/cli/package.json +1 -1
  6. package/compiler/package.json +1 -1
  7. package/compiler/stencil.js +337 -174
  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 +11 -6
  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/index.js +2 -2
  25. package/internal/hydrate/package.json +1 -1
  26. package/internal/package.json +1 -1
  27. package/internal/stencil-private.d.ts +2 -2
  28. package/internal/stencil-public-compiler.d.ts +67 -48
  29. package/internal/testing/index.js +1 -1
  30. package/internal/testing/package.json +1 -1
  31. package/mock-doc/index.cjs +1 -1
  32. package/mock-doc/index.js +1 -1
  33. package/mock-doc/package.json +1 -1
  34. package/package.json +2 -1
  35. package/screenshot/package.json +1 -1
  36. package/sys/node/index.js +4 -4
  37. package/sys/node/package.json +1 -1
  38. package/sys/node/worker.js +1 -1
  39. package/testing/index.d.ts +1 -1
  40. package/testing/index.js +40 -24
  41. package/testing/jest/jest-config.d.ts +1 -1
  42. package/testing/jest/jest-runner.d.ts +3 -2
  43. package/testing/jest/jest-screenshot.d.ts +1 -1
  44. package/testing/mocks.d.ts +27 -2
  45. package/testing/package.json +1 -1
  46. package/testing/puppeteer/puppeteer-browser.d.ts +2 -2
  47. package/testing/test/testing-utils.spec.d.ts +1 -0
  48. package/testing/testing-utils.d.ts +74 -2
  49. package/testing/testing.d.ts +2 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.17.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v2.17.1 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  (function(exports) {
5
5
  'use strict';
@@ -727,12 +727,27 @@ const trimFalsy = (data) => {
727
727
  return arr;
728
728
  };
729
729
 
730
- const toLowerCase = (str) => str.toLowerCase();
731
- const toDashCase = (str) => toLowerCase(str
732
- .replace(/([A-Z0-9])/g, (g) => ' ' + g[0])
730
+ /**
731
+ * Convert a string from PascalCase to dash-case
732
+ *
733
+ * @param str the string to convert
734
+ * @returns a converted string
735
+ */
736
+ const toDashCase = (str) => str
737
+ .replace(/([A-Z0-9])/g, (match) => ` ${match[0]}`)
733
738
  .trim()
734
- .replace(/ /g, '-'));
735
- const dashToPascalCase$1 = (str) => toLowerCase(str)
739
+ .split(' ')
740
+ .join('-')
741
+ .toLowerCase();
742
+ /**
743
+ * Convert a string from dash-case / kebab-case to PascalCase (or CamelCase,
744
+ * or whatever you call it!)
745
+ *
746
+ * @param str a string to convert
747
+ * @returns a converted string
748
+ */
749
+ const dashToPascalCase$1 = (str) => str
750
+ .toLowerCase()
736
751
  .split('-')
737
752
  .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
738
753
  .join('');
@@ -789,8 +804,8 @@ const pluck = (obj, keys) => {
789
804
  return final;
790
805
  }, {});
791
806
  };
792
- const isBoolean$1 = (v) => typeof v === 'boolean';
793
807
  const isDefined = (v) => v !== null && v !== undefined;
808
+ const isBoolean$1 = (v) => typeof v === 'boolean';
794
809
  const isFunction = (v) => typeof v === 'function';
795
810
  const isNumber$1 = (v) => typeof v === 'number';
796
811
  const isObject$4 = (val) => val != null && typeof val === 'object' && Array.isArray(val) === false;
@@ -1631,7 +1646,7 @@ const isDtsFile$1 = (filePath) => {
1631
1646
  /**
1632
1647
  * Generate the preamble to be placed atop the main file of the build
1633
1648
  * @param config the Stencil configuration file
1634
- * @return the generated preamble
1649
+ * @returns the generated preamble
1635
1650
  */
1636
1651
  const generatePreamble = (config) => {
1637
1652
  const { preamble } = config;
@@ -2026,10 +2041,14 @@ const buildEvents = () => {
2026
2041
  };
2027
2042
  };
2028
2043
 
2044
+ /**
2045
+ * Creates an instance of a logger
2046
+ * @returns the new logger instance
2047
+ */
2029
2048
  const createLogger = () => {
2030
2049
  let useColors = IS_BROWSER_ENV;
2031
2050
  let level = 'info';
2032
- const logger = {
2051
+ return {
2033
2052
  enableColors: (uc) => (useColors = uc),
2034
2053
  getLevel: () => level,
2035
2054
  setLevel: (l) => (level = l),
@@ -2056,7 +2075,6 @@ const createLogger = () => {
2056
2075
  diagnostics.forEach((diagnostic) => logDiagnostic(diagnostic, useColors));
2057
2076
  },
2058
2077
  };
2059
- return logger;
2060
2078
  };
2061
2079
  const logDiagnostic = (diagnostic, useColors) => {
2062
2080
  let color = BLUE;
@@ -2346,8 +2364,16 @@ const getPackageDirPath = (p, moduleId) => {
2346
2364
  return null;
2347
2365
  };
2348
2366
 
2367
+ /**
2368
+ * A fetch wrapper which dispatches to `sys.fetch` if present, and otherwise
2369
+ * uses `global.fetch`.
2370
+ *
2371
+ * @param sys a compiler system object
2372
+ * @param input a `RequestInfo` object
2373
+ * @param init an optional `RequestInit` object
2374
+ * @returns a Promise wrapping a response
2375
+ */
2349
2376
  const httpFetch = (sys, input, init) => {
2350
- console.trace(input);
2351
2377
  if (sys && isFunction(sys.fetch)) {
2352
2378
  return sys.fetch(input, init);
2353
2379
  }
@@ -2355,10 +2381,16 @@ const httpFetch = (sys, input, init) => {
2355
2381
  };
2356
2382
  const packageVersions = new Map();
2357
2383
  const known404Urls = new Set();
2358
- const getStencilRootUrl = (compilerExe) => new URL('../', compilerExe).href;
2359
- const getStencilModuleUrl = (compilerExe, p) => {
2360
- p = normalizePath$1(p);
2361
- let parts = p.split('/');
2384
+ /**
2385
+ * Get the URL for a Stencil module given the path to the compiler
2386
+ *
2387
+ * @param compilerExe the path to the compiler executable
2388
+ * @param path the path to the module or file in question
2389
+ * @returns a URL for the file of interest
2390
+ */
2391
+ const getStencilModuleUrl = (compilerExe, path) => {
2392
+ path = normalizePath$1(path);
2393
+ let parts = path.split('/');
2362
2394
  const nmIndex = parts.lastIndexOf('node_modules');
2363
2395
  if (nmIndex > -1 && nmIndex < parts.length - 1) {
2364
2396
  parts = parts.slice(nmIndex + 1);
@@ -2368,9 +2400,10 @@ const getStencilModuleUrl = (compilerExe, p) => {
2368
2400
  else {
2369
2401
  parts = parts.slice(1);
2370
2402
  }
2371
- p = parts.join('/');
2403
+ path = parts.join('/');
2372
2404
  }
2373
- return new URL('./' + p, getStencilRootUrl(compilerExe)).href;
2405
+ const stencilRootUrl = new URL('../', compilerExe).href;
2406
+ return new URL('./' + path, stencilRootUrl).href;
2374
2407
  };
2375
2408
  const getCommonDirUrl = (sys, pkgVersions, dirPath, fileName) => getNodeModuleFetchUrl(sys, pkgVersions, dirPath) + '/' + fileName;
2376
2409
  const getNodeModuleFetchUrl = (sys, pkgVersions, filePath) => {
@@ -4019,7 +4052,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
4019
4052
  };
4020
4053
  };
4021
4054
 
4022
- const buildId = '20220621172432';
4055
+ const buildId = '20220711170106';
4023
4056
  const minfyJsId = 'terser5.6.1_7';
4024
4057
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.13_7';
4025
4058
  const parse5Version = '6.0.1';
@@ -4027,8 +4060,8 @@ const rollupVersion = '2.42.3';
4027
4060
  const sizzleVersion = '2.42.3';
4028
4061
  const terserVersion = '5.6.1';
4029
4062
  const typescriptVersion = '4.5.4';
4030
- const vermoji = '🚂';
4031
- const version$3 = '2.17.0';
4063
+ const vermoji = '😊';
4064
+ const version$3 = '2.17.1';
4032
4065
  const versions = {
4033
4066
  stencil: version$3,
4034
4067
  parse5: parse5Version,
@@ -4577,6 +4610,17 @@ const createSystem = (c) => {
4577
4610
  };
4578
4611
 
4579
4612
  let cssProcessor;
4613
+ /**
4614
+ * Autoprefix a CSS string, adding vendor prefixes to make sure that what
4615
+ * is written in the CSS will render correctly in our range of supported browsers.
4616
+ * This function uses PostCSS in compbination with the Autoprefix plugin to
4617
+ * automatically add vendor prefixes based on a list of browsers which we want
4618
+ * to support.
4619
+ *
4620
+ * @param cssText the text to be prefixed
4621
+ * @param opts an optional param with options for Autoprefixer
4622
+ * @returns a Promise wrapping some prefixed CSS as well as diagnostics
4623
+ */
4580
4624
  const autoprefixCss = async (cssText, opts) => {
4581
4625
  const output = {
4582
4626
  output: cssText,
@@ -4586,7 +4630,7 @@ const autoprefixCss = async (cssText, opts) => {
4586
4630
  return output;
4587
4631
  }
4588
4632
  try {
4589
- const autoprefixerOpts = opts != null && typeof opts === 'object' ? opts : DEFAULT_AUTOPREFIX_LEGACY;
4633
+ const autoprefixerOpts = opts != null && typeof opts === 'object' ? opts : DEFAULT_AUTOPREFIX_OPTIONS;
4590
4634
  const processor = getProcessor(autoprefixerOpts);
4591
4635
  const result = await processor.process(cssText, { map: null });
4592
4636
  result.warnings().forEach((warning) => {
@@ -4642,6 +4686,12 @@ const autoprefixCss = async (cssText, opts) => {
4642
4686
  }
4643
4687
  return output;
4644
4688
  };
4689
+ /**
4690
+ * Get the processor for PostCSS and the Autoprefixer plugin
4691
+ *
4692
+ * @param autoprefixerOpts Options for Autoprefixer
4693
+ * @returns postCSS with the Autoprefixer plugin applied
4694
+ */
4645
4695
  const getProcessor = (autoprefixerOpts) => {
4646
4696
  const { postcss, autoprefixer } = requireFunc('../sys/node/autoprefixer.js');
4647
4697
  if (!cssProcessor) {
@@ -4649,7 +4699,19 @@ const getProcessor = (autoprefixerOpts) => {
4649
4699
  }
4650
4700
  return cssProcessor;
4651
4701
  };
4652
- const DEFAULT_AUTOPREFIX_LEGACY = {
4702
+ /**
4703
+ * Default options for the Autoprefixer PostCSS plugin. See the documentation:
4704
+ * https://github.com/postcss/autoprefixer#options for a complete list.
4705
+ *
4706
+ * This default option set will:
4707
+ *
4708
+ * - override the default browser list (`overrideBrowserslist`)
4709
+ * - turn off the visual cascade (`cascade`)
4710
+ * - disable auto-removing outdated prefixes (`remove`)
4711
+ * - set `flexbox` to `"no-2009"`, which limits prefixing for flexbox to the
4712
+ * final and IE 10 versions of the specification
4713
+ */
4714
+ const DEFAULT_AUTOPREFIX_OPTIONS = {
4653
4715
  overrideBrowserslist: ['last 2 versions', 'iOS >= 9', 'Android >= 4.4', 'Explorer >= 11', 'ExplorerMobile >= 11'],
4654
4716
  cascade: false,
4655
4717
  remove: false,
@@ -5445,6 +5507,13 @@ const resolveStylesheetUrl = async (nodes, resolveUrl, resolved) => {
5445
5507
  }
5446
5508
  };
5447
5509
 
5510
+ /**
5511
+ * Optimize a CSS file, optionally running an autoprefixer and a minifier
5512
+ * depending on the options set on the input options argument.
5513
+ *
5514
+ * @param inputOpts input CSS options
5515
+ * @returns a promise wrapping the optimized output
5516
+ */
5448
5517
  const optimizeCss$1 = async (inputOpts) => {
5449
5518
  let result = {
5450
5519
  output: inputOpts.input,
@@ -11508,6 +11577,12 @@ const parseImportPath = (importPath) => {
11508
11577
  return parsedPath;
11509
11578
  };
11510
11579
 
11580
+ /**
11581
+ * Strip out comments from some CSS
11582
+ *
11583
+ * @param input the string we'd like to de-comment
11584
+ * @returns de-commented CSS!
11585
+ */
11511
11586
  const stripCssComments = (input) => {
11512
11587
  let isInsideString = null;
11513
11588
  let currentCharacter = '';
@@ -18828,48 +18903,88 @@ const emptyOutputTargets = async (config, compilerCtx, buildCtx) => {
18828
18903
  timeSpan.finish('cleaning dirs finished');
18829
18904
  };
18830
18905
 
18906
+ /**
18907
+ * Parse CSS imports into an object which contains a manifest of imports and a
18908
+ * stylesheet with all imports resolved and concatenated.
18909
+ *
18910
+ * @param config the current config
18911
+ * @param compilerCtx the compiler context (we need filesystem access)
18912
+ * @param buildCtx the build context, we'll need access to diagnostics
18913
+ * @param srcFilePath the source filepath
18914
+ * @param resolvedFilePath the resolved filepath
18915
+ * @param styleText style text we start with
18916
+ * @param styleDocs optional array of style document objects
18917
+ * @returns an object with concatenated styleText and imports
18918
+ */
18831
18919
  const parseCssImports = async (config, compilerCtx, buildCtx, srcFilePath, resolvedFilePath, styleText, styleDocs) => {
18832
18920
  const isCssEntry = resolvedFilePath.toLowerCase().endsWith('.css');
18833
18921
  const allCssImports = [];
18834
- const concatStyleText = await updateCssImports(config, compilerCtx, buildCtx, isCssEntry, srcFilePath, resolvedFilePath, styleText, allCssImports, new Set(), styleDocs);
18922
+ // a Set of previously-resolved file paths that we add to as we traverse the
18923
+ // import tree (to avoid a possible circular dependency and infinite loop)
18924
+ const resolvedFilePaths = new Set();
18925
+ const concatStyleText = await resolveAndFlattenImports(srcFilePath, resolvedFilePath, styleText);
18835
18926
  return {
18836
18927
  imports: allCssImports,
18837
18928
  styleText: concatStyleText,
18838
18929
  };
18839
- };
18840
- const updateCssImports = async (config, compilerCtx, buildCtx, isCssEntry, srcFilePath, resolvedFilePath, styleText, allCssImports, noLoop, styleDocs) => {
18841
- if (noLoop.has(resolvedFilePath)) {
18842
- return styleText;
18843
- }
18844
- noLoop.add(resolvedFilePath);
18845
- if (styleDocs != null) {
18846
- parseStyleDocs(styleDocs, styleText);
18847
- }
18848
- const cssImports = await getCssImports(config, compilerCtx, buildCtx, resolvedFilePath, styleText);
18849
- if (cssImports.length === 0) {
18850
- return styleText;
18851
- }
18852
- for (const cssImport of cssImports) {
18853
- if (!allCssImports.includes(cssImport.filePath)) {
18854
- allCssImports.push(cssImport.filePath);
18930
+ /**
18931
+ * Resolve and flatten all imports for a given CSS file, recursively crawling
18932
+ * the tree of imports to resolve them all and produce a concatenated
18933
+ * stylesheet. We declare this function here, within `parseCssImports`, in order
18934
+ * to get access to `compilerCtx`, `buildCtx`, and more without having to pass
18935
+ * a whole bunch of arguments.
18936
+ *
18937
+ * @param srcFilePath the source filepath
18938
+ * @param resolvedFilePath the resolved filepath
18939
+ * @param styleText style text we start with*
18940
+ * @returns concatenated styles assembled from the various imported stylesheets
18941
+ */
18942
+ async function resolveAndFlattenImports(srcFilePath, resolvedFilePath, styleText) {
18943
+ // if we've seen this path before we early return
18944
+ if (resolvedFilePaths.has(resolvedFilePath)) {
18945
+ return styleText;
18855
18946
  }
18856
- }
18857
- await Promise.all(cssImports.map(async (cssImportData) => {
18858
- await concatCssImport(config, compilerCtx, buildCtx, isCssEntry, srcFilePath, cssImportData, allCssImports, noLoop, styleDocs);
18859
- }));
18860
- return replaceImportDeclarations(styleText, cssImports, isCssEntry);
18861
- };
18862
- const concatCssImport = async (config, compilerCtx, buildCtx, isCssEntry, srcFilePath, cssImportData, allCssImports, noLoop, styleDocs) => {
18863
- cssImportData.styleText = await loadStyleText(compilerCtx, cssImportData);
18864
- if (typeof cssImportData.styleText === 'string') {
18865
- cssImportData.styleText = await updateCssImports(config, compilerCtx, buildCtx, isCssEntry, cssImportData.filePath, cssImportData.filePath, cssImportData.styleText, allCssImports, noLoop, styleDocs);
18866
- }
18867
- else {
18868
- const err = buildError(buildCtx.diagnostics);
18869
- err.messageText = `Unable to read css import: ${cssImportData.srcImport}`;
18870
- err.absFilePath = srcFilePath;
18947
+ resolvedFilePaths.add(resolvedFilePath);
18948
+ if (styleDocs != null) {
18949
+ parseStyleDocs(styleDocs, styleText);
18950
+ }
18951
+ const cssImports = await getCssImports(config, compilerCtx, buildCtx, resolvedFilePath, styleText);
18952
+ if (cssImports.length === 0) {
18953
+ return styleText;
18954
+ }
18955
+ // add any newly-found imports to the 'global' list
18956
+ for (const cssImport of cssImports) {
18957
+ if (!allCssImports.includes(cssImport.filePath)) {
18958
+ allCssImports.push(cssImport.filePath);
18959
+ }
18960
+ }
18961
+ // Recur down the tree of CSS imports, resolving all the imports in
18962
+ // the children of the current file (and, by extension, in their children
18963
+ // and so on)
18964
+ await Promise.all(cssImports.map(async (cssImportData) => {
18965
+ cssImportData.styleText = await loadStyleText(compilerCtx, cssImportData);
18966
+ if (typeof cssImportData.styleText === 'string') {
18967
+ cssImportData.styleText = await resolveAndFlattenImports(cssImportData.filePath, cssImportData.filePath, cssImportData.styleText);
18968
+ }
18969
+ else {
18970
+ // we had some error loading the file from disk, so write a diagnostic
18971
+ const err = buildError(buildCtx.diagnostics);
18972
+ err.messageText = `Unable to read css import: ${cssImportData.srcImport}`;
18973
+ err.absFilePath = srcFilePath;
18974
+ }
18975
+ }));
18976
+ // replace import statements with the actual CSS code in children modules
18977
+ return replaceImportDeclarations(styleText, cssImports, isCssEntry);
18871
18978
  }
18872
18979
  };
18980
+ /**
18981
+ * Load the style text for a CSS file from disk, based on the filepaths set in
18982
+ * our import data.
18983
+ *
18984
+ * @param compilerCtx the compiler context
18985
+ * @param cssImportData the import data for the file we want to read
18986
+ * @returns the contents of the file, if it can be read without error
18987
+ */
18873
18988
  const loadStyleText = async (compilerCtx, cssImportData) => {
18874
18989
  let styleText = null;
18875
18990
  try {
@@ -18885,7 +19000,18 @@ const loadStyleText = async (compilerCtx, cssImportData) => {
18885
19000
  }
18886
19001
  return styleText;
18887
19002
  };
19003
+ /**
19004
+ * Get a manifest of all the CSS imports in a given CSS file
19005
+ *
19006
+ * @param config the current config
19007
+ * @param compilerCtx the compiler context (we need the filesystem)
19008
+ * @param buildCtx the build context, in case we need to set a diagnostic
19009
+ * @param filePath the filepath we're working with
19010
+ * @param styleText the CSS for which we want to retrieve import data
19011
+ * @returns a Promise wrapping a list of CSS import data objects
19012
+ */
18888
19013
  const getCssImports = async (config, compilerCtx, buildCtx, filePath, styleText) => {
19014
+ var _a;
18889
19015
  const imports = [];
18890
19016
  if (!styleText.includes('@import')) {
18891
19017
  // no @import at all, so don't bother
@@ -18893,13 +19019,14 @@ const getCssImports = async (config, compilerCtx, buildCtx, filePath, styleText)
18893
19019
  }
18894
19020
  styleText = stripCssComments(styleText);
18895
19021
  const dir = dirname(filePath);
18896
- const importeeExt = filePath.split('.').pop().toLowerCase();
19022
+ const importeeExt = ((_a = filePath.split('.').pop()) !== null && _a !== void 0 ? _a : '').toLowerCase();
18897
19023
  let r;
18898
19024
  const IMPORT_RE = /(@import)\s+(url\()?\s?(.*?)\s?\)?([^;]*);?/gi;
18899
19025
  while ((r = IMPORT_RE.exec(styleText))) {
18900
19026
  const cssImportData = {
18901
19027
  srcImport: r[0],
18902
19028
  url: r[4].replace(/[\"\'\)]/g, ''),
19029
+ filePath: '',
18903
19030
  };
18904
19031
  if (!isLocalCssImport(cssImportData.srcImport)) {
18905
19032
  // do nothing for @import url(http://external.css)
@@ -18926,7 +19053,10 @@ const getCssImports = async (config, compilerCtx, buildCtx, filePath, styleText)
18926
19053
  cssImportData.altFilePath = normalizePath$1(join(dirPath, fileName));
18927
19054
  }
18928
19055
  }
18929
- if (typeof cssImportData.filePath === 'string') {
19056
+ // we set `filePath` to `""` when the object is created above, so if it
19057
+ // hasn't been changed in the intervening conditionals then we didn't resolve
19058
+ // a filepath for it.
19059
+ if (cssImportData.filePath !== '') {
18930
19060
  imports.push(cssImportData);
18931
19061
  }
18932
19062
  }
@@ -18968,6 +19098,16 @@ const isLocalCssImport = (srcImport) => {
18968
19098
  }
18969
19099
  return true;
18970
19100
  };
19101
+ /**
19102
+ * Replace import declarations (like '@import "foobar";') with the actual CSS
19103
+ * written in the imported module, allowing us to produce a single file from a
19104
+ * tree of stylesheets.
19105
+ *
19106
+ * @param styleText the text within which we want to replace @import statements
19107
+ * @param cssImports information about imported modules
19108
+ * @param isCssEntry whether we're dealing with a CSS file
19109
+ * @returns an updated string with the requisite substitutions
19110
+ */
18971
19111
  const replaceImportDeclarations = (styleText, cssImports, isCssEntry) => {
18972
19112
  for (const cssImport of cssImports) {
18973
19113
  if (isCssEntry) {
@@ -41777,7 +41917,7 @@ const createCustomResolverSync = (sys, inMemoryFs, exts) => {
41777
41917
  * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d121716ed123957f6a86f8985eb013fcaddab345/types/node/globals.d.ts#L183-L188
41778
41918
  * in mind.
41779
41919
  * @param err the entity to check the type of
41780
- * @return true if the provided value is an instance of `ErrnoException`, `false` otherwise
41920
+ * @returns true if the provided value is an instance of `ErrnoException`, `false` otherwise
41781
41921
  */
41782
41922
  function isErrnoException(err) {
41783
41923
  return err instanceof Error && err.hasOwnProperty('code');
@@ -57816,6 +57956,16 @@ const lazyComponentTransform = (compilerCtx, transformOpts) => {
57816
57956
  };
57817
57957
  };
57818
57958
 
57959
+ /**
57960
+ * Generate rollup output based on a rollup build and a series of options.
57961
+ *
57962
+ * @param build a rollup build
57963
+ * @param options output options for rollup
57964
+ * @param config a user-supplied configuration object
57965
+ * @param entryModules a list of entry modules, for checking which chunks
57966
+ * contain components
57967
+ * @returns a Promise wrapping either build results or `null`
57968
+ */
57819
57969
  const generateRollupOutput = async (build, options, config, entryModules) => {
57820
57970
  if (build == null) {
57821
57971
  return null;
@@ -57823,7 +57973,7 @@ const generateRollupOutput = async (build, options, config, entryModules) => {
57823
57973
  const { output } = await build.generate(options);
57824
57974
  return output.map((chunk) => {
57825
57975
  if (chunk.type === 'chunk') {
57826
- const isCore = Object.keys(chunk.modules).some((m) => m.includes('@stencil/core'));
57976
+ const isCore = Object.keys(chunk.modules).some((m) => m.includes(STENCIL_CORE_ID));
57827
57977
  return {
57828
57978
  type: 'chunk',
57829
57979
  fileName: chunk.fileName,
@@ -58322,7 +58472,8 @@ const getSystemLoader = async (config, compilerCtx, corePath, includePolyfills)
58322
58472
 
58323
58473
  var resourcesUrl = scriptElm ? scriptElm.getAttribute('data-resources-url') || scriptElm.src : '';
58324
58474
  var start = function() {
58325
- var url = new URL('${corePath}', new URL(resourcesUrl, window.location.origin));
58475
+ // if src is not present then origin is "null", and new URL() throws TypeError: Failed to construct 'URL': Invalid base URL
58476
+ var url = new URL('${corePath}', new URL(resourcesUrl, window.location.origin !== 'null' ? window.location.origin : undefined));
58326
58477
  System.import(url.href);
58327
58478
  };
58328
58479
 
@@ -64247,15 +64398,14 @@ const updateCompilerCtxCache = (config, compilerCtx, path, kind) => {
64247
64398
  };
64248
64399
 
64249
64400
  const getConfig = (userConfig) => {
64250
- const config = { ...userConfig };
64251
- if (!config.logger) {
64252
- config.logger = createLogger();
64253
- }
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 };
64254
64405
  if (!config.sys) {
64255
64406
  config.sys = createSystem({ logger: config.logger });
64256
64407
  }
64257
64408
  setPlatformPath(config.sys.platformPath);
64258
- config.flags = config.flags || {};
64259
64409
  if (config.flags.debug || config.flags.verbose) {
64260
64410
  config.logLevel = 'debug';
64261
64411
  }
@@ -64276,14 +64426,15 @@ const patchFs = (userSys) => {
64276
64426
 
64277
64427
  /**
64278
64428
  * Generate a Stencil compiler instance
64279
- * @param config a Stencil configuration to apply to the compiler instance
64429
+ * @param userConfig a user-provided Stencil configuration to apply to the compiler instance
64280
64430
  * @returns a new instance of a Stencil compiler
64431
+ * @public
64281
64432
  */
64282
- const createCompiler = async (config) => {
64433
+ const createCompiler = async (userConfig) => {
64283
64434
  // actual compiler code
64284
64435
  // could be in a web worker on the browser
64285
64436
  // or the main thread in node
64286
- config = getConfig(config);
64437
+ const config = getConfig(userConfig);
64287
64438
  const diagnostics = [];
64288
64439
  const sys = config.sys;
64289
64440
  const compilerCtx = new CompilerContext();
@@ -64959,7 +65110,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
64959
65110
  const dependencies = [
64960
65111
  {
64961
65112
  name: "@stencil/core",
64962
- version: "2.17.0",
65113
+ version: "2.17.1",
64963
65114
  main: "compiler/stencil.js",
64964
65115
  resources: [
64965
65116
  "package.json",
@@ -65131,11 +65282,11 @@ const getUserConfigName = (config, correctConfigName) => {
65131
65282
  };
65132
65283
 
65133
65284
  const validateDevServer = (config, diagnostics) => {
65134
- var _a, _b, _c, _d, _e, _f, _g;
65285
+ var _a, _b, _c, _d, _e;
65135
65286
  if ((config.devServer === null || config.devServer) === false) {
65136
65287
  return undefined;
65137
65288
  }
65138
- const flags = (_a = config.flags) !== null && _a !== void 0 ? _a : {};
65289
+ const { flags } = config;
65139
65290
  const devServer = { ...config.devServer };
65140
65291
  if (flags.address && isString$1(flags.address)) {
65141
65292
  devServer.address = flags.address;
@@ -65193,14 +65344,14 @@ const validateDevServer = (config, diagnostics) => {
65193
65344
  if (!isBoolean$1(devServer.websocket)) {
65194
65345
  devServer.websocket = true;
65195
65346
  }
65196
- if ((_b = config === null || config === void 0 ? void 0 : config.flags) === null || _b === void 0 ? void 0 : _b.ssr) {
65347
+ if (flags.ssr) {
65197
65348
  devServer.ssr = true;
65198
65349
  }
65199
65350
  else {
65200
65351
  devServer.ssr = !!devServer.ssr;
65201
65352
  }
65202
65353
  if (devServer.ssr) {
65203
- const wwwOutput = ((_c = config.outputTargets) !== null && _c !== void 0 ? _c : []).find(isOutputTargetWww);
65354
+ const wwwOutput = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).find(isOutputTargetWww);
65204
65355
  devServer.prerenderConfig = wwwOutput === null || wwwOutput === void 0 ? void 0 : wwwOutput.prerenderConfig;
65205
65356
  }
65206
65357
  if (isString$1(config.srcIndexHtml)) {
@@ -65226,15 +65377,15 @@ const validateDevServer = (config, diagnostics) => {
65226
65377
  }
65227
65378
  let serveDir;
65228
65379
  let basePath;
65229
- const wwwOutputTarget = ((_d = config.outputTargets) !== null && _d !== void 0 ? _d : []).find(isOutputTargetWww);
65380
+ const wwwOutputTarget = ((_b = config.outputTargets) !== null && _b !== void 0 ? _b : []).find(isOutputTargetWww);
65230
65381
  if (wwwOutputTarget) {
65231
- const baseUrl = new URL((_e = wwwOutputTarget.baseUrl) !== null && _e !== void 0 ? _e : '', 'http://config.stenciljs.com');
65382
+ const baseUrl = new URL((_c = wwwOutputTarget.baseUrl) !== null && _c !== void 0 ? _c : '', 'http://config.stenciljs.com');
65232
65383
  basePath = baseUrl.pathname;
65233
- serveDir = (_f = wwwOutputTarget.appDir) !== null && _f !== void 0 ? _f : '';
65384
+ serveDir = (_d = wwwOutputTarget.appDir) !== null && _d !== void 0 ? _d : '';
65234
65385
  }
65235
65386
  else {
65236
65387
  basePath = '';
65237
- serveDir = (_g = config.rootDir) !== null && _g !== void 0 ? _g : '';
65388
+ serveDir = (_e = config.rootDir) !== null && _e !== void 0 ? _e : '';
65238
65389
  }
65239
65390
  if (!isString$1(basePath) || basePath.trim() === '') {
65240
65391
  basePath = `/`;
@@ -65368,11 +65519,19 @@ const validateHydrated = (config) => {
65368
65519
  return hydratedFlag;
65369
65520
  };
65370
65521
 
65522
+ /**
65523
+ * Validate and return DIST_COLLECTION output targets, ensuring that the `dir`
65524
+ * property is set on them.
65525
+ *
65526
+ * @param config the user-supplied configuration object
65527
+ * @param userOutputs an array of output targets
65528
+ * @returns an array of validated DIST_COLLECTION output targets
65529
+ */
65371
65530
  const validateCollection = (config, userOutputs) => {
65372
- return userOutputs.filter(isOutputTargetDistCollection).map((o) => {
65531
+ return userOutputs.filter(isOutputTargetDistCollection).map((outputTarget) => {
65373
65532
  return {
65374
- ...o,
65375
- dir: getAbsolutePath(config, o.dir || 'dist/collection'),
65533
+ ...outputTarget,
65534
+ dir: getAbsolutePath(config, outputTarget.dir || 'dist/collection'),
65376
65535
  };
65377
65536
  });
65378
65537
  };
@@ -65706,7 +65865,7 @@ const validateHydrateScript = (config, userOutputs) => {
65706
65865
  // we don't already have a hydrate output target
65707
65866
  // let's still see if we require one because of other output targets
65708
65867
  const hasWwwOutput = userOutputs.filter(isOutputTargetWww).some((o) => isString$1(o.indexHtml));
65709
- const shouldBuildHydrate = (config === null || config === void 0 ? void 0 : config.flags.prerender) || (config === null || config === void 0 ? void 0 : config.flags.ssr);
65868
+ const shouldBuildHydrate = config.flags.prerender || config.flags.ssr;
65710
65869
  if (hasWwwOutput && shouldBuildHydrate) {
65711
65870
  // we're prerendering a www output target, so we'll need a hydrate app
65712
65871
  let hydrateDir;
@@ -65782,7 +65941,7 @@ const validateStats = (userConfig, userOutputs) => {
65782
65941
  };
65783
65942
 
65784
65943
  const validatePrerender = (config, diagnostics, outputTarget) => {
65785
- if (!config.flags || (!config.flags.ssr && !config.flags.prerender && config.flags.task !== 'prerender')) {
65944
+ if (!config.flags.ssr && !config.flags.prerender && config.flags.task !== 'prerender') {
65786
65945
  return;
65787
65946
  }
65788
65947
  outputTarget.baseUrl = normalizePath$1(outputTarget.baseUrl);
@@ -65807,8 +65966,6 @@ const validatePrerender = (config, diagnostics, outputTarget) => {
65807
65966
  }
65808
65967
  };
65809
65968
 
65810
- const HOST_CONFIG_FILENAME = 'host.config.json';
65811
-
65812
65969
  const validateServiceWorker = (config, outputTarget) => {
65813
65970
  if (outputTarget.serviceWorker === false) {
65814
65971
  return;
@@ -65861,14 +66018,15 @@ const validateServiceWorker = (config, outputTarget) => {
65861
66018
  }
65862
66019
  };
65863
66020
  const addGlobIgnores = (config, globIgnores) => {
65864
- globIgnores.push(`**/${HOST_CONFIG_FILENAME}`, `**/*.system.entry.js`, `**/*.system.js`, `**/${config.fsNamespace}.js`, `**/${config.fsNamespace}.esm.js`, `**/${config.fsNamespace}.css`);
66021
+ globIgnores.push(`**/host.config.json`, // the filename of the host configuration
66022
+ `**/*.system.entry.js`, `**/*.system.js`, `**/${config.fsNamespace}.js`, `**/${config.fsNamespace}.esm.js`, `**/${config.fsNamespace}.css`);
65865
66023
  };
65866
66024
  const DEFAULT_GLOB_PATTERNS = ['*.html', '**/*.{js,css,json}'];
65867
66025
  const DEFAULT_FILENAME = 'sw.js';
65868
66026
 
65869
66027
  const validateWww = (config, diagnostics, userOutputs) => {
65870
66028
  const hasOutputTargets = userOutputs.length > 0;
65871
- const hasE2eTests = !!(config.flags && config.flags.e2e);
66029
+ const hasE2eTests = !!config.flags.e2e;
65872
66030
  const userWwwOutputs = userOutputs.filter(isOutputTargetWww);
65873
66031
  if (!hasOutputTargets ||
65874
66032
  (hasE2eTests && !userOutputs.some(isOutputTargetWww) && !userOutputs.some(isOutputTargetDist))) {
@@ -66122,7 +66280,7 @@ const DEFAULT_ROLLUP_CONFIG = {
66122
66280
  const validateTesting = (config, diagnostics) => {
66123
66281
  var _a;
66124
66282
  const testing = (config.testing = Object.assign({}, config.testing || {}));
66125
- if (!config.flags || (!config.flags.e2e && !config.flags.spec)) {
66283
+ if (!config.flags.e2e && !config.flags.spec) {
66126
66284
  return;
66127
66285
  }
66128
66286
  let configPathDir = config.configPath;
@@ -66160,7 +66318,7 @@ const validateTesting = (config, diagnostics) => {
66160
66318
  else {
66161
66319
  testing.rootDir = config.rootDir;
66162
66320
  }
66163
- if (config.flags && typeof config.flags.screenshotConnector === 'string') {
66321
+ if (typeof config.flags.screenshotConnector === 'string') {
66164
66322
  testing.screenshotConnector = config.flags.screenshotConnector;
66165
66323
  }
66166
66324
  if (typeof testing.screenshotConnector === 'string') {
@@ -66282,13 +66440,11 @@ const validateWorkers = (config) => {
66282
66440
  if (typeof config.maxConcurrentWorkers !== 'number') {
66283
66441
  config.maxConcurrentWorkers = 8;
66284
66442
  }
66285
- if (config.flags) {
66286
- if (typeof config.flags.maxWorkers === 'number') {
66287
- config.maxConcurrentWorkers = config.flags.maxWorkers;
66288
- }
66289
- else if (config.flags.ci) {
66290
- config.maxConcurrentWorkers = 4;
66291
- }
66443
+ if (typeof config.flags.maxWorkers === 'number') {
66444
+ config.maxConcurrentWorkers = config.flags.maxWorkers;
66445
+ }
66446
+ else if (config.flags.ci) {
66447
+ config.maxConcurrentWorkers = 4;
66292
66448
  }
66293
66449
  config.maxConcurrentWorkers = Math.max(Math.min(config.maxConcurrentWorkers, 16), 0);
66294
66450
  if (config.devServer) {
@@ -66302,111 +66458,119 @@ const validateWorkers = (config) => {
66302
66458
  * `UnvalidatedConfig` to a `Config`.
66303
66459
  *
66304
66460
  * @param userConfig an unvalidated config that we've gotten from a user
66461
+ * @param bootstrapConfig the initial configuration provided by the user (or generated by Stencil) used to bootstrap
66462
+ * configuration loading and validation
66305
66463
  * @returns an object with config and diagnostics props
66306
66464
  */
66307
- const validateConfig = (userConfig = {}) => {
66465
+ const validateConfig = (userConfig = {}, bootstrapConfig) => {
66308
66466
  const config = Object.assign({}, userConfig || {}); // not positive it's json safe
66309
66467
  const diagnostics = [];
66310
- // copy flags (we know it'll be json safe)
66311
- config.flags = JSON.parse(JSON.stringify(config.flags || {}));
66468
+ const logger = bootstrapConfig.logger || config.logger || createLogger();
66469
+ const validatedConfig = {
66470
+ ...config,
66471
+ // flags _should_ be JSON safe
66472
+ flags: JSON.parse(JSON.stringify(config.flags || {})),
66473
+ logger,
66474
+ };
66312
66475
  // default devMode false
66313
- if (config.flags.prod) {
66314
- config.devMode = false;
66315
- }
66316
- else if (config.flags.dev) {
66317
- config.devMode = true;
66318
- }
66319
- else if (!isBoolean$1(config.devMode)) {
66320
- config.devMode = DEFAULT_DEV_MODE;
66321
- }
66322
- config.extras = config.extras || {};
66323
- config.extras.appendChildSlotFix = !!config.extras.appendChildSlotFix;
66324
- config.extras.cloneNodeFix = !!config.extras.cloneNodeFix;
66325
- config.extras.cssVarsShim = !!config.extras.cssVarsShim;
66326
- config.extras.dynamicImportShim = !!config.extras.dynamicImportShim;
66327
- config.extras.lifecycleDOMEvents = !!config.extras.lifecycleDOMEvents;
66328
- config.extras.safari10 = !!config.extras.safari10;
66329
- config.extras.scriptDataOpts = !!config.extras.scriptDataOpts;
66330
- config.extras.shadowDomShim = !!config.extras.shadowDomShim;
66331
- config.extras.slotChildNodesFix = !!config.extras.slotChildNodesFix;
66332
- config.extras.initializeNextTick = !!config.extras.initializeNextTick;
66333
- config.extras.tagNameTransform = !!config.extras.tagNameTransform;
66334
- config.buildEs5 = config.buildEs5 === true || (!config.devMode && config.buildEs5 === 'prod');
66335
- setBooleanConfig(config, 'minifyCss', null, !config.devMode);
66336
- setBooleanConfig(config, 'minifyJs', null, !config.devMode);
66337
- setBooleanConfig(config, 'sourceMap', null, typeof config.sourceMap === 'undefined' ? false : config.sourceMap);
66338
- setBooleanConfig(config, 'watch', 'watch', false);
66339
- setBooleanConfig(config, 'buildDocs', 'docs', !config.devMode);
66340
- setBooleanConfig(config, 'buildDist', 'esm', !config.devMode || config.buildEs5);
66341
- setBooleanConfig(config, 'profile', 'profile', config.devMode);
66342
- setBooleanConfig(config, 'writeLog', 'log', false);
66343
- setBooleanConfig(config, 'buildAppCore', null, true);
66344
- setBooleanConfig(config, 'autoprefixCss', null, config.buildEs5);
66345
- setBooleanConfig(config, 'validateTypes', null, !config._isTesting);
66346
- setBooleanConfig(config, 'allowInlineScripts', null, true);
66347
- if (!isString$1(config.taskQueue)) {
66348
- config.taskQueue = 'async';
66476
+ if (validatedConfig.flags.prod) {
66477
+ validatedConfig.devMode = false;
66478
+ }
66479
+ else if (validatedConfig.flags.dev) {
66480
+ validatedConfig.devMode = true;
66481
+ }
66482
+ else if (!isBoolean$1(validatedConfig.devMode)) {
66483
+ validatedConfig.devMode = DEFAULT_DEV_MODE;
66484
+ }
66485
+ validatedConfig.extras = validatedConfig.extras || {};
66486
+ validatedConfig.extras.appendChildSlotFix = !!validatedConfig.extras.appendChildSlotFix;
66487
+ validatedConfig.extras.cloneNodeFix = !!validatedConfig.extras.cloneNodeFix;
66488
+ validatedConfig.extras.cssVarsShim = !!validatedConfig.extras.cssVarsShim;
66489
+ validatedConfig.extras.dynamicImportShim = !!validatedConfig.extras.dynamicImportShim;
66490
+ validatedConfig.extras.lifecycleDOMEvents = !!validatedConfig.extras.lifecycleDOMEvents;
66491
+ validatedConfig.extras.safari10 = !!validatedConfig.extras.safari10;
66492
+ validatedConfig.extras.scriptDataOpts = !!validatedConfig.extras.scriptDataOpts;
66493
+ validatedConfig.extras.shadowDomShim = !!validatedConfig.extras.shadowDomShim;
66494
+ validatedConfig.extras.slotChildNodesFix = !!validatedConfig.extras.slotChildNodesFix;
66495
+ validatedConfig.extras.initializeNextTick = !!validatedConfig.extras.initializeNextTick;
66496
+ validatedConfig.extras.tagNameTransform = !!validatedConfig.extras.tagNameTransform;
66497
+ validatedConfig.buildEs5 =
66498
+ validatedConfig.buildEs5 === true || (!validatedConfig.devMode && validatedConfig.buildEs5 === 'prod');
66499
+ setBooleanConfig(validatedConfig, 'minifyCss', null, !validatedConfig.devMode);
66500
+ setBooleanConfig(validatedConfig, 'minifyJs', null, !validatedConfig.devMode);
66501
+ setBooleanConfig(validatedConfig, 'sourceMap', null, typeof validatedConfig.sourceMap === 'undefined' ? false : validatedConfig.sourceMap);
66502
+ setBooleanConfig(validatedConfig, 'watch', 'watch', false);
66503
+ setBooleanConfig(validatedConfig, 'buildDocs', 'docs', !validatedConfig.devMode);
66504
+ setBooleanConfig(validatedConfig, 'buildDist', 'esm', !validatedConfig.devMode || validatedConfig.buildEs5);
66505
+ setBooleanConfig(validatedConfig, 'profile', 'profile', validatedConfig.devMode);
66506
+ setBooleanConfig(validatedConfig, 'writeLog', 'log', false);
66507
+ setBooleanConfig(validatedConfig, 'buildAppCore', null, true);
66508
+ setBooleanConfig(validatedConfig, 'autoprefixCss', null, validatedConfig.buildEs5);
66509
+ setBooleanConfig(validatedConfig, 'validateTypes', null, !validatedConfig._isTesting);
66510
+ setBooleanConfig(validatedConfig, 'allowInlineScripts', null, true);
66511
+ if (!isString$1(validatedConfig.taskQueue)) {
66512
+ validatedConfig.taskQueue = 'async';
66349
66513
  }
66350
66514
  // hash file names
66351
- if (!isBoolean$1(config.hashFileNames)) {
66352
- config.hashFileNames = !config.devMode;
66515
+ if (!isBoolean$1(validatedConfig.hashFileNames)) {
66516
+ validatedConfig.hashFileNames = !validatedConfig.devMode;
66353
66517
  }
66354
- if (!isNumber$1(config.hashedFileNameLength)) {
66355
- config.hashedFileNameLength = DEFAULT_HASHED_FILENAME_LENTH;
66518
+ if (!isNumber$1(validatedConfig.hashedFileNameLength)) {
66519
+ validatedConfig.hashedFileNameLength = DEFAULT_HASHED_FILENAME_LENTH;
66356
66520
  }
66357
- if (config.hashedFileNameLength < MIN_HASHED_FILENAME_LENTH) {
66521
+ if (validatedConfig.hashedFileNameLength < MIN_HASHED_FILENAME_LENTH) {
66358
66522
  const err = buildError(diagnostics);
66359
- err.messageText = `config.hashedFileNameLength must be at least ${MIN_HASHED_FILENAME_LENTH} characters`;
66523
+ err.messageText = `validatedConfig.hashedFileNameLength must be at least ${MIN_HASHED_FILENAME_LENTH} characters`;
66360
66524
  }
66361
- if (config.hashedFileNameLength > MAX_HASHED_FILENAME_LENTH) {
66525
+ if (validatedConfig.hashedFileNameLength > MAX_HASHED_FILENAME_LENTH) {
66362
66526
  const err = buildError(diagnostics);
66363
- err.messageText = `config.hashedFileNameLength cannot be more than ${MAX_HASHED_FILENAME_LENTH} characters`;
66527
+ err.messageText = `validatedConfig.hashedFileNameLength cannot be more than ${MAX_HASHED_FILENAME_LENTH} characters`;
66364
66528
  }
66365
- if (!config.env) {
66366
- config.env = {};
66529
+ if (!validatedConfig.env) {
66530
+ validatedConfig.env = {};
66367
66531
  }
66368
66532
  // get a good namespace
66369
- validateNamespace(config, diagnostics);
66533
+ validateNamespace(validatedConfig, diagnostics);
66370
66534
  // figure out all of the config paths and absolute paths
66371
- validatePaths(config);
66535
+ validatePaths(validatedConfig);
66372
66536
  // outputTargets
66373
- validateOutputTargets(config, diagnostics);
66537
+ validateOutputTargets(validatedConfig, diagnostics);
66374
66538
  // plugins
66375
- validatePlugins(config, diagnostics);
66539
+ validatePlugins(validatedConfig, diagnostics);
66376
66540
  // rollup config
66377
- validateRollupConfig(config);
66541
+ validateRollupConfig(validatedConfig);
66378
66542
  // dev server
66379
- config.devServer = validateDevServer(config, diagnostics);
66543
+ validatedConfig.devServer = validateDevServer(validatedConfig, diagnostics);
66380
66544
  // testing
66381
- validateTesting(config, diagnostics);
66545
+ validateTesting(validatedConfig, diagnostics);
66382
66546
  // hydrate flag
66383
- config.hydratedFlag = validateHydrated(config);
66547
+ validatedConfig.hydratedFlag = validateHydrated(validatedConfig);
66384
66548
  // bundles
66385
- if (Array.isArray(config.bundles)) {
66386
- config.bundles = sortBy(config.bundles, (a) => a.components.length);
66549
+ if (Array.isArray(validatedConfig.bundles)) {
66550
+ validatedConfig.bundles = sortBy(validatedConfig.bundles, (a) => a.components.length);
66387
66551
  }
66388
66552
  else {
66389
- config.bundles = [];
66553
+ validatedConfig.bundles = [];
66390
66554
  }
66391
66555
  // validate how many workers we can use
66392
- validateWorkers(config);
66556
+ validateWorkers(validatedConfig);
66393
66557
  // default devInspector to whatever devMode is
66394
- setBooleanConfig(config, 'devInspector', null, config.devMode);
66395
- if (!config._isTesting) {
66396
- validateDistNamespace(config, diagnostics);
66558
+ setBooleanConfig(validatedConfig, 'devInspector', null, validatedConfig.devMode);
66559
+ if (!validatedConfig._isTesting) {
66560
+ validateDistNamespace(validatedConfig, diagnostics);
66397
66561
  }
66398
- setBooleanConfig(config, 'enableCache', 'cache', true);
66399
- if (!Array.isArray(config.watchIgnoredRegex) && config.watchIgnoredRegex != null) {
66400
- config.watchIgnoredRegex = [config.watchIgnoredRegex];
66562
+ setBooleanConfig(validatedConfig, 'enableCache', 'cache', true);
66563
+ if (!Array.isArray(validatedConfig.watchIgnoredRegex) && validatedConfig.watchIgnoredRegex != null) {
66564
+ validatedConfig.watchIgnoredRegex = [validatedConfig.watchIgnoredRegex];
66401
66565
  }
66402
- config.watchIgnoredRegex = (config.watchIgnoredRegex || []).reduce((arr, reg) => {
66566
+ validatedConfig.watchIgnoredRegex = (validatedConfig.watchIgnoredRegex || []).reduce((arr, reg) => {
66403
66567
  if (reg instanceof RegExp) {
66404
66568
  arr.push(reg);
66405
66569
  }
66406
66570
  return arr;
66407
66571
  }, []);
66408
66572
  return {
66409
- config,
66573
+ config: validatedConfig,
66410
66574
  diagnostics,
66411
66575
  };
66412
66576
  };
@@ -66585,6 +66749,7 @@ const loadConfig = async (init = {}) => {
66585
66749
  extends: null,
66586
66750
  },
66587
66751
  };
66752
+ const unknownConfig = {};
66588
66753
  try {
66589
66754
  const sys = init.sys || createSystem();
66590
66755
  const config = init.config || {};
@@ -66593,22 +66758,21 @@ const loadConfig = async (init = {}) => {
66593
66758
  if (hasError(results.diagnostics)) {
66594
66759
  return results;
66595
66760
  }
66596
- if (loadedConfigFile != null) {
66761
+ if (loadedConfigFile !== null) {
66597
66762
  // merge the user's config object into their loaded config file
66598
66763
  configPath = loadedConfigFile.configPath;
66599
- results.config = { ...loadedConfigFile, ...config };
66600
- results.config.configPath = configPath;
66601
- results.config.rootDir = normalizePath$1(dirname(configPath));
66764
+ unknownConfig.config = { ...loadedConfigFile, ...config };
66765
+ unknownConfig.config.configPath = configPath;
66766
+ unknownConfig.config.rootDir = normalizePath$1(dirname(configPath));
66602
66767
  }
66603
66768
  else {
66604
66769
  // no stencil.config.ts or .js file, which is fine
66605
- // #0CJS ¯\_(ツ)_/¯
66606
- results.config = { ...config };
66607
- results.config.configPath = null;
66608
- results.config.rootDir = normalizePath$1(sys.getCurrentDirectory());
66770
+ unknownConfig.config = { ...config };
66771
+ unknownConfig.config.configPath = null;
66772
+ unknownConfig.config.rootDir = normalizePath$1(sys.getCurrentDirectory());
66609
66773
  }
66610
- results.config.sys = sys;
66611
- const validated = validateConfig(results.config);
66774
+ unknownConfig.config.sys = sys;
66775
+ const validated = validateConfig(unknownConfig.config, init);
66612
66776
  results.diagnostics.push(...validated.diagnostics);
66613
66777
  if (hasError(results.diagnostics)) {
66614
66778
  return results;
@@ -66623,7 +66787,6 @@ const loadConfig = async (init = {}) => {
66623
66787
  else if (typeof results.config.logLevel !== 'string') {
66624
66788
  results.config.logLevel = 'info';
66625
66789
  }
66626
- results.config.logger = init.logger || results.config.logger || createLogger();
66627
66790
  results.config.logger.setLevel(results.config.logLevel);
66628
66791
  if (!hasError(results.diagnostics)) {
66629
66792
  const tsConfigResults = await validateTsConfig(results.config, sys, init);