@stencil/core 4.40.1 → 4.41.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.
Files changed (45) hide show
  1. package/cli/config-flags.d.ts +2 -2
  2. package/cli/index.cjs +9 -4
  3. package/cli/index.js +9 -4
  4. package/cli/package.json +1 -1
  5. package/compiler/package.json +1 -1
  6. package/compiler/stencil.js +268 -136
  7. package/dev-server/client/index.js +12 -12
  8. package/dev-server/client/package.json +1 -1
  9. package/dev-server/connector.html +3 -3
  10. package/dev-server/index.js +2 -2
  11. package/dev-server/package.json +1 -1
  12. package/dev-server/server-process.js +18 -11
  13. package/internal/app-data/package.json +1 -1
  14. package/internal/app-globals/package.json +1 -1
  15. package/internal/client/index.js +105 -25
  16. package/internal/client/package.json +1 -1
  17. package/internal/client/patch-browser.js +1 -1
  18. package/internal/hydrate/index.js +64 -25
  19. package/internal/hydrate/package.json +1 -1
  20. package/internal/hydrate/runner.js +196 -135
  21. package/internal/package.json +1 -1
  22. package/internal/stencil-core/jsx-dev-runtime.cjs +7 -0
  23. package/internal/stencil-core/jsx-dev-runtime.d.ts +23 -0
  24. package/internal/stencil-core/jsx-dev-runtime.js +2 -0
  25. package/internal/stencil-core/jsx-runtime.cjs +8 -0
  26. package/internal/stencil-core/jsx-runtime.d.ts +22 -0
  27. package/internal/stencil-core/jsx-runtime.js +2 -0
  28. package/internal/stencil-private.d.ts +20 -0
  29. package/internal/stencil-public-compiler.d.ts +6 -0
  30. package/internal/stencil-public-docs.d.ts +11 -0
  31. package/internal/stencil-public-runtime.d.ts +29 -0
  32. package/internal/testing/index.js +753 -638
  33. package/internal/testing/package.json +1 -1
  34. package/mock-doc/index.cjs +192 -135
  35. package/mock-doc/index.js +193 -135
  36. package/mock-doc/package.json +1 -1
  37. package/package.json +11 -1
  38. package/screenshot/index.js +29 -8
  39. package/screenshot/package.json +1 -1
  40. package/screenshot/pixel-match.js +1 -1
  41. package/sys/node/index.js +29 -29
  42. package/sys/node/package.json +1 -1
  43. package/sys/node/worker.js +1 -1
  44. package/testing/index.js +98 -70
  45. package/testing/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Stencil Compiler v4.40.1 | MIT Licensed | https://stenciljs.com
2
+ Stencil Compiler v4.41.0 | MIT Licensed | https://stenciljs.com
3
3
  */
4
4
  "use strict";
5
5
  var __create = Object.create;
@@ -25074,8 +25074,8 @@ ${lanes.join("\n")}
25074
25074
  return option.strictFlag ? getStrictOptionValue(options, option.name) : option.allowJsFlag ? getAllowJSCompilerOption(options) : options[option.name];
25075
25075
  }
25076
25076
  function getJSXTransformEnabled(options) {
25077
- const jsx = options.jsx;
25078
- return jsx === 2 || jsx === 4 || jsx === 5;
25077
+ const jsx2 = options.jsx;
25078
+ return jsx2 === 2 || jsx2 === 4 || jsx2 === 5;
25079
25079
  }
25080
25080
  function getJSXImplicitImportBase(compilerOptions, file) {
25081
25081
  const jsxImportSourcePragmas = file == null ? void 0 : file.pragmas.get("jsximportsource");
@@ -153086,8 +153086,8 @@ ${lanes.join("\n")}
153086
153086
  /* Ignore */
153087
153087
  };
153088
153088
  }
153089
- function jsxModeNeedsExplicitImport(jsx) {
153090
- return jsx === 2 || jsx === 3;
153089
+ function jsxModeNeedsExplicitImport(jsx2) {
153090
+ return jsx2 === 2 || jsx2 === 3;
153091
153091
  }
153092
153092
  function isSourceFileFromLibrary(program3, node) {
153093
153093
  return program3.isSourceFileFromExternalLibrary(node) || program3.isSourceFileDefaultLibrary(node);
@@ -178305,8 +178305,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
178305
178305
  return binaryExpr;
178306
178306
  }
178307
178307
  function doChange38(changeTracker, sf, node) {
178308
- const jsx = flattenInvalidBinaryExpr(node);
178309
- if (jsx) changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
178308
+ const jsx2 = flattenInvalidBinaryExpr(node);
178309
+ if (jsx2) changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx2, factory.createJsxJsxClosingFragment()));
178310
178310
  }
178311
178311
  function flattenInvalidBinaryExpr(node) {
178312
178312
  const children = [];
@@ -226972,7 +226972,7 @@ var init_parseAst = __esm({
226972
226972
  };
226973
226973
  }
226974
226974
  ];
226975
- parseAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => convertProgram(getAstBuffer((0, import_native.parse)(input, allowReturnOutsideFunction, jsx)));
226975
+ parseAst = (input, { allowReturnOutsideFunction = false, jsx: jsx2 = false } = {}) => convertProgram(getAstBuffer((0, import_native.parse)(input, allowReturnOutsideFunction, jsx2)));
226976
226976
  }
226977
226977
  });
226978
226978
 
@@ -239392,12 +239392,12 @@ var init_node_entry = __esm({
239392
239392
  }
239393
239393
  }
239394
239394
  getRenderingMode() {
239395
- const jsx = this.scope.context.options.jsx;
239396
- const { mode, factory, importSource } = jsx;
239395
+ const jsx2 = this.scope.context.options.jsx;
239396
+ const { mode, factory, importSource } = jsx2;
239397
239397
  if (mode === "automatic") {
239398
239398
  return {
239399
239399
  factory: getRenderedJsxChildren(this.children) > 1 ? "jsxs" : "jsx",
239400
- importSource: jsx.jsxImportSource,
239400
+ importSource: jsx2.jsxImportSource,
239401
239401
  mode
239402
239402
  };
239403
239403
  }
@@ -239449,8 +239449,8 @@ var init_node_entry = __esm({
239449
239449
  }
239450
239450
  }
239451
239451
  getRenderingMode() {
239452
- const jsx = this.scope.context.options.jsx;
239453
- const { mode, factory, importSource } = jsx;
239452
+ const jsx2 = this.scope.context.options.jsx;
239453
+ const { mode, factory, importSource } = jsx2;
239454
239454
  if (mode === "automatic") {
239455
239455
  let hasSpread = false;
239456
239456
  for (const attribute of this.openingElement.attributes) {
@@ -239659,12 +239659,12 @@ var init_node_entry = __esm({
239659
239659
  this.included = true;
239660
239660
  if (!this.deoptimized)
239661
239661
  this.applyDeoptimizations();
239662
- const jsx = this.scope.context.options.jsx;
239663
- if (jsx.mode === "automatic") {
239662
+ const jsx2 = this.scope.context.options.jsx;
239663
+ if (jsx2.mode === "automatic") {
239664
239664
  this.fragment = "Fragment";
239665
- this.fragmentVariable = getAndIncludeFactoryVariable("Fragment", false, jsx.jsxImportSource, this, context);
239665
+ this.fragmentVariable = getAndIncludeFactoryVariable("Fragment", false, jsx2.jsxImportSource, this, context);
239666
239666
  } else {
239667
- const { fragment, importSource, mode } = jsx;
239667
+ const { fragment, importSource, mode } = jsx2;
239668
239668
  if (fragment != null) {
239669
239669
  this.fragment = fragment;
239670
239670
  this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === "preserve", importSource, this, context);
@@ -245765,7 +245765,7 @@ var import_typescript72 = __toESM(require_typescript_5_8_3_bundle_cache_min());
245765
245765
 
245766
245766
  // src/version.ts
245767
245767
  init_import_meta_url();
245768
- var buildId = "1766528469";
245768
+ var buildId = "1767392397";
245769
245769
  var minfyJsId = "terser5.37.0_7";
245770
245770
  var optimizeCssId = "autoprefixer10.4.19_postcss8.5.6_7";
245771
245771
  var parse5Version = "7.2.1";
@@ -245773,8 +245773,8 @@ var rollupVersion = "4.34.9";
245773
245773
  var jqueryVersion = "4.0.0-pre";
245774
245774
  var terserVersion = "5.37.0";
245775
245775
  var typescriptVersion = "5.8.3";
245776
- var vermoji = "\u{1F402}";
245777
- var version = "4.40.1";
245776
+ var vermoji = "\u{1F3C2}";
245777
+ var version = "4.41.0";
245778
245778
  var versions = {
245779
245779
  stencil: version,
245780
245780
  parse5: parse5Version,
@@ -248940,6 +248940,12 @@ init_import_meta_url();
248940
248940
  // src/runtime/tag-transform.ts
248941
248941
  init_import_meta_url();
248942
248942
 
248943
+ // src/runtime/vdom/jsx-dev-runtime.ts
248944
+ init_import_meta_url();
248945
+
248946
+ // src/runtime/vdom/jsx-runtime.ts
248947
+ init_import_meta_url();
248948
+
248943
248949
  // src/runtime/vdom/vdom-annotations.ts
248944
248950
  init_import_meta_url();
248945
248951
 
@@ -249229,35 +249235,36 @@ var buildEvents = () => {
249229
249235
 
249230
249236
  // src/compiler/build/compiler-ctx.ts
249231
249237
  var CompilerContext = class {
249232
- constructor() {
249233
- this.version = 2;
249234
- this.activeBuildId = -1;
249235
- this.activeFilesAdded = [];
249236
- this.activeFilesDeleted = [];
249237
- this.activeFilesUpdated = [];
249238
- this.activeDirsAdded = [];
249239
- this.activeDirsDeleted = [];
249240
- this.addWatchDir = noop;
249241
- this.addWatchFile = noop;
249242
- this.cssModuleImports = /* @__PURE__ */ new Map();
249243
- this.changedFiles = /* @__PURE__ */ new Set();
249244
- this.changedModules = /* @__PURE__ */ new Set();
249245
- this.collections = [];
249246
- this.compilerOptions = null;
249247
- this.events = buildEvents();
249248
- this.hasSuccessfulBuild = false;
249249
- this.isActivelyBuilding = false;
249250
- this.lastBuildResults = null;
249251
- this.moduleMap = /* @__PURE__ */ new Map();
249252
- this.nodeMap = /* @__PURE__ */ new WeakMap();
249253
- this.resolvedCollections = /* @__PURE__ */ new Set();
249254
- this.rollupCache = /* @__PURE__ */ new Map();
249255
- this.rollupCacheHydrate = null;
249256
- this.rollupCacheLazy = null;
249257
- this.rollupCacheNative = null;
249258
- this.styleModeNames = /* @__PURE__ */ new Set();
249259
- this.worker = null;
249260
- }
249238
+ version = 2;
249239
+ activeBuildId = -1;
249240
+ activeFilesAdded = [];
249241
+ activeFilesDeleted = [];
249242
+ activeFilesUpdated = [];
249243
+ activeDirsAdded = [];
249244
+ activeDirsDeleted = [];
249245
+ addWatchDir = noop;
249246
+ addWatchFile = noop;
249247
+ cache;
249248
+ cssModuleImports = /* @__PURE__ */ new Map();
249249
+ changedFiles = /* @__PURE__ */ new Set();
249250
+ changedModules = /* @__PURE__ */ new Set();
249251
+ collections = [];
249252
+ compilerOptions = null;
249253
+ events = buildEvents();
249254
+ fs;
249255
+ hasSuccessfulBuild = false;
249256
+ isActivelyBuilding = false;
249257
+ lastBuildResults = null;
249258
+ moduleMap = /* @__PURE__ */ new Map();
249259
+ nodeMap = /* @__PURE__ */ new WeakMap();
249260
+ resolvedCollections = /* @__PURE__ */ new Set();
249261
+ rollupCache = /* @__PURE__ */ new Map();
249262
+ rollupCacheHydrate = null;
249263
+ rollupCacheLazy = null;
249264
+ rollupCacheNative = null;
249265
+ cachedGlobalStyle;
249266
+ styleModeNames = /* @__PURE__ */ new Set();
249267
+ worker = null;
249261
249268
  reset() {
249262
249269
  this.cache.clear();
249263
249270
  this.cssModuleImports.clear();
@@ -250521,15 +250528,18 @@ var getTypeReferenceLocation = (typeName, type, sourceFile, checker, program3) =
250521
250528
  const compilerHost = import_typescript9.default.createCompilerHost(options);
250522
250529
  const importHomeModule = getHomeModule(sourceFile, localImportPath, options, compilerHost, program3);
250523
250530
  if (importHomeModule) {
250524
- const importName = namedImportBindings.elements.find((nbe) => nbe.name.getText() === typeName).name;
250531
+ const importElement = namedImportBindings.elements.find((nbe) => nbe.name.getText() === typeName);
250532
+ const importName = importElement.name;
250525
250533
  const originalTypeName = getOriginalTypeName(importName, checker);
250534
+ const importedAs = importElement.propertyName ? importElement.propertyName.getText() : typeName;
250526
250535
  const typeDecl = findTypeWithName(importHomeModule, originalTypeName);
250527
250536
  type = checker.getTypeAtLocation(typeDecl);
250528
250537
  const id = addToLibrary(type, originalTypeName, checker, normalizePath(importHomeModule.fileName, false));
250529
250538
  return {
250530
250539
  location: "import",
250531
250540
  path: localImportPath,
250532
- id
250541
+ id,
250542
+ referenceLocation: importedAs
250533
250543
  };
250534
250544
  }
250535
250545
  }
@@ -250558,6 +250568,35 @@ var getTypeReferenceLocation = (typeName, type, sourceFile, checker, program3) =
250558
250568
  id
250559
250569
  };
250560
250570
  }
250571
+ const defaultImportDeclaration = sourceFile.statements.find((st) => {
250572
+ if (!import_typescript9.default.isImportDeclaration(st) || !st.importClause) {
250573
+ return false;
250574
+ }
250575
+ const defaultImportName = st.importClause.name;
250576
+ return defaultImportName && defaultImportName.getText() === typeName;
250577
+ });
250578
+ if (defaultImportDeclaration) {
250579
+ const localImportPath = defaultImportDeclaration.moduleSpecifier.text;
250580
+ const options = program3.getCompilerOptions();
250581
+ const compilerHost = import_typescript9.default.createCompilerHost(options);
250582
+ const importHomeModule = getHomeModule(sourceFile, localImportPath, options, compilerHost, program3);
250583
+ if (importHomeModule) {
250584
+ const defaultExport = importHomeModule.statements.find(
250585
+ (st) => import_typescript9.default.isExportAssignment(st) && !st.isExportEquals && import_typescript9.default.isIdentifier(st.expression) && st.expression.getText() === typeName
250586
+ );
250587
+ if (defaultExport) {
250588
+ const typeDecl = findTypeWithName(importHomeModule, typeName);
250589
+ type = checker.getTypeAtLocation(typeDecl);
250590
+ const id = addToLibrary(type, typeName, checker, normalizePath(importHomeModule.fileName, false));
250591
+ return {
250592
+ location: "import",
250593
+ path: localImportPath,
250594
+ id,
250595
+ isDefault: true
250596
+ };
250597
+ }
250598
+ }
250599
+ }
250561
250600
  return {
250562
250601
  location: "global",
250563
250602
  id: "global::" + typeName
@@ -256234,6 +256273,18 @@ var appDataPlugin = (config, compilerCtx, buildCtx, buildConditionals, platform)
256234
256273
  if (globalScripts.some((s) => s.path === id)) {
256235
256274
  const program3 = this.parse(code, {});
256236
256275
  const needsDefault = !program3.body.some((s) => s.type === "ExportDefaultDeclaration");
256276
+ if (needsDefault) {
256277
+ const diagnostic = {
256278
+ level: "warn",
256279
+ type: "build",
256280
+ header: "Missing default export in globalScript",
256281
+ messageText: `globalScript should export a default function.
256282
+ See: https://stenciljs.com/docs/config#globalscript`,
256283
+ relFilePath: id,
256284
+ lines: []
256285
+ };
256286
+ buildCtx.diagnostics.push(diagnostic);
256287
+ }
256237
256288
  const defaultExport = needsDefault ? "\nexport const globalFn = () => {};\nexport default globalFn;" : "";
256238
256289
  code = code + defaultExport;
256239
256290
  const compilerOptions = { ...config.tsCompilerOptions };
@@ -256301,13 +256352,17 @@ var getGlobalScriptData = (config, compilerCtx) => {
256301
256352
  };
256302
256353
  var appendGlobalScripts = (globalScripts, s) => {
256303
256354
  if (globalScripts.length === 1) {
256304
- s.prepend(`import appGlobalScript from '${globalScripts[0].path}';
256355
+ s.prepend(`import * as appGlobalScriptNs from '${globalScripts[0].path}';
256356
+ `);
256357
+ s.prepend(`const appGlobalScript = appGlobalScriptNs.default || (() => {});
256305
256358
  `);
256306
256359
  s.append(`export const globalScripts = appGlobalScript;
256307
256360
  `);
256308
256361
  } else if (globalScripts.length > 1) {
256309
256362
  globalScripts.forEach((globalScript) => {
256310
- s.prepend(`import ${globalScript.defaultName} from '${globalScript.path}';
256363
+ s.prepend(`import * as ${globalScript.defaultName}Ns from '${globalScript.path}';
256364
+ `);
256365
+ s.prepend(`const ${globalScript.defaultName} = ${globalScript.defaultName}Ns.default || (() => {});
256311
256366
  `);
256312
256367
  });
256313
256368
  s.append(`export const globalScripts = () => {
@@ -270353,7 +270408,7 @@ var lazyComponentTransform = (compilerCtx, transformOpts, buildCtx) => {
270353
270408
  return updateLazyComponentClass(transformOpts, styleStatements, node, moduleFile, cmp, buildCtx);
270354
270409
  } else if (module2 == null ? void 0 : module2.isMixin) {
270355
270410
  return updateMixin(node, moduleFile, cmp, transformOpts);
270356
- } else if (buildCtx.config._isTesting && buildCtx.config.flags.spec) {
270411
+ } else if (buildCtx.config._isTesting && buildCtx.config.flags.spec && !buildCtx.config.flags.e2e) {
270357
270412
  return updateConstructor(node, Array.from(node.members), [], []);
270358
270413
  }
270359
270414
  }
@@ -271672,9 +271727,13 @@ var validateStats = (userConfig, userOutputs) => {
271672
271727
  if (userConfig.flags.stats) {
271673
271728
  const hasOutputTarget = userOutputs.some(isOutputTargetStats);
271674
271729
  if (!hasOutputTarget) {
271675
- outputTargets.push({
271730
+ const statsOutput = {
271676
271731
  type: STATS
271677
- });
271732
+ };
271733
+ if (typeof userConfig.flags.stats === "string") {
271734
+ statsOutput.file = userConfig.flags.stats;
271735
+ }
271736
+ outputTargets.push(statsOutput);
271678
271737
  }
271679
271738
  }
271680
271739
  outputTargets.push(...userOutputs.filter(isOutputTargetStats));
@@ -271953,6 +272012,9 @@ var validateDevServer = (config, diagnostics) => {
271953
272012
  if (!isBoolean(devServer.websocket)) {
271954
272013
  devServer.websocket = true;
271955
272014
  }
272015
+ if (!isBoolean(devServer.strictPort)) {
272016
+ devServer.strictPort = false;
272017
+ }
271956
272018
  if (flags.ssr) {
271957
272019
  devServer.ssr = true;
271958
272020
  } else {
@@ -272044,9 +272106,7 @@ init_import_meta_url();
272044
272106
  // src/compiler/docs/readme/docs-util.ts
272045
272107
  init_import_meta_url();
272046
272108
  var MarkdownTable = class {
272047
- constructor() {
272048
- this.rows = [];
272049
- }
272109
+ rows = [];
272050
272110
  addHeader(data) {
272051
272111
  this.addRow(data, true);
272052
272112
  }
@@ -272718,52 +272778,61 @@ var validateConfig = (userConfig = {}, bootstrapConfig) => {
272718
272778
 
272719
272779
  // src/compiler/build/build-ctx.ts
272720
272780
  var BuildContext = class {
272781
+ buildId = -1;
272782
+ buildMessages = [];
272783
+ buildResults = null;
272784
+ bundleBuildCount = 0;
272785
+ collections = [];
272786
+ completedTasks = [];
272787
+ compilerCtx;
272788
+ components = [];
272789
+ componentGraph = /* @__PURE__ */ new Map();
272790
+ config;
272791
+ data = {};
272792
+ buildStats = void 0;
272793
+ esmBrowserComponentBundle;
272794
+ esmComponentBundle;
272795
+ es5ComponentBundle;
272796
+ systemComponentBundle;
272797
+ commonJsComponentBundle;
272798
+ diagnostics = [];
272799
+ dirsAdded = [];
272800
+ dirsDeleted = [];
272801
+ entryModules = [];
272802
+ filesAdded = [];
272803
+ filesChanged = [];
272804
+ filesDeleted = [];
272805
+ filesUpdated = [];
272806
+ filesWritten = [];
272807
+ globalStyle = void 0;
272808
+ hasConfigChanges = false;
272809
+ hasFinished = false;
272810
+ hasHtmlChanges = false;
272811
+ hasPrintedResults = false;
272812
+ hasServiceWorkerChanges = false;
272813
+ hasScriptChanges = true;
272814
+ hasStyleChanges = true;
272815
+ hydrateAppFilePath = null;
272816
+ indexBuildCount = 0;
272817
+ indexDoc = void 0;
272818
+ isRebuild = false;
272819
+ moduleFiles = [];
272820
+ outputs = [];
272821
+ packageJson = {};
272822
+ packageJsonFilePath = null;
272823
+ pendingCopyTasks = [];
272824
+ requiresFullBuild = true;
272825
+ scriptsAdded = [];
272826
+ scriptsDeleted = [];
272827
+ startTime = Date.now();
272828
+ styleBuildCount = 0;
272829
+ stylesPromise = null;
272830
+ stylesUpdated = [];
272831
+ timeSpan = null;
272832
+ timestamp;
272833
+ transpileBuildCount = 0;
272834
+ validateTypesPromise;
272721
272835
  constructor(config, compilerCtx) {
272722
- this.buildId = -1;
272723
- this.buildMessages = [];
272724
- this.buildResults = null;
272725
- this.bundleBuildCount = 0;
272726
- this.collections = [];
272727
- this.completedTasks = [];
272728
- this.components = [];
272729
- this.componentGraph = /* @__PURE__ */ new Map();
272730
- this.data = {};
272731
- this.buildStats = void 0;
272732
- this.diagnostics = [];
272733
- this.dirsAdded = [];
272734
- this.dirsDeleted = [];
272735
- this.entryModules = [];
272736
- this.filesAdded = [];
272737
- this.filesChanged = [];
272738
- this.filesDeleted = [];
272739
- this.filesUpdated = [];
272740
- this.filesWritten = [];
272741
- this.globalStyle = void 0;
272742
- this.hasConfigChanges = false;
272743
- this.hasFinished = false;
272744
- this.hasHtmlChanges = false;
272745
- this.hasPrintedResults = false;
272746
- this.hasServiceWorkerChanges = false;
272747
- this.hasScriptChanges = true;
272748
- this.hasStyleChanges = true;
272749
- this.hydrateAppFilePath = null;
272750
- this.indexBuildCount = 0;
272751
- this.indexDoc = void 0;
272752
- this.isRebuild = false;
272753
- this.moduleFiles = [];
272754
- this.outputs = [];
272755
- this.packageJson = {};
272756
- this.packageJsonFilePath = null;
272757
- this.pendingCopyTasks = [];
272758
- this.requiresFullBuild = true;
272759
- this.scriptsAdded = [];
272760
- this.scriptsDeleted = [];
272761
- this.startTime = Date.now();
272762
- this.styleBuildCount = 0;
272763
- this.stylesPromise = null;
272764
- this.stylesUpdated = [];
272765
- this.timeSpan = null;
272766
- this.transpileBuildCount = 0;
272767
272836
  this.config = validateConfig(config, {}).config;
272768
272837
  this.compilerCtx = compilerCtx;
272769
272838
  this.buildId = ++this.compilerCtx.activeBuildId;
@@ -274491,12 +274560,21 @@ var updateImportReferenceFactory = (typeCounts, filePath, config) => {
274491
274560
  return;
274492
274561
  }
274493
274562
  const newTypeName = getIncrementTypeName(typeName);
274563
+ let originalExportName;
274564
+ if (typeReference.referenceLocation) {
274565
+ originalExportName = typeReference.referenceLocation;
274566
+ } else {
274567
+ const typeIdParts = typeReference.id.split("::");
274568
+ originalExportName = typeIdParts.length > 1 ? typeIdParts[typeIdParts.length - 1] : typeName;
274569
+ }
274494
274570
  existingTypeImportData[importResolvedFile].push({
274495
- // Since we create a unique ID for each type for documentation generation purposes, we can parse
274496
- // that ID to get the original name for the export
274497
- originalName: typeReference.id.split("::").pop(),
274571
+ // originalName: the name exported from the source module (for import { originalName as ... })
274572
+ // localName: the name used in the component file (the alias if there is one)
274573
+ // importName: Stencil-generated alias to avoid collisions in components.d.ts
274574
+ originalName: originalExportName,
274498
274575
  localName: typeName,
274499
- importName: newTypeName
274576
+ importName: newTypeName,
274577
+ isDefault: typeReference.isDefault
274500
274578
  });
274501
274579
  });
274502
274580
  return existingTypeImportData;
@@ -274543,23 +274621,48 @@ var generateComponentTypesFile = (config, buildCtx, areTypesInternal) => {
274543
274621
  });
274544
274622
  c.push(COMPONENTS_DTS_HEADER);
274545
274623
  c.push(`import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";`);
274546
- const expressions = Object.keys(typeImportData).map((filePath) => {
274624
+ const imports = [];
274625
+ const exports2 = [];
274626
+ Object.keys(typeImportData).forEach((filePath) => {
274547
274627
  const typeData = typeImportData[filePath];
274548
274628
  let importFilePath = filePath;
274549
274629
  if ((0, import_path43.isAbsolute)(filePath)) {
274550
274630
  importFilePath = normalizePath("./" + relative(config.srcDir, filePath)).replace(/\.(tsx|ts)$/, "");
274551
274631
  }
274552
- return `{ ${typeData.sort(sortImportNames).map((td3) => {
274553
- if (td3.originalName === "") {
274554
- return `${td3.localName}`;
274555
- } else if (td3.originalName === td3.importName) {
274556
- return `${td3.originalName}`;
274557
- } else {
274558
- return `${td3.originalName} as ${td3.importName}`;
274559
- }
274560
- }).join(`, `)} } from "${importFilePath}";`;
274632
+ const hasDefaultImport = typeData.some((td3) => td3.isDefault);
274633
+ if (hasDefaultImport && typeData.length === 1) {
274634
+ const td3 = typeData[0];
274635
+ imports.push(`import ${td3.importName} from "${importFilePath}";`);
274636
+ exports2.push(`export { default as ${td3.importName} } from "${importFilePath}";`);
274637
+ } else if (hasDefaultImport) {
274638
+ const defaultImport = typeData.find((td3) => td3.isDefault);
274639
+ const namedImports = typeData.filter((td3) => !td3.isDefault);
274640
+ const namedPart = namedImports.sort(sortImportNames).map((td3) => {
274641
+ if (td3.originalName === "") {
274642
+ return `${td3.localName}`;
274643
+ } else if (td3.originalName === td3.importName) {
274644
+ return `${td3.originalName}`;
274645
+ } else {
274646
+ return `${td3.originalName} as ${td3.importName}`;
274647
+ }
274648
+ }).join(`, `);
274649
+ imports.push(`import ${defaultImport.importName}, { ${namedPart} } from "${importFilePath}";`);
274650
+ exports2.push(`export { default as ${defaultImport.importName}, ${namedPart} } from "${importFilePath}";`);
274651
+ } else {
274652
+ const namedPart = typeData.sort(sortImportNames).map((td3) => {
274653
+ if (td3.originalName === "") {
274654
+ return `${td3.localName}`;
274655
+ } else if (td3.originalName === td3.importName) {
274656
+ return `${td3.originalName}`;
274657
+ } else {
274658
+ return `${td3.originalName} as ${td3.importName}`;
274659
+ }
274660
+ }).join(`, `);
274661
+ imports.push(`import { ${namedPart} } from "${importFilePath}";`);
274662
+ exports2.push(`export { ${namedPart} } from "${importFilePath}";`);
274663
+ }
274561
274664
  });
274562
- c.push(...expressions.map((ref) => `import ${ref}`), ...expressions.map((ref) => `export ${ref}`));
274665
+ c.push(...imports, ...exports2);
274563
274666
  c.push(`export namespace Components {`);
274564
274667
  c.push(...modules.map((m) => `${m.component}`));
274565
274668
  c.push(`}`);
@@ -278697,7 +278800,7 @@ var runTsProgram = async (config, compilerCtx, buildCtx, tsBuilder) => {
278697
278800
  buildCtx.diagnostics.push(...tsGlobal);
278698
278801
  buildCtx.diagnostics.push(...tsOptions);
278699
278802
  if (buildCtx.hasError) {
278700
- return false;
278803
+ return [];
278701
278804
  }
278702
278805
  const tsProgram = tsBuilder.getProgram();
278703
278806
  const tsTypeChecker = tsProgram.getTypeChecker();
@@ -278754,7 +278857,32 @@ var runTsProgram = async (config, compilerCtx, buildCtx, tsBuilder) => {
278754
278857
  resolveComponentDependencies(buildCtx.components);
278755
278858
  validateTranspiledComponents(config, buildCtx);
278756
278859
  if (buildCtx.hasError) {
278757
- return false;
278860
+ return [];
278861
+ }
278862
+ return emittedDts;
278863
+ };
278864
+ var validateTypesAfterGeneration = async (config, compilerCtx, buildCtx, tsBuilder, emittedDts) => {
278865
+ const tsProgram = tsBuilder.getProgram();
278866
+ const typesOutputTarget = config.outputTargets.filter(isOutputTargetDistTypes);
278867
+ const componentsDtsPath = join(config.srcDir, "components.d.ts");
278868
+ const componentsDtsExists = await compilerCtx.fs.access(componentsDtsPath);
278869
+ if (config.validateTypes && componentsDtsExists) {
278870
+ const sourceFiles = tsProgram.getSourceFiles().filter((sf) => {
278871
+ const fileName = normalizePath(sf.fileName);
278872
+ return !fileName.includes("node_modules") && !fileName.endsWith(".d.ts") && fileName.startsWith(normalizePath(config.srcDir));
278873
+ });
278874
+ for (const sourceFile of sourceFiles) {
278875
+ const sourceSemanticDiagnostics = tsProgram.getSemanticDiagnostics(sourceFile);
278876
+ const tsSemantic = loadTypeScriptDiagnostics(sourceSemanticDiagnostics);
278877
+ if (config.devMode) {
278878
+ tsSemantic.forEach((semanticDiagnostic) => {
278879
+ if (semanticDiagnostic.code === "6133" || semanticDiagnostic.code === "6192") {
278880
+ semanticDiagnostic.level = "warn";
278881
+ }
278882
+ });
278883
+ }
278884
+ buildCtx.diagnostics.push(...tsSemantic);
278885
+ }
278758
278886
  }
278759
278887
  const hasTypesChanged = await generateAppTypes(config, compilerCtx, buildCtx, "src");
278760
278888
  if (typesOutputTarget.length > 0) {
@@ -278771,17 +278899,6 @@ var runTsProgram = async (config, compilerCtx, buildCtx, tsBuilder) => {
278771
278899
  });
278772
278900
  await Promise.all(srcRootDtsFiles);
278773
278901
  }
278774
- if (config.validateTypes && !hasTypesChanged) {
278775
- const tsSemantic = loadTypeScriptDiagnostics(tsBuilder.getSemanticDiagnostics());
278776
- if (config.devMode) {
278777
- tsSemantic.forEach((semanticDiagnostic) => {
278778
- if (semanticDiagnostic.code === "6133" || semanticDiagnostic.code === "6192") {
278779
- semanticDiagnostic.level = "warn";
278780
- }
278781
- });
278782
- }
278783
- buildCtx.diagnostics.push(...tsSemantic);
278784
- }
278785
278902
  return hasTypesChanged;
278786
278903
  };
278787
278904
  var getRelativeDts = (config, srcPath, emitDtsPath) => {
@@ -279681,9 +279798,17 @@ var build2 = async (config, compilerCtx, buildCtx, tsBuilder) => {
279681
279798
  await readPackageJson(config, compilerCtx, buildCtx);
279682
279799
  if (buildCtx.hasError) return buildAbort(buildCtx);
279683
279800
  const tsTimeSpan = buildCtx.createTimeSpan("transpile started");
279684
- const componentDtsChanged = await runTsProgram(config, compilerCtx, buildCtx, tsBuilder);
279801
+ const emittedDts = await runTsProgram(config, compilerCtx, buildCtx, tsBuilder);
279685
279802
  tsTimeSpan.finish("transpile finished");
279686
279803
  if (buildCtx.hasError) return buildAbort(buildCtx);
279804
+ const componentDtsChanged = await validateTypesAfterGeneration(
279805
+ config,
279806
+ compilerCtx,
279807
+ buildCtx,
279808
+ tsBuilder,
279809
+ emittedDts
279810
+ );
279811
+ if (buildCtx.hasError) return buildAbort(buildCtx);
279687
279812
  if (config.watch && componentDtsChanged) {
279688
279813
  return null;
279689
279814
  }
@@ -280251,11 +280376,14 @@ var Cache = class {
280251
280376
  constructor(config, cacheFs) {
280252
280377
  this.config = config;
280253
280378
  this.cacheFs = cacheFs;
280254
- this.failed = 0;
280255
- this.skip = false;
280256
280379
  this.sys = config.sys;
280257
280380
  this.logger = config.logger;
280258
280381
  }
280382
+ failed = 0;
280383
+ skip = false;
280384
+ sys;
280385
+ logger;
280386
+ buildCacheDir;
280259
280387
  async initCacheDir() {
280260
280388
  if (this.config._isTesting || !this.config.cacheDir) {
280261
280389
  return;
@@ -281606,6 +281734,10 @@ var parseCss = (css, filePath) => {
281606
281734
  });
281607
281735
  };
281608
281736
  class ParsePosition {
281737
+ start;
281738
+ end;
281739
+ source;
281740
+ content;
281609
281741
  constructor(start) {
281610
281742
  this.start = start;
281611
281743
  this.end = { line: lineno, column };
@@ -282901,7 +283033,7 @@ var transformCssToEsmModule = (input) => {
282901
283033
  };
282902
283034
  var generateTransformCssToEsm = (input, results) => {
282903
283035
  const s = new MagicString("");
282904
- results.styleText = results.styleText.replace(/`/g, "\\`").replace(/\u000c/g, "\\f").replace(/\u0008/g, "\\b").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\u000b/g, "\\v").replace(/\0/g, "\\0").replace(/\\/g, "\\\\");
283036
+ results.styleText = results.styleText.replace(/\n/g, " ").replace(/\r/g, " ").replace(/\t/g, " ").replace(/`/g, "\\`").replace(/\u000c/g, "\\f").replace(/\u0008/g, "\\b").replace(/\u000b/g, "\\v").replace(/\0/g, "\\0").replace(/\\/g, "\\\\");
282905
283037
  if (input.addTagTransformers) {
282906
283038
  results.styleText = addTagTransformToCssString(results.styleText, input.tags);
282907
283039
  }