@stencil/core 2.10.0 → 2.11.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v2.10.0 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v2.11.0-0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  (function(exports) {
5
5
  'use strict';
@@ -1645,6 +1645,11 @@ const parseJson = (jsonStr, filePath) => {
1645
1645
  const SKIP_DEPS = ['@stencil/core'];
1646
1646
 
1647
1647
  // MODULE: utils/validation.js
1648
+ /**
1649
+ * Validates that a component tag meets required naming conventions to be used for a web component
1650
+ * @param tag the tag to validate
1651
+ * @returns an error message if the tag has an invalid name, undefined if the tag name passes all checks
1652
+ */
1648
1653
  const validateComponentTag = (tag) => {
1649
1654
  if (tag !== tag.trim()) {
1650
1655
  return `Tag can not contain white spaces`;
@@ -3967,7 +3972,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
3967
3972
  };
3968
3973
 
3969
3974
  // MODULE: version.js
3970
- const buildId = '20211101165355';
3975
+ const buildId = '20211109214411';
3971
3976
  const minfyJsId = 'terser5.6.1_7';
3972
3977
  const optimizeCssId = 'autoprefixer10.2.5_postcss8.2.8_7';
3973
3978
  const parse5Version = '6.0.1';
@@ -3975,8 +3980,8 @@ const rollupVersion = '2.42.3';
3975
3980
  const sizzleVersion = '2.42.3';
3976
3981
  const terserVersion = '5.6.1';
3977
3982
  const typescriptVersion = '4.3.5';
3978
- const vermoji = '🦁';
3979
- const version$3 = '2.10.0';
3983
+ const vermoji = '🚟';
3984
+ const version$3 = '2.11.0-0';
3980
3985
  const versions = {
3981
3986
  stencil: version$3,
3982
3987
  parse5: parse5Version,
@@ -11091,6 +11096,7 @@ const extractCommentsWithHash = (input) => {
11091
11096
  };
11092
11097
  const _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
11093
11098
  const _curlyRe = /([{}])/g;
11099
+ const _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
11094
11100
  const OPEN_CURLY = '{';
11095
11101
  const CLOSE_CURLY = '}';
11096
11102
  const BLOCK_PLACEHOLDER = '%BLOCK%';
@@ -11243,17 +11249,18 @@ const selectorNeedsScoping = (selector, scopeSelector) => {
11243
11249
  const re = makeScopeMatcher(scopeSelector);
11244
11250
  return !re.test(selector);
11245
11251
  };
11252
+ const injectScopingSelector = (selector, scopingSelector) => {
11253
+ return selector.replace(_selectorPartsRe, (_, before = '', _colonGroup, colon = '', after = '') => {
11254
+ return before + scopingSelector + colon + after;
11255
+ });
11256
+ };
11246
11257
  const applySimpleSelectorScope = (selector, scopeSelector, hostSelector) => {
11247
11258
  // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
11248
11259
  _polyfillHostRe.lastIndex = 0;
11249
11260
  if (_polyfillHostRe.test(selector)) {
11250
11261
  const replaceBy = `.${hostSelector}`;
11251
11262
  return selector
11252
- .replace(_polyfillHostNoCombinatorRe, (_, selector) => {
11253
- return selector.replace(/([^:]*)(:*)(.*)/, (_, before, colon, after) => {
11254
- return before + replaceBy + colon + after;
11255
- });
11256
- })
11263
+ .replace(_polyfillHostNoCombinatorRe, (_, selector) => injectScopingSelector(selector, replaceBy))
11257
11264
  .replace(_polyfillHostRe, replaceBy + ' ');
11258
11265
  }
11259
11266
  return scopeSelector + ' ' + selector;
@@ -11274,10 +11281,7 @@ const applyStrictSelectorScope = (selector, scopeSelector, hostSelector) => {
11274
11281
  // remove :host since it should be unnecessary
11275
11282
  const t = p.replace(_polyfillHostRe, '');
11276
11283
  if (t.length > 0) {
11277
- const matches = t.match(/([^:]*)(:*)(.*)/);
11278
- if (matches) {
11279
- scopedP = matches[1] + className + matches[2] + matches[3];
11280
- }
11284
+ scopedP = injectScopingSelector(t, className);
11281
11285
  }
11282
11286
  }
11283
11287
  return scopedP;
@@ -54999,11 +55003,11 @@ const updateNativeHostComponentHeritageClauses = (classNode, moduleFile) => {
54999
55003
  if (classNode.heritageClauses != null && classNode.heritageClauses.length > 0) {
55000
55004
  return classNode.heritageClauses;
55001
55005
  }
55002
- if (moduleFile.cmps.length > 1) {
55006
+ if (moduleFile.cmps.length >= 1) {
55003
55007
  addCoreRuntimeApi(moduleFile, RUNTIME_APIS.HTMLElement);
55004
55008
  }
55005
- const heritageClause = t.createHeritageClause(t.SyntaxKind.ExtendsKeyword, [
55006
- t.createExpressionWithTypeArguments([], t.createIdentifier(HTML_ELEMENT)),
55009
+ const heritageClause = t.factory.createHeritageClause(t.SyntaxKind.ExtendsKeyword, [
55010
+ t.factory.createExpressionWithTypeArguments(t.factory.createIdentifier(HTML_ELEMENT), []),
55007
55011
  ]);
55008
55012
  return [heritageClause];
55009
55013
  };
@@ -55241,6 +55245,9 @@ const createCustomElementsDefineCase = (tagName, actionExpression) => {
55241
55245
  * Add the main `defineCustomElement` function e.g.
55242
55246
  * ```javascript
55243
55247
  * function defineCustomElement() {
55248
+ * if (typeof customElements === 'undefined') {
55249
+ * return;
55250
+ * }
55244
55251
  * const components = ['my-component'];
55245
55252
  * components.forEach(tagName => {
55246
55253
  * switch (tagName) {
@@ -55261,6 +55268,7 @@ const createCustomElementsDefineCase = (tagName, actionExpression) => {
55261
55268
  */
55262
55269
  const addDefineCustomElementFunction = (tagNames, newStatements, caseStatements) => {
55263
55270
  const newExpression = t.factory.createFunctionDeclaration(undefined, [t.factory.createModifier(t.SyntaxKind.ExportKeyword)], undefined, t.factory.createIdentifier('defineCustomElement'), undefined, undefined, undefined, t.factory.createBlock([
55271
+ t.factory.createIfStatement(t.factory.createStrictEquality(t.factory.createTypeOfExpression(t.factory.createIdentifier('customElements')), t.factory.createStringLiteral('undefined')), t.factory.createBlock([t.factory.createReturnStatement()])),
55264
55272
  t.factory.createVariableStatement(undefined, t.factory.createVariableDeclarationList([
55265
55273
  t.factory.createVariableDeclaration('components', undefined, undefined, t.factory.createArrayLiteralExpression(tagNames.map((tagName) => t.factory.createStringLiteral(tagName)))),
55266
55274
  ], t.NodeFlags.Const)),
@@ -57155,195 +57163,6 @@ const outputHydrateScript = async (config, compilerCtx, buildCtx) => {
57155
57163
  }
57156
57164
  };
57157
57165
 
57158
- // MODULE: compiler/html/used-components.js
57159
- const getUsedComponents = (doc, cmps) => {
57160
- const tags = new Set(cmps.map((cmp) => cmp.tagName.toUpperCase()));
57161
- const found = [];
57162
- const searchComponents = (el) => {
57163
- if (tags.has(el.tagName)) {
57164
- found.push(el.tagName.toLowerCase());
57165
- }
57166
- for (let i = 0; i < el.childElementCount; i++) {
57167
- searchComponents(el.children[i]);
57168
- }
57169
- };
57170
- searchComponents(doc.documentElement);
57171
- return found;
57172
- };
57173
-
57174
- // MODULE: compiler/entries/default-bundles.js
57175
- function getDefaultBundles(config, buildCtx, cmps) {
57176
- const userConfigEntryPoints = getUserConfigBundles(config, buildCtx, cmps);
57177
- if (userConfigEntryPoints.length > 0) {
57178
- return userConfigEntryPoints;
57179
- }
57180
- let entryPointsHints = config.entryComponentsHint;
57181
- if (!entryPointsHints && buildCtx.indexDoc) {
57182
- entryPointsHints = getUsedComponents(buildCtx.indexDoc, cmps);
57183
- }
57184
- if (!entryPointsHints) {
57185
- return [];
57186
- }
57187
- const mainBundle = unique([
57188
- ...entryPointsHints,
57189
- ...flatOne(entryPointsHints.map(resolveTag).map((cmp) => cmp.dependencies)),
57190
- ]).map(resolveTag);
57191
- function resolveTag(tag) {
57192
- return cmps.find((cmp) => cmp.tagName === tag);
57193
- }
57194
- return [mainBundle];
57195
- }
57196
- function getUserConfigBundles(config, buildCtx, cmps) {
57197
- const definedTags = new Set();
57198
- const entryTags = config.bundles.map((b) => {
57199
- return b.components
57200
- .map((tag) => {
57201
- const tagError = validateComponentTag(tag);
57202
- if (tagError) {
57203
- const err = buildError(buildCtx.diagnostics);
57204
- err.header = `Stencil Config`;
57205
- err.messageText = tagError;
57206
- }
57207
- const component = cmps.find((cmp) => cmp.tagName === tag);
57208
- if (!component) {
57209
- const warn = buildWarn(buildCtx.diagnostics);
57210
- warn.header = `Stencil Config`;
57211
- warn.messageText = `Component tag "${tag}" is defined in a bundle but no matching component was found within this app or its collections.`;
57212
- }
57213
- if (definedTags.has(tag)) {
57214
- const warn = buildWarn(buildCtx.diagnostics);
57215
- warn.header = `Stencil Config`;
57216
- warn.messageText = `Component tag "${tag}" has been defined multiple times in the "bundles" config.`;
57217
- }
57218
- definedTags.add(tag);
57219
- return component;
57220
- })
57221
- .sort();
57222
- });
57223
- return entryTags;
57224
- }
57225
-
57226
- // MODULE: compiler/entries/component-bundles.js
57227
- function computeUsedComponents(config, defaultBundles, allCmps) {
57228
- if (!config.excludeUnusedDependencies) {
57229
- return new Set(allCmps.map((c) => c.tagName));
57230
- }
57231
- const usedComponents = new Set();
57232
- // All components
57233
- defaultBundles.forEach((entry) => {
57234
- entry.forEach((cmp) => usedComponents.add(cmp.tagName));
57235
- });
57236
- allCmps.forEach((cmp) => {
57237
- if (!cmp.isCollectionDependency) {
57238
- usedComponents.add(cmp.tagName);
57239
- }
57240
- });
57241
- allCmps.forEach((cmp) => {
57242
- if (cmp.isCollectionDependency) {
57243
- if (cmp.dependents.some((dep) => usedComponents.has(dep))) {
57244
- usedComponents.add(cmp.tagName);
57245
- }
57246
- }
57247
- });
57248
- return usedComponents;
57249
- }
57250
- function generateComponentBundles(config, buildCtx) {
57251
- const cmps = sortBy(buildCtx.components, (cmp) => cmp.dependents.length);
57252
- const defaultBundles = getDefaultBundles(config, buildCtx, cmps);
57253
- const usedComponents = computeUsedComponents(config, defaultBundles, cmps);
57254
- if (config.devMode) {
57255
- return cmps.filter((c) => usedComponents.has(c.tagName)).map((cmp) => [cmp]);
57256
- }
57257
- // Visit components that are already in one of the default bundlers
57258
- const alreadyBundled = new Set();
57259
- defaultBundles.forEach((entry) => {
57260
- entry.forEach((cmp) => alreadyBundled.add(cmp));
57261
- });
57262
- const bundlers = cmps
57263
- .filter((cmp) => usedComponents.has(cmp.tagName) && !alreadyBundled.has(cmp))
57264
- .map((c) => [c]);
57265
- return [...defaultBundles, ...optimizeBundlers(bundlers, 0.6)].filter((b) => b.length > 0);
57266
- }
57267
- function optimizeBundlers(bundles, threshold) {
57268
- const cmpIndexMap = new Map();
57269
- bundles.forEach((entry, index) => {
57270
- entry.forEach((cmp) => {
57271
- cmpIndexMap.set(cmp.tagName, index);
57272
- });
57273
- });
57274
- const visited = new Uint8Array(bundles.length);
57275
- const matrix = bundles.map((entry) => {
57276
- const vector = new Uint8Array(bundles.length);
57277
- entry.forEach((cmp) => {
57278
- cmp.dependents.forEach((tag) => {
57279
- const index = cmpIndexMap.get(tag);
57280
- if (index !== undefined) {
57281
- vector[index] = 1;
57282
- }
57283
- });
57284
- });
57285
- entry.forEach((cmp) => {
57286
- const index = cmpIndexMap.get(cmp.tagName);
57287
- if (index !== undefined) {
57288
- vector[index] = 0;
57289
- }
57290
- });
57291
- return vector;
57292
- });
57293
- // resolve similar components
57294
- const newBundles = [];
57295
- for (let i = 0; i < matrix.length; i++) {
57296
- // check if bundle is visited (0 means it's not)
57297
- if (visited[i] === 0) {
57298
- const bundle = [...bundles[i]];
57299
- visited[i] = 1;
57300
- for (let j = i + 1; j < matrix.length; j++) {
57301
- if (visited[j] === 0 && computeScore(matrix[i], matrix[j]) >= threshold) {
57302
- bundle.push(...bundles[j]);
57303
- visited[j] = 1;
57304
- }
57305
- }
57306
- newBundles.push(bundle);
57307
- }
57308
- }
57309
- return newBundles;
57310
- }
57311
- function computeScore(m0, m1) {
57312
- let total = 0;
57313
- let match = 0;
57314
- for (let i = 0; i < m0.length; i++) {
57315
- if (m0[i] === 1 || m1[i] === 1) {
57316
- total++;
57317
- if (m0[i] === m1[i]) {
57318
- match++;
57319
- }
57320
- }
57321
- }
57322
- return match / total;
57323
- }
57324
-
57325
- // MODULE: compiler/entries/entry-modules.js
57326
- function generateEntryModules(config, buildCtx) {
57327
- // figure out how modules and components connect
57328
- try {
57329
- const bundles = generateComponentBundles(config, buildCtx);
57330
- buildCtx.entryModules = bundles.map(createEntryModule);
57331
- }
57332
- catch (e) {
57333
- catchError(buildCtx.diagnostics, e);
57334
- }
57335
- buildCtx.debug(`generateEntryModules, ${buildCtx.entryModules.length} entryModules`);
57336
- }
57337
- function createEntryModule(cmps) {
57338
- // generate a unique entry key based on the components within this entry module
57339
- cmps = sortBy(cmps, (c) => c.tagName);
57340
- const entryKey = cmps.map((c) => c.tagName).join('.') + '.entry';
57341
- return {
57342
- cmps,
57343
- entryKey,
57344
- };
57345
- }
57346
-
57347
57166
  // MODULE: compiler/output-targets/dist-lazy/lazy-build-conditionals.js
57348
57167
  const getLazyBuildConditionals = (config, cmps) => {
57349
57168
  const build = getBuildFeatures(cmps);
@@ -57882,6 +57701,258 @@ const generateModuleGraph = (cmps, bundleModules) => {
57882
57701
  return cmpMap;
57883
57702
  };
57884
57703
 
57704
+ // MODULE: compiler/html/used-components.js
57705
+ /**
57706
+ * Scan the provided `doc` for any known Stencil components
57707
+ * @param doc the Document to scan
57708
+ * @param cmps the compiler metadata of known Stencil components
57709
+ * @returns a list of all tags that were identified as known Stencil components
57710
+ */
57711
+ const getUsedComponents = (doc, cmps) => {
57712
+ const tags = new Set(cmps.map((cmp) => cmp.tagName.toUpperCase()));
57713
+ const found = [];
57714
+ const searchComponents = (el) => {
57715
+ if (tags.has(el.tagName)) {
57716
+ found.push(el.tagName.toLowerCase());
57717
+ }
57718
+ for (let i = 0; i < el.childElementCount; i++) {
57719
+ searchComponents(el.children[i]);
57720
+ }
57721
+ };
57722
+ searchComponents(doc.documentElement);
57723
+ return found;
57724
+ };
57725
+
57726
+ // MODULE: compiler/entries/default-bundles.js
57727
+ /**
57728
+ * Retrieve the component bundle groupings to be used when generating output
57729
+ * @param config the Stencil configuration used for the build
57730
+ * @param buildCtx the current build context
57731
+ * @param cmps the components that have been registered & defined for the current build
57732
+ * @returns the component bundling data
57733
+ */
57734
+ function getDefaultBundles(config, buildCtx, cmps) {
57735
+ // get all of the user defined bundles in the Stencil config file
57736
+ const userConfigEntryPoints = getUserConfigBundles(config, buildCtx, cmps);
57737
+ if (userConfigEntryPoints.length > 0) {
57738
+ // prefer user defined entry points over anything else Stencil may derive
57739
+ return userConfigEntryPoints;
57740
+ }
57741
+ let entryPointsHints = config.entryComponentsHint;
57742
+ if (!entryPointsHints && buildCtx.indexDoc) {
57743
+ // attempt to scan an HTML file for known Stencil components
57744
+ entryPointsHints = getUsedComponents(buildCtx.indexDoc, cmps);
57745
+ }
57746
+ if (!entryPointsHints) {
57747
+ return [];
57748
+ }
57749
+ const mainBundle = unique([
57750
+ ...entryPointsHints,
57751
+ ...flatOne(entryPointsHints.map(resolveTag).map((cmp) => cmp.dependencies)),
57752
+ ]).map(resolveTag);
57753
+ function resolveTag(tag) {
57754
+ return cmps.find((cmp) => cmp.tagName === tag);
57755
+ }
57756
+ return [mainBundle];
57757
+ }
57758
+ /**
57759
+ * Retrieve and validate the `bundles` field on a project's Stencil configuration file
57760
+ * @param config the configuration file with a `bundles` field to inspect
57761
+ * @param buildCtx the current build context
57762
+ * @param cmps the components that have been registered & defined for the current build
57763
+ * @returns a three dimensional array with the compiler metadata for each component used
57764
+ */
57765
+ function getUserConfigBundles(config, buildCtx, cmps) {
57766
+ const definedTags = new Set();
57767
+ const entryTags = config.bundles.map((b) => {
57768
+ return b.components
57769
+ .map((tag) => {
57770
+ const tagError = validateComponentTag(tag);
57771
+ if (tagError) {
57772
+ const err = buildError(buildCtx.diagnostics);
57773
+ err.header = `Stencil Config`;
57774
+ err.messageText = tagError;
57775
+ }
57776
+ const component = cmps.find((cmp) => cmp.tagName === tag);
57777
+ if (!component) {
57778
+ const warn = buildWarn(buildCtx.diagnostics);
57779
+ warn.header = `Stencil Config`;
57780
+ warn.messageText = `Component tag "${tag}" is defined in a bundle but no matching component was found within this app or its collections.`;
57781
+ }
57782
+ if (definedTags.has(tag)) {
57783
+ const warn = buildWarn(buildCtx.diagnostics);
57784
+ warn.header = `Stencil Config`;
57785
+ warn.messageText = `Component tag "${tag}" has been defined multiple times in the "bundles" config.`;
57786
+ }
57787
+ definedTags.add(tag);
57788
+ return component;
57789
+ })
57790
+ .sort();
57791
+ });
57792
+ return entryTags;
57793
+ }
57794
+
57795
+ // MODULE: compiler/entries/component-bundles.js
57796
+ /**
57797
+ * Generate a list of all component tags that will be used by the output
57798
+ * @param config the Stencil configuration used for the build
57799
+ * @param defaultBundles metadata of the assumed components being used/bundled
57800
+ * @param allCmps all known components
57801
+ * @returns a set of all component tags that are used
57802
+ */
57803
+ function computeUsedComponents(config, defaultBundles, allCmps) {
57804
+ if (!config.excludeUnusedDependencies) {
57805
+ // the user/config has specified that Stencil should use all the dependencies it's found, return the set of all
57806
+ // known tags
57807
+ return new Set(allCmps.map((c) => c.tagName));
57808
+ }
57809
+ const usedComponents = new Set();
57810
+ // All components
57811
+ defaultBundles.forEach((entry) => {
57812
+ entry.forEach((cmp) => usedComponents.add(cmp.tagName));
57813
+ });
57814
+ allCmps.forEach((cmp) => {
57815
+ if (!cmp.isCollectionDependency) {
57816
+ usedComponents.add(cmp.tagName);
57817
+ }
57818
+ });
57819
+ allCmps.forEach((cmp) => {
57820
+ if (cmp.isCollectionDependency) {
57821
+ if (cmp.dependents.some((dep) => usedComponents.has(dep))) {
57822
+ usedComponents.add(cmp.tagName);
57823
+ }
57824
+ }
57825
+ });
57826
+ return usedComponents;
57827
+ }
57828
+ /**
57829
+ * Generate the bundles that will be used during the bundling process
57830
+ * @param config the Stencil configuration used for the build
57831
+ * @param buildCtx the current build context
57832
+ * @returns the bundles to be used during the bundling process
57833
+ */
57834
+ function generateComponentBundles(config, buildCtx) {
57835
+ const cmps = sortBy(buildCtx.components, (cmp) => cmp.dependents.length);
57836
+ const defaultBundles = getDefaultBundles(config, buildCtx, cmps);
57837
+ const usedComponents = computeUsedComponents(config, defaultBundles, cmps);
57838
+ if (config.devMode) {
57839
+ return cmps
57840
+ .filter((c) => usedComponents.has(c.tagName))
57841
+ .map((cmp) => [cmp]);
57842
+ }
57843
+ // Visit components that are already in one of the default bundlers
57844
+ const alreadyBundled = new Set();
57845
+ defaultBundles.forEach((entry) => {
57846
+ entry.forEach((cmp) => alreadyBundled.add(cmp));
57847
+ });
57848
+ const bundlers = cmps
57849
+ .filter((cmp) => usedComponents.has(cmp.tagName) && !alreadyBundled.has(cmp))
57850
+ .map((c) => [c]);
57851
+ return [...defaultBundles, ...optimizeBundlers(bundlers, 0.6)].filter((b) => b.length > 0);
57852
+ }
57853
+ /**
57854
+ * Calculate and reorganize bundles based on a calculated similarity score between bundle entries
57855
+ * @param bundles the bundles to reorganize
57856
+ * @param threshold a numeric value used to determine whether or not bundles should be reorganized
57857
+ * @returns the reorganized bundles
57858
+ */
57859
+ function optimizeBundlers(bundles, threshold) {
57860
+ /**
57861
+ * build a mapping of component tag names in each `bundles` entry to the index where that entry occurs in `bundles`:
57862
+ * ```ts
57863
+ * bundles = [
57864
+ * [
57865
+ * {
57866
+ * tagName: 'my-foo', ...<other_fields>,
57867
+ * },
57868
+ * ],
57869
+ * [
57870
+ * {
57871
+ * tagName: 'my-bar', ...<other_fields>,
57872
+ * },
57873
+ * {
57874
+ * tagName: 'my-baz', ...<other_fields>,
57875
+ * },
57876
+ * ],
57877
+ * ];
57878
+ * // yields
57879
+ * {
57880
+ * 'my-foo': 0,
57881
+ * 'my-bar': 1,
57882
+ * 'my-baz': 1,
57883
+ * }
57884
+ * ```
57885
+ * note that in the event of a component being found >1 time, store the index of the last entry in which it's found
57886
+ */
57887
+ const cmpIndexMap = new Map();
57888
+ bundles.forEach((entry, index) => {
57889
+ entry.forEach((cmp) => {
57890
+ cmpIndexMap.set(cmp.tagName, index);
57891
+ });
57892
+ });
57893
+ // build a record of components
57894
+ const matrix = bundles.map((entry) => {
57895
+ const vector = new Uint8Array(bundles.length);
57896
+ entry.forEach((cmp) => {
57897
+ // for each dependent of a component, check to see if the dependent has been seen already when the `cmpIndexMap`
57898
+ // was originally built. If so, mark it with a '1'
57899
+ cmp.dependents.forEach((tag) => {
57900
+ const index = cmpIndexMap.get(tag);
57901
+ if (index !== undefined) {
57902
+ vector[index] = 1;
57903
+ }
57904
+ });
57905
+ });
57906
+ entry.forEach((cmp) => {
57907
+ // for each entry, check to see if the component has been seen already when the `cmpIndexMap` was originally
57908
+ // built. If so, mark it with a '0', potentially overriding a previously set value on the vector.
57909
+ const index = cmpIndexMap.get(cmp.tagName);
57910
+ if (index !== undefined) {
57911
+ vector[index] = 0;
57912
+ }
57913
+ });
57914
+ return vector;
57915
+ });
57916
+ // resolve similar components
57917
+ const newBundles = [];
57918
+ const visited = new Uint8Array(bundles.length);
57919
+ for (let i = 0; i < matrix.length; i++) {
57920
+ // check if bundle is visited (0 means it's not)
57921
+ if (visited[i] === 0) {
57922
+ const bundle = [...bundles[i]];
57923
+ visited[i] = 1;
57924
+ for (let j = i + 1; j < matrix.length; j++) {
57925
+ if (visited[j] === 0 && computeScore(matrix[i], matrix[j]) >= threshold) {
57926
+ bundle.push(...bundles[j]);
57927
+ visited[j] = 1;
57928
+ }
57929
+ }
57930
+ newBundles.push(bundle);
57931
+ }
57932
+ }
57933
+ return newBundles;
57934
+ }
57935
+ /**
57936
+ * Computes a 'score' between two arrays, that is defined as the number of times that the value at a given index is the
57937
+ * same in both arrays divided by the number of times the value in either array is high at the given index.
57938
+ * @param m0 the first array to calculate sameness with
57939
+ * @param m1 the second array to calculate sameness with
57940
+ * @returns the calculated score
57941
+ */
57942
+ function computeScore(m0, m1) {
57943
+ let total = 0;
57944
+ let match = 0;
57945
+ for (let i = 0; i < m0.length; i++) {
57946
+ if (m0[i] === 1 || m1[i] === 1) {
57947
+ total++;
57948
+ if (m0[i] === m1[i]) {
57949
+ match++;
57950
+ }
57951
+ }
57952
+ }
57953
+ return match / total;
57954
+ }
57955
+
57885
57956
  // MODULE: compiler/output-targets/dist-lazy/lazy-output.js
57886
57957
  const outputLazy = async (config, compilerCtx, buildCtx) => {
57887
57958
  const outputTargets = config.outputTargets.filter(isOutputTargetDistLazy);
@@ -57964,6 +58035,36 @@ const getLazyCustomTransformer = (config, compilerCtx) => {
57964
58035
  removeCollectionImports(compilerCtx),
57965
58036
  ];
57966
58037
  };
58038
+ /**
58039
+ * Generate entry modules to be used by the build process by determining how modules and components are connected
58040
+ * @param config the Stencil configuration file that was provided as a part of the build step
58041
+ * @param buildCtx the current build context
58042
+ */
58043
+ function generateEntryModules(config, buildCtx) {
58044
+ // figure out how modules and components connect
58045
+ try {
58046
+ const bundles = generateComponentBundles(config, buildCtx);
58047
+ buildCtx.entryModules = bundles.map(createEntryModule);
58048
+ }
58049
+ catch (e) {
58050
+ catchError(buildCtx.diagnostics, e);
58051
+ }
58052
+ buildCtx.debug(`generateEntryModules, ${buildCtx.entryModules.length} entryModules`);
58053
+ }
58054
+ /**
58055
+ * Generates an entry module to be used during the bundling process
58056
+ * @param cmps the component metadata to create a single entry module from
58057
+ * @returns the entry module generated
58058
+ */
58059
+ function createEntryModule(cmps) {
58060
+ // generate a unique entry key based on the components within this entry module
58061
+ cmps = sortBy(cmps, (c) => c.tagName);
58062
+ const entryKey = cmps.map((c) => c.tagName).join('.') + '.entry';
58063
+ return {
58064
+ cmps,
58065
+ entryKey,
58066
+ };
58067
+ }
57967
58068
  const getLazyEntry = (isBrowser) => {
57968
58069
  const s = new MagicString$2(``);
57969
58070
  s.append(`import { bootstrapLazy } from '${STENCIL_CORE_ID}';\n`);
@@ -58604,7 +58705,39 @@ const generateIndexHtml = async (config, compilerCtx, buildCtx, criticalPath, ou
58604
58705
  };
58605
58706
  const MAX_CSS_INLINE_SIZE = 3 * 1024;
58606
58707
 
58607
- // MODULE: compiler/output-targets/output-collection.js
58708
+ // MODULE: compiler/output-targets/dist-collection/index.js
58709
+ const outputCollection = async (config, compilerCtx, buildCtx, changedModuleFiles) => {
58710
+ const outputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
58711
+ if (outputTargets.length === 0) {
58712
+ return;
58713
+ }
58714
+ const bundlingEventMessage = `generate collections${config.sourceMap ? ' + source maps' : ''}`;
58715
+ const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`, true);
58716
+ try {
58717
+ await Promise.all(changedModuleFiles.map(async (mod) => {
58718
+ let code = mod.staticSourceFileText;
58719
+ if (config.preamble) {
58720
+ code = `${generatePreamble(config)}\n${code}`;
58721
+ }
58722
+ const mapCode = mod.sourceMapFileText;
58723
+ await Promise.all(outputTargets.map(async (o) => {
58724
+ const relPath = relative$1(config.srcDir, mod.jsFilePath);
58725
+ const filePath = join(o.collectionDir, relPath);
58726
+ await compilerCtx.fs.writeFile(filePath, code, { outputTargetType: o.type });
58727
+ if (mod.sourceMapPath) {
58728
+ const relativeSourceMapPath = relative$1(config.srcDir, mod.sourceMapPath);
58729
+ const sourceMapOutputFilePath = join(o.collectionDir, relativeSourceMapPath);
58730
+ await compilerCtx.fs.writeFile(sourceMapOutputFilePath, mapCode, { outputTargetType: o.type });
58731
+ }
58732
+ }));
58733
+ }));
58734
+ await writeCollectionManifests(config, compilerCtx, buildCtx, outputTargets);
58735
+ }
58736
+ catch (e) {
58737
+ catchError(buildCtx.diagnostics, e);
58738
+ }
58739
+ timespan.finish(`${bundlingEventMessage} finished`);
58740
+ };
58608
58741
  const writeCollectionManifests = async (config, compilerCtx, buildCtx, outputTargets) => {
58609
58742
  const collectionData = JSON.stringify(serializeCollectionManifest(config, compilerCtx, buildCtx), null, 2);
58610
58743
  return Promise.all(outputTargets.map((o) => writeCollectionManifest(compilerCtx, collectionData, o)));
@@ -58656,40 +58789,6 @@ const serializeCollectionDependencies = (compilerCtx) => {
58656
58789
  return sortBy(collectionDeps, (item) => item.name);
58657
58790
  };
58658
58791
 
58659
- // MODULE: compiler/output-targets/dist-collection/index.js
58660
- const outputCollection = async (config, compilerCtx, buildCtx, changedModuleFiles) => {
58661
- const outputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
58662
- if (outputTargets.length === 0) {
58663
- return;
58664
- }
58665
- const bundlingEventMessage = `generate collections${config.sourceMap ? ' + source maps' : ''}`;
58666
- const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`, true);
58667
- try {
58668
- await Promise.all(changedModuleFiles.map(async (mod) => {
58669
- let code = mod.staticSourceFileText;
58670
- if (config.preamble) {
58671
- code = `${generatePreamble(config)}\n${code}`;
58672
- }
58673
- const mapCode = mod.sourceMapFileText;
58674
- await Promise.all(outputTargets.map(async (o) => {
58675
- const relPath = relative$1(config.srcDir, mod.jsFilePath);
58676
- const filePath = join(o.collectionDir, relPath);
58677
- await compilerCtx.fs.writeFile(filePath, code, { outputTargetType: o.type });
58678
- if (mod.sourceMapPath) {
58679
- const relativeSourceMapPath = relative$1(config.srcDir, mod.sourceMapPath);
58680
- const sourceMapOutputFilePath = join(o.collectionDir, relativeSourceMapPath);
58681
- await compilerCtx.fs.writeFile(sourceMapOutputFilePath, mapCode, { outputTargetType: o.type });
58682
- }
58683
- }));
58684
- }));
58685
- await writeCollectionManifests(config, compilerCtx, buildCtx, outputTargets);
58686
- }
58687
- catch (e) {
58688
- catchError(buildCtx.diagnostics, e);
58689
- }
58690
- timespan.finish(`${bundlingEventMessage} finished`);
58691
- };
58692
-
58693
58792
  // MODULE: compiler/types/stencil-types.js
58694
58793
  const updateStencilTypesImports = (typesDir, dtsFilePath, dtsContent) => {
58695
58794
  const dir = dirname(dtsFilePath);
@@ -63818,7 +63917,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
63818
63917
  const dependencies = [
63819
63918
  {
63820
63919
  name: "@stencil/core",
63821
- version: "2.10.0",
63920
+ version: "2.11.0-0",
63822
63921
  main: "compiler/stencil.js",
63823
63922
  resources: [
63824
63923
  "package.json",