@stencil/core 5.0.0-alpha.4 → 5.0.0-alpha.5

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 (36) hide show
  1. package/dist/{client-Dti6fFpE.mjs → client-Dnio47yQ.mjs} +81 -10
  2. package/dist/compiler/index.d.mts +2 -2
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-BYRrEeD-.mjs → compiler-Dxri2g8Z.mjs} +15313 -14822
  7. package/dist/declarations/stencil-public-compiler.d.ts +288 -132
  8. package/dist/declarations/stencil-public-compiler.js +2 -3
  9. package/dist/declarations/stencil-public-runtime.d.ts +2 -0
  10. package/dist/{index-hS-KBdAP.d.ts → index-D-XN9HW_.d.ts} +1 -1
  11. package/dist/{index-BwTaN1Nq.d.mts → index-D5zaocDq.d.mts} +357 -189
  12. package/dist/{index-CyrGY82h.d.ts → index-D61XZw0f.d.ts} +2 -2
  13. package/dist/{index-9LTuoSiw.d.mts → index-Dat4djoo.d.mts} +1 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/{jsx-runtime-DlDkTqps.d.ts → jsx-runtime-B3vQbWIW.d.ts} +1 -1
  16. package/dist/jsx-runtime.d.ts +1 -1
  17. package/dist/jsx-runtime.js +1 -1
  18. package/dist/{node-BF2jSfWg.mjs → node-pj6rF4Wt.mjs} +66 -69
  19. package/dist/{regular-expression-D5pGVpCu.mjs → regular-expression-D0_N0PGa.mjs} +44 -26
  20. package/dist/runtime/app-data/index.d.ts +1 -1
  21. package/dist/runtime/client/index.d.ts +41 -8
  22. package/dist/runtime/client/index.js +105 -31
  23. package/dist/runtime/index.d.ts +29 -5
  24. package/dist/runtime/index.js +2 -2
  25. package/dist/runtime/server/index.d.mts +56 -25
  26. package/dist/runtime/server/index.mjs +122 -37
  27. package/dist/runtime/server/runner.d.mts +40 -26
  28. package/dist/runtime/server/runner.mjs +28 -22
  29. package/dist/{runtime-COEYYPyw.js → runtime-CKyUrF4i.js} +104 -30
  30. package/dist/sys/node/index.d.mts +1 -1
  31. package/dist/sys/node/index.mjs +1 -1
  32. package/dist/sys/node/worker.mjs +2 -2
  33. package/dist/testing/index.d.mts +2 -2
  34. package/dist/testing/index.mjs +15 -15
  35. package/dist/{validation-Byxie0Uk.mjs → validation-BA8nzXu_.mjs} +82 -58
  36. package/package.json +11 -12
@@ -1309,7 +1309,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1309
1309
  styleElm.textContent = style;
1310
1310
  const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
1311
1311
  if (nonce != null) styleElm.setAttribute("nonce", nonce);
1312
- if ((BUILD.hydrateServerSide || BUILD.hotModuleReplacement) && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1312
+ if (BUILD.hydrateServerSide && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) || BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1313
+ if (BUILD.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
1313
1314
  /**
1314
1315
  * attach styles at the end of the head tag if we render scoped components
1315
1316
  */
@@ -2420,6 +2421,46 @@ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) =>
2420
2421
  const setMode = (handler) => modeResolutionChain.push(handler);
2421
2422
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2422
2423
  //#endregion
2424
+ //#region src/runtime/normalize-watchers.ts
2425
+ /**
2426
+ * Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
2427
+ *
2428
+ * Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
2429
+ * handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
2430
+ * wraps each entry in an object that carries option flags (e.g. `immediate`):
2431
+ * `{ "min": [{ "minChanged": 0 }] }`.
2432
+ *
2433
+ * When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
2434
+ * but consumed by an app using a newer Stencil runtime, the runtime's
2435
+ * `Object.entries(watcher)` call receives a string and misinterprets its character
2436
+ * indices as method names, causing:
2437
+ * `TypeError: instance[watchMethodName] is not a function`
2438
+ *
2439
+ * This helper should be used at `$watchers$` assignment sites that need to
2440
+ * accept both legacy and current compiler metadata so downstream code on those
2441
+ * paths can safely assume the new object format.
2442
+ *
2443
+ * @param raw The raw watcher map from compiled metadata (new or legacy format).
2444
+ * @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
2445
+ */
2446
+ const normalizeWatchers = (raw) => {
2447
+ if (!raw) return void 0;
2448
+ const keys = Object.keys(raw);
2449
+ if (keys.length === 0) return void 0;
2450
+ let hasLegacy = false;
2451
+ for (const propName of keys) {
2452
+ if (hasLegacy) break;
2453
+ for (const h of raw[propName]) if (typeof h === "string") {
2454
+ hasLegacy = true;
2455
+ break;
2456
+ }
2457
+ }
2458
+ if (!hasLegacy) return raw;
2459
+ const out = {};
2460
+ for (const propName of keys) out[propName] = raw[propName].map((h) => typeof h === "string" ? { [h]: 0 } : h);
2461
+ return out;
2462
+ };
2463
+ //#endregion
2423
2464
  //#region src/runtime/parse-property-value.ts
2424
2465
  /**
2425
2466
  * Parse a new property value for a given property type.
@@ -3770,7 +3811,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3770
3811
  });
3771
3812
  if (BUILD.member && cmpMeta.$members$ || BUILD.propChangeCallback) {
3772
3813
  if (BUILD.propChangeCallback) {
3773
- if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = Cstr.watchers;
3814
+ if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
3774
3815
  if (Cstr.deserializers && !cmpMeta.$deserializers$) cmpMeta.$deserializers$ = Cstr.deserializers;
3775
3816
  if (Cstr.serializers && !cmpMeta.$serializers$) cmpMeta.$serializers$ = Cstr.serializers;
3776
3817
  }
@@ -3920,7 +3961,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
3920
3961
  if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
3921
3962
  if (BUILD.member && !Cstr.isProxied) {
3922
3963
  if (BUILD.propChangeCallback) {
3923
- cmpMeta.$watchers$ = Cstr.watchers;
3964
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
3924
3965
  cmpMeta.$serializers$ = Cstr.serializers;
3925
3966
  cmpMeta.$deserializers$ = Cstr.deserializers;
3926
3967
  }
@@ -4096,7 +4137,59 @@ const disconnectedCallback = async (elm) => {
4096
4137
  if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) rootAppliedStyles.delete(elm.shadowRoot);
4097
4138
  };
4098
4139
  //#endregion
4099
- //#region src/runtime/bootstrap-custom-element.ts
4140
+ //#region src/runtime/hmr-component.ts
4141
+ /**
4142
+ * Kick off hot-module-replacement for a component. In order to replace the
4143
+ * component in-place we:
4144
+ *
4145
+ * 1. get a reference to the {@link d.HostRef} for the element
4146
+ * 2. reset the element's runtime flags
4147
+ * 3. re-run the initialization logic for the element (via
4148
+ * {@link initializeComponent})
4149
+ *
4150
+ * For standalone (non-lazy) builds, we instead re-import the component module
4151
+ * and patch the prototype of the registered constructor in-place, then
4152
+ * force a re-render of all existing instances in the DOM.
4153
+ *
4154
+ * @param hostElement the host element for the component which we want to start
4155
+ * doing HMR
4156
+ * @param cmpMeta runtime metadata for the component
4157
+ * @param hmrVersionId the current HMR version ID
4158
+ */
4159
+ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4160
+ if (BUILD.lazyLoad) {
4161
+ const hostRef = getHostRef(hostElement);
4162
+ if (!hostRef) return;
4163
+ hostRef.$flags$ = HOST_FLAGS.hasConnected;
4164
+ initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
4165
+ } else hmrStandalone(hostElement, cmpMeta, hmrVersionId);
4166
+ };
4167
+ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4168
+ const modulePath = hostElement.constructor.__stencil_module__;
4169
+ console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
4170
+ if (!modulePath) {
4171
+ console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor — was this built with devMode?`);
4172
+ return;
4173
+ }
4174
+ try {
4175
+ const newModule = await import(
4176
+ /* @vite-ignore */
4177
+ `${modulePath}?s-hmr=${hmrVersionId}`
4178
+ );
4179
+ const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4180
+ if (!NewClass) return;
4181
+ const ctor = customElements.get(cmpMeta.$tagName$);
4182
+ if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4183
+ if (key === "constructor") continue;
4184
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4185
+ }
4186
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => forceUpdate(el));
4187
+ } catch (e) {
4188
+ console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4189
+ }
4190
+ };
4191
+ //#endregion
4192
+ //#region src/runtime/bootstrap-standalone.ts
4100
4193
  const defineCustomElement = (Cstr, compactMeta) => {
4101
4194
  customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
4102
4195
  };
@@ -4110,12 +4203,15 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4110
4203
  if (BUILD.member) cmpMeta.$members$ = compactMeta[2];
4111
4204
  if (BUILD.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4112
4205
  if (BUILD.propChangeCallback) {
4113
- cmpMeta.$watchers$ = Cstr.$watchers$;
4206
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.$watchers$);
4114
4207
  cmpMeta.$deserializers$ = Cstr.$deserializers$;
4115
4208
  cmpMeta.$serializers$ = Cstr.$serializers$;
4116
4209
  }
4117
4210
  if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4118
4211
  if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4212
+ if (BUILD.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4213
+ hmrStart(this, cmpMeta, hmrVersionId);
4214
+ };
4119
4215
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD.experimentalSlotFixes || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) patchPseudoShadowDom(Cstr.prototype);
4120
4216
  else {
4121
4217
  if (BUILD.slotChildNodesFix || BUILD.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
@@ -4196,29 +4292,7 @@ const forceModeUpdate = (elm) => {
4196
4292
  }
4197
4293
  };
4198
4294
  //#endregion
4199
- //#region src/runtime/hmr-component.ts
4200
- /**
4201
- * Kick off hot-module-replacement for a component. In order to replace the
4202
- * component in-place we:
4203
- *
4204
- * 1. get a reference to the {@link d.HostRef} for the element
4205
- * 2. reset the element's runtime flags
4206
- * 3. re-run the initialization logic for the element (via
4207
- * {@link initializeComponent})
4208
- *
4209
- * @param hostElement the host element for the component which we want to start
4210
- * doing HMR
4211
- * @param cmpMeta runtime metadata for the component
4212
- * @param hmrVersionId the current HMR version ID
4213
- */
4214
- const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4215
- const hostRef = getHostRef(hostElement);
4216
- if (!hostRef) return;
4217
- hostRef.$flags$ = HOST_FLAGS.hasConnected;
4218
- initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
4219
- };
4220
- //#endregion
4221
- //#region src/runtime/bootstrap-lazy.ts
4295
+ //#region src/runtime/bootstrap-loader.ts
4222
4296
  const bootstrapLazy = (lazyBundles, options = {}) => {
4223
4297
  if (BUILD.profile && performance.mark) performance.mark("st:app:start");
4224
4298
  installDevTools();
@@ -4252,7 +4326,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4252
4326
  if (BUILD.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4253
4327
  if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
4254
4328
  if (BUILD.propChangeCallback) {
4255
- cmpMeta.$watchers$ = compactMeta[4] ?? {};
4329
+ cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
4256
4330
  cmpMeta.$serializers$ = compactMeta[5] ?? {};
4257
4331
  cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4258
4332
  }
@@ -4674,4 +4748,4 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4674
4748
  }
4675
4749
  };
4676
4750
  //#endregion
4677
- export { h as A, postUpdateComponent as C, getMode as D, parsePropertyValue as E, HYDRATED_STYLE_ID as F, getShadowRoot as M, getAssetPath as N, setMode as O, setAssetPath as P, getRenderingRef as S, createEvent as T, connectedCallback as _, transformTag as a, setValue as b, setNonce as c, Fragment as d, bootstrapLazy as f, disconnectedCallback as g, proxyCustomElement as h, setTagTransformer as i, getElement as j, Host as k, Mixin as l, forceModeUpdate as m, jsx as n, render as o, defineCustomElement as p, jsxs as r, setPlatformOptions as s, insertVdomAnnotations as t, addHostEventListeners as u, proxyComponent as v, renderVdom as w, forceUpdate as x, getValue as y };
4751
+ export { Host as A, postUpdateComponent as C, normalizeWatchers as D, parsePropertyValue as E, setAssetPath as F, HYDRATED_STYLE_ID as I, getElement as M, getShadowRoot as N, getMode as O, getAssetPath as P, getRenderingRef as S, createEvent as T, connectedCallback as _, transformTag as a, setValue as b, setNonce as c, Fragment as d, bootstrapLazy as f, disconnectedCallback as g, proxyCustomElement as h, setTagTransformer as i, h as j, setMode as k, Mixin as l, forceModeUpdate as m, jsx as n, render as o, defineCustomElement as p, jsxs as r, setPlatformOptions as s, insertVdomAnnotations as t, addHostEventListeners as u, proxyComponent as v, renderVdom as w, forceUpdate as x, getValue as y };
@@ -1,4 +1,4 @@
1
- import { $r as Logger, _r as CompilerSystem } from "../../index-BwTaN1Nq.mjs";
1
+ import { Qr as Logger, _r as CompilerSystem } from "../../index-D5zaocDq.mjs";
2
2
 
3
3
  //#region src/sys/node/logger/index.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-BF2jSfWg.mjs";
1
+ import { n as setupNodeProcess, r as createNodeLogger, t as createNodeSys } from "../../node-pj6rF4Wt.mjs";
2
2
  export { createNodeLogger, createNodeSys, setupNodeProcess };
@@ -1,5 +1,5 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-BYRrEeD-.mjs";
2
- import { t as createNodeSys } from "../../node-BF2jSfWg.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-Dxri2g8Z.mjs";
2
+ import { t as createNodeSys } from "../../node-pj6rF4Wt.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
5
5
  * Initialize a worker thread, setting up various machinery for managing
@@ -1,5 +1,5 @@
1
- import { $r as Logger, B as ComponentCompilerMeta, Bt as Module, E as CompilerCtx, Et as HostRef, Gt as NewSpecPageOptions, Qr as LogLevel, Tt as HostElement, Xr as LoadConfigInit, _r as CompilerSystem, a as BuildCtx, bn as SpecPage, fa as UserBuildConditionals, hn as RuntimeRef, la as RafCallback, na as UnvalidatedConfig, pt as ComponentRuntimeMeta, ra as ValidatedConfig, sa as ErrorHandler, ti as LoggerTimeSpan, zr as Diagnostic } from "../index-BwTaN1Nq.mjs";
2
- import { _ as Env, c as getMode, d as Fragment, f as createEvent, g as setAssetPath, h as getAssetPath, i as getRenderingRef, n as h, p as getElement, r as forceUpdate, t as Host, u as Mixin } from "../index-9LTuoSiw.mjs";
1
+ import { B as ComponentCompilerMeta, E as CompilerCtx, Et as HostRef, Lt as NewSpecPageOptions, Mt as Module, Qr as Logger, Tt as HostElement, Yr as LoadConfigInit, Zr as LogLevel, _r as CompilerSystem, a as BuildCtx, aa as ValidatedConfig, da as RafCallback, ei as LoggerTimeSpan, fn as SpecPage, ia as UnvalidatedConfig, la as ErrorHandler, ma as UserBuildConditionals, pt as ComponentRuntimeMeta, sn as RuntimeRef, zr as Diagnostic } from "../index-D5zaocDq.mjs";
2
+ import { _ as Env, c as getMode, d as Fragment, f as createEvent, g as setAssetPath, h as getAssetPath, i as getRenderingRef, n as h, p as getElement, r as forceUpdate, t as Host, u as Mixin } from "../index-Dat4djoo.mjs";
3
3
  import { Mock } from "vitest";
4
4
 
5
5
  //#region src/testing/testing-logger.d.ts
@@ -1,10 +1,10 @@
1
- import { B as BUILD, E as reWireGetterSetter, V as Env, _ as getElement, a as Mixin, b as setAssetPath, c as forceUpdate, d as createEvent, f as getMode, g as h, h as Host, l as getRenderingRef, o as Fragment, s as bootstrapLazy, t as insertVdomAnnotations, u as renderVdom, y as getAssetPath } from "../client-Dti6fFpE.mjs";
2
- import { C as CMP_FLAGS, V as EVENT_FLAGS, h as noop } from "../regular-expression-D5pGVpCu.mjs";
3
- import { _ as getBuildFeatures, c as createWorkerContext, h as BuildContext, i as createSystem, m as Cache, p as createInMemoryFs } from "../compiler-BYRrEeD-.mjs";
4
- import { St as formatLazyBundleRuntimeMeta } from "../validation-Byxie0Uk.mjs";
5
- import { o as buildEvents } from "../node-BF2jSfWg.mjs";
6
- import path from "node:path";
7
- import path$1 from "path";
1
+ import { B as BUILD, E as reWireGetterSetter, V as Env, _ as getElement, a as Mixin, b as setAssetPath, c as forceUpdate, d as createEvent, f as getMode, g as h, h as Host, l as getRenderingRef, o as Fragment, s as bootstrapLazy, t as insertVdomAnnotations, u as renderVdom, y as getAssetPath } from "../client-Dnio47yQ.mjs";
2
+ import { F as EVENT_FLAGS, h as noop, w as CMP_FLAGS } from "../regular-expression-D0_N0PGa.mjs";
3
+ import { _ as getBuildFeatures, c as createWorkerContext, g as BuildContext, h as Cache, i as createSystem, p as createInMemoryFs } from "../compiler-Dxri2g8Z.mjs";
4
+ import { St as formatLazyBundleRuntimeMeta } from "../validation-BA8nzXu_.mjs";
5
+ import { o as buildEvents } from "../node-pj6rF4Wt.mjs";
6
+ import nodePath from "node:path";
7
+ import path from "path";
8
8
  import { MockWindow, setupGlobal } from "@stencil/mock-doc";
9
9
  import { createHash } from "crypto";
10
10
  import { afterAll, vi } from "vitest";
@@ -86,7 +86,7 @@ const createTestingSystem = () => {
86
86
  let diskReads = 0;
87
87
  let diskWrites = 0;
88
88
  const sys = createSystem();
89
- sys.platformPath = path$1;
89
+ sys.platformPath = path;
90
90
  sys.generateContentHash = (content, length) => {
91
91
  let hash = createHash("sha1").update(content).digest("hex").toLowerCase();
92
92
  if (typeof length === "number") hash = hash.slice(0, length);
@@ -260,7 +260,7 @@ const mockComponentMeta = (overrides = {}) => ({
260
260
  */
261
261
  function mockValidatedConfig(overrides = {}) {
262
262
  const baseConfig = mockConfig(overrides);
263
- const rootDir = path.resolve("/");
263
+ const rootDir = nodePath.resolve("/");
264
264
  return {
265
265
  ...baseConfig,
266
266
  cacheDir: ".stencil",
@@ -277,7 +277,7 @@ function mockValidatedConfig(overrides = {}) {
277
277
  minifyJs: false,
278
278
  namespace: "Testing",
279
279
  outputTargets: baseConfig.outputTargets ?? [],
280
- packageJsonFilePath: path.join(rootDir, "package.json"),
280
+ packageJsonFilePath: nodePath.join(rootDir, "package.json"),
281
281
  rootDir,
282
282
  sourceMap: true,
283
283
  srcDir: "/src",
@@ -289,7 +289,6 @@ function mockValidatedConfig(overrides = {}) {
289
289
  inputOptions: {},
290
290
  outputOptions: {}
291
291
  },
292
- validatePrimaryPackageOutputTarget: false,
293
292
  ...overrides
294
293
  };
295
294
  }
@@ -301,14 +300,13 @@ function mockValidatedConfig(overrides = {}) {
301
300
  * @returns the mock Stencil configuration
302
301
  */
303
302
  function mockConfig(overrides = {}) {
304
- const rootDir = path.resolve("/");
303
+ const rootDir = nodePath.resolve("/");
305
304
  let { sys } = overrides;
306
305
  if (!sys) sys = createTestingSystem();
307
306
  sys.getCurrentDirectory = () => rootDir;
308
307
  return {
309
308
  _isTesting: true,
310
309
  buildAppCore: false,
311
- buildDist: true,
312
310
  bundles: null,
313
311
  devMode: true,
314
312
  enableCache: false,
@@ -366,7 +364,7 @@ function mockCompilerCtx(config) {
366
364
  activeFilesUpdated: [],
367
365
  addWatchDir: noop,
368
366
  addWatchFile: noop,
369
- cachedGlobalStyle: null,
367
+ globalStyleCache: /* @__PURE__ */ new Map(),
370
368
  changedFiles: /* @__PURE__ */ new Set(),
371
369
  changedModules: /* @__PURE__ */ new Set(),
372
370
  collections: [],
@@ -383,9 +381,11 @@ function mockCompilerCtx(config) {
383
381
  reset: noop,
384
382
  resolvedCollections: /* @__PURE__ */ new Set(),
385
383
  rolldownCache: /* @__PURE__ */ new Map(),
386
- rolldownCacheHydrate: null,
384
+ rolldownCacheSsr: null,
387
385
  rolldownCacheLazy: null,
388
386
  rolldownCacheNative: null,
387
+ transpileCache: /* @__PURE__ */ new Map(),
388
+ prevStylesMap: /* @__PURE__ */ new Map(),
389
389
  styleModeNames: /* @__PURE__ */ new Set(),
390
390
  worker: createWorkerContext(innerConfig.sys),
391
391
  cssTransformCache: /* @__PURE__ */ new Map()
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- import { A as DIST_CUSTOM_ELEMENTS, B as DOCS_VSCODE, C as CMP_FLAGS, E as CUSTOM, F as DIST_TYPES, G as LISTENER_FLAGS, H as GENERATED_DTS, I as DOCS_CUSTOM, J as STATS, K as MEMBER_FLAGS, L as DOCS_CUSTOM_ELEMENTS_MANIFEST, M as DIST_HYDRATE_SCRIPT, N as DIST_LAZY, O as DIST, P as DIST_LAZY_LOADER, R as DOCS_JSON, T as COPY, X as VALID_CONFIG_OUTPUT_TARGETS, Z as WATCH_FLAGS, _ as sortBy, b as toTitleCase, i as flatOne, j as DIST_GLOBAL_STYLES, k as DIST_COLLECTION, n as dashToPascalCase, p as isString, r as escapeWithPattern, u as isIterable, y as toDashCase, z as DOCS_README } from "./regular-expression-D5pGVpCu.mjs";
3
- import path, { basename, dirname, relative } from "node:path";
4
- import { minimatch } from "minimatch";
2
+ import { A as DOCS_CUSTOM, B as LISTENER_FLAGS, C as ASSETS, D as CUSTOM, E as COPY, G as STANDALONE, H as MEMBER_FLAGS, I as GENERATED_DTS, K as STATS, L as GLOBAL_STYLE, M as DOCS_JSON, N as DOCS_README, P as DOCS_VSCODE, V as LOADER_BUNDLE, X as VALID_CONFIG_OUTPUT_TARGETS, Y as TYPES, Z as WATCH_FLAGS, _ as sortBy, b as toTitleCase, i as flatOne, j as DOCS_CUSTOM_ELEMENTS_MANIFEST, k as DIST_LAZY, n as dashToPascalCase, p as isString, q as STENCIL_REBUNDLE, r as escapeWithPattern, u as isIterable, w as CMP_FLAGS, y as toDashCase } from "./regular-expression-D0_N0PGa.mjs";
3
+ import nodePath, { basename, dirname, relative } from "node:path";
4
+ import picomatch from "picomatch";
5
5
  //#region src/utils/byte-size.ts
6
6
  /**
7
7
  * Used to learn the size of a string in bytes.
@@ -267,7 +267,8 @@ const buildWarn = (diagnostics) => {
267
267
  * @param jsonFilePath the path to the JSON file where the error occurred
268
268
  * @param msg the error message
269
269
  * @param jsonField the key for the field which caused the error, used for finding
270
- * the error line in the original JSON file
270
+ * the error line in the original JSON file. Only root-level keys (with minimal
271
+ * indentation, typically 2 spaces) are highlighted to avoid matching nested keys.
271
272
  * @returns a reference to the newly-created diagnostic
272
273
  */
273
274
  const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
@@ -276,41 +277,60 @@ const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonFie
276
277
  err.absFilePath = jsonFilePath;
277
278
  if (typeof jsonField === "string") try {
278
279
  const lines = compilerCtx.fs.readFileSync(jsonFilePath).replace(/\r/g, "\n").split("\n");
280
+ let bestMatch = null;
281
+ const ROOT_LEVEL_INDENTATION = 2;
279
282
  for (let i = 0; i < lines.length; i++) {
280
283
  const txtLine = lines[i];
281
284
  const txtIndex = txtLine.indexOf(jsonField);
282
285
  if (txtIndex > -1) {
283
- const warnLine = {
286
+ const indentation = txtLine.search(/\S/);
287
+ if (indentation === ROOT_LEVEL_INDENTATION) {
288
+ bestMatch = {
289
+ lineIndex: i,
290
+ charIndex: txtIndex,
291
+ indentation
292
+ };
293
+ break;
294
+ } else if (bestMatch === null || indentation < bestMatch.indentation) bestMatch = {
284
295
  lineIndex: i,
285
- lineNumber: i + 1,
286
- text: txtLine,
287
- errorCharStart: txtIndex,
288
- errorLength: jsonField.length
296
+ charIndex: txtIndex,
297
+ indentation
289
298
  };
290
- err.lineNumber = warnLine.lineNumber;
291
- err.columnNumber = txtIndex + 1;
292
- err.lines.push(warnLine);
293
- if (i >= 0) {
294
- const beforeWarnLine = {
295
- lineIndex: warnLine.lineIndex - 1,
296
- lineNumber: warnLine.lineNumber - 1,
297
- text: lines[i - 1],
298
- errorCharStart: -1,
299
- errorLength: -1
300
- };
301
- err.lines.unshift(beforeWarnLine);
302
- }
303
- if (i < lines.length) {
304
- const afterWarnLine = {
305
- lineIndex: warnLine.lineIndex + 1,
306
- lineNumber: warnLine.lineNumber + 1,
307
- text: lines[i + 1],
308
- errorCharStart: -1,
309
- errorLength: -1
310
- };
311
- err.lines.push(afterWarnLine);
312
- }
313
- break;
299
+ }
300
+ }
301
+ if (bestMatch !== null && bestMatch.indentation === ROOT_LEVEL_INDENTATION) {
302
+ const i = bestMatch.lineIndex;
303
+ const txtIndex = bestMatch.charIndex;
304
+ const txtLine = lines[i];
305
+ const warnLine = {
306
+ lineIndex: i,
307
+ lineNumber: i + 1,
308
+ text: txtLine,
309
+ errorCharStart: txtIndex,
310
+ errorLength: jsonField.length
311
+ };
312
+ err.lineNumber = warnLine.lineNumber;
313
+ err.columnNumber = txtIndex + 1;
314
+ err.lines.push(warnLine);
315
+ if (i > 0) {
316
+ const beforeWarnLine = {
317
+ lineIndex: warnLine.lineIndex - 1,
318
+ lineNumber: warnLine.lineNumber - 1,
319
+ text: lines[i - 1],
320
+ errorCharStart: -1,
321
+ errorLength: -1
322
+ };
323
+ err.lines.unshift(beforeWarnLine);
324
+ }
325
+ if (i < lines.length - 1) {
326
+ const afterWarnLine = {
327
+ lineIndex: warnLine.lineIndex + 1,
328
+ lineNumber: warnLine.lineNumber + 1,
329
+ text: lines[i + 1],
330
+ errorCharStart: -1,
331
+ errorLength: -1
332
+ };
333
+ err.lines.push(afterWarnLine);
314
334
  }
315
335
  }
316
336
  } catch {}
@@ -741,7 +761,7 @@ function relative$1(from, to) {
741
761
  * path. However, our algorithm does differ from that of Node's, as described in this function's JSDoc when a zero
742
762
  * length string is encountered.
743
763
  */
744
- return normalizePath(path.relative(from, to), false);
764
+ return normalizePath(nodePath.relative(from, to), false);
745
765
  }
746
766
  /**
747
767
  * A wrapped version of node.js' {@link path.join} which adds our custom
@@ -764,7 +784,7 @@ function join$1(...paths) {
764
784
  * Note that our algorithm does differ from Node's, as described in this function's JSDoc regarding trailing
765
785
  * slashes.
766
786
  */
767
- return normalizePath(path.join(...paths), false);
787
+ return normalizePath(nodePath.join(...paths), false);
768
788
  }
769
789
  /**
770
790
  * A wrapped version of node.js' {@link path.resolve} which adds our custom
@@ -781,7 +801,7 @@ function resolve(...paths) {
781
801
  * When normalizing, we should _not_ attempt to relativize the path returned by the native Node `resolve` method. When
782
802
  * calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
783
803
  */
784
- return normalizePath(path.resolve(...paths), false);
804
+ return normalizePath(nodePath.resolve(...paths), false);
785
805
  }
786
806
  /**
787
807
  * A wrapped version of node.js' {@link path.normalize} which adds our custom
@@ -798,7 +818,7 @@ function normalize(toNormalize) {
798
818
  * When normalizing, we should _not_ attempt to relativize the path returned by the native Node `normalize` method.
799
819
  * When calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
800
820
  */
801
- return normalizePath(path.normalize(toNormalize), false);
821
+ return normalizePath(nodePath.normalize(toNormalize), false);
802
822
  }
803
823
  //#endregion
804
824
  //#region src/utils/logger/logger-typescript.ts
@@ -973,7 +993,7 @@ const flattenDiagnosticMessageText = (tsDiagnostic, diag) => {
973
993
  const shouldExcludeComponent = (tagName, excludePatterns) => {
974
994
  if (!excludePatterns || excludePatterns.length === 0) return false;
975
995
  return excludePatterns.some((pattern) => {
976
- if (isGlob(pattern)) return minimatch(tagName, pattern);
996
+ if (isGlob(pattern)) return picomatch.isMatch(tagName, pattern);
977
997
  return pattern === tagName;
978
998
  });
979
999
  };
@@ -1025,21 +1045,21 @@ const relativeImport = (pathFrom, pathTo, ext, addPrefix = true) => {
1025
1045
  };
1026
1046
  const getComponentsDtsSrcFilePath = (config) => join$1(config.srcDir, GENERATED_DTS);
1027
1047
  /**
1028
- * Helper to get an appropriate file path for `components.d.ts` for a `"dist"`
1029
- * or `"dist-types"` output target.
1048
+ * Helper to get an appropriate file path for `components.d.ts` for an output target.
1030
1049
  *
1031
- * @param outputTarget the output target of interest
1050
+ * @param typesDir the directory where types are generated
1032
1051
  * @returns a properly-formatted path
1033
1052
  */
1034
- const getComponentsDtsTypesFilePath = (outputTarget) => join$1(outputTarget.typesDir, GENERATED_DTS);
1035
- const isOutputTargetDist = (o) => o.type === DIST;
1036
- const isOutputTargetDistCollection = (o) => o.type === DIST_COLLECTION;
1037
- const isOutputTargetDistCustomElements = (o) => o.type === DIST_CUSTOM_ELEMENTS;
1053
+ const getComponentsDtsTypesFilePath = (typesDir) => join$1(typesDir, GENERATED_DTS);
1054
+ const isOutputTargetLoaderBundle = (o) => o.type === LOADER_BUNDLE;
1055
+ const isOutputTargetStandalone = (o) => o.type === STANDALONE;
1056
+ const isOutputTargetSsr = (o) => o.type === "ssr";
1057
+ const isOutputTargetStencilRebundle = (o) => o.type === STENCIL_REBUNDLE;
1058
+ const isOutputTargetTypes = (o) => o.type === TYPES;
1059
+ const isOutputTargetGlobalStyle = (o) => o.type === GLOBAL_STYLE;
1060
+ const isOutputTargetAssets = (o) => o.type === ASSETS;
1038
1061
  const isOutputTargetCopy = (o) => o.type === COPY;
1039
1062
  const isOutputTargetDistLazy = (o) => o.type === DIST_LAZY;
1040
- const isOutputTargetDistLazyLoader = (o) => o.type === DIST_LAZY_LOADER;
1041
- const isOutputTargetDistGlobalStyles = (o) => o.type === DIST_GLOBAL_STYLES;
1042
- const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
1043
1063
  const isOutputTargetCustom = (o) => o.type === CUSTOM;
1044
1064
  const isOutputTargetDocs = (o) => o.type === "docs-readme" || o.type === "docs-json" || o.type === "docs-custom" || o.type === "docs-vscode" || o.type === "docs-custom-elements-manifest";
1045
1065
  const isOutputTargetDocsReadme = (o) => o.type === DOCS_README;
@@ -1049,15 +1069,6 @@ const isOutputTargetDocsVscode = (o) => o.type === DOCS_VSCODE;
1049
1069
  const isOutputTargetDocsCustomElementsManifest = (o) => o.type === DOCS_CUSTOM_ELEMENTS_MANIFEST;
1050
1070
  const isOutputTargetWww = (o) => o.type === "www";
1051
1071
  const isOutputTargetStats = (o) => o.type === STATS;
1052
- const isOutputTargetDistTypes = (o) => o.type === DIST_TYPES;
1053
- /**
1054
- * Checks whether or not the supplied output target's type matches one of the eligible primary
1055
- * package output target types (i.e. it can have `isPrimaryPackageOutputTarget: true` in its config).
1056
- *
1057
- * @param o The output target to check.
1058
- * @returns Whether the output target type is one of the "primary" output targets.
1059
- */
1060
- const isEligiblePrimaryPackageOutputTarget = (o) => isOutputTargetDist(o) || isOutputTargetDistCollection(o) || isOutputTargetDistCustomElements(o) || isOutputTargetDistTypes(o);
1061
1072
  /**
1062
1073
  * Retrieve the Stencil component compiler metadata from a collection of Stencil {@link d.Module}s
1063
1074
  * @param moduleFiles the collection of `Module`s to retrieve the metadata from
@@ -1073,6 +1084,19 @@ const getComponentsFromModules = (moduleFiles) => sortBy(flatOne(moduleFiles.map
1073
1084
  function isValidConfigOutputTarget(targetType) {
1074
1085
  return VALID_CONFIG_OUTPUT_TARGETS.includes(targetType);
1075
1086
  }
1087
+ /**
1088
+ * Filter output targets based on devMode and their skipInDev setting.
1089
+ * In dev mode, targets with `skipInDev: true` are filtered out.
1090
+ * In prod mode, all targets are included.
1091
+ *
1092
+ * @param targets Array of output targets to filter
1093
+ * @param devMode Whether we're in dev mode
1094
+ * @returns Filtered array of active targets
1095
+ */
1096
+ const filterActiveTargets = (targets, devMode) => {
1097
+ if (!devMode) return targets;
1098
+ return targets.filter((t) => !t.skipInDev);
1099
+ };
1076
1100
  //#endregion
1077
1101
  //#region src/utils/result.ts
1078
1102
  var result_exports = /* @__PURE__ */ __exportAll({
@@ -1442,4 +1466,4 @@ const validateComponentTag = (tag) => {
1442
1466
  if (tag.lastIndexOf("-") === tag.length - 1) return `"${tag}" tag cannot end with a dash (-)`;
1443
1467
  };
1444
1468
  //#endregion
1445
- export { join$1 as $, isOutputTargetCustom as A, isOutputTargetDocsCustomElementsManifest as B, result_exports as C, stringifyRuntimeData as Ct, getComponentsFromModules as D, getComponentsDtsTypesFilePath as E, isOutputTargetDistLazy as F, isOutputTargetStats as G, isOutputTargetDocsReadme as H, isOutputTargetDistLazyLoader as I, relativeImport as J, isOutputTargetWww as K, isOutputTargetDistTypes as L, isOutputTargetDistCollection as M, isOutputTargetDistCustomElements as N, isEligiblePrimaryPackageOutputTarget as O, isOutputTargetDistGlobalStyles as P, loadTypeScriptDiagnostics as Q, isOutputTargetDocs as R, ok as S, formatLazyBundleRuntimeMeta as St, getComponentsDtsSrcFilePath as T, isOutputTargetDocsVscode as U, isOutputTargetDocsJson as V, isOutputTargetHydrate as W, augmentDiagnosticWithNode as X, shouldExcludeComponent as Y, loadTypeScriptDiagnostic as Z, getSourceMappingUrlForEndOfFile as _, hasWarning as _t, getTextDocs as a, resolve as at, err as b, isGlob as bt, isJsFile as c, escapeHtml as ct, isTsxFile as d, TASK_CANCELED_MSG as dt, normalize as et, parsePackageJson as f, buildError as ft, getInlineSourceMappingUrlLinker as g, hasError as gt, isRemoteUrl as h, catchError as ht, generatePreamble as i, relative$1 as it, isOutputTargetDist as j, isOutputTargetCopy as k, isJsxFile as l, normalizeDiagnostics as lt, readPackageJson as m, buildWarn as mt, addDocBlock as n, normalizeFsPathQuery as nt, hasDependency as o, createOnWarnFn as ot, readOnlyArrayHasStringMember as p, buildJsonFileError as pt, isValidConfigOutputTarget as q, createJsVarName as r, normalizePath as rt, isDtsFile as s, loadRolldownDiagnostics as st, validateComponentTag as t, normalizeFsPath as tt, isTsFile as u, splitLineBreaks as ut, getSourceMappingUrlLinker as v, shouldIgnoreError as vt, filterExcludedComponents as w, byteSize as wt, map as x, formatComponentRuntimeMeta as xt, rolldownToStencilSourceMap as y, isRootPath as yt, isOutputTargetDocsCustom as z };
1469
+ export { join$1 as $, isOutputTargetCopy as A, isOutputTargetLoaderBundle as B, result_exports as C, stringifyRuntimeData as Ct, getComponentsDtsTypesFilePath as D, getComponentsDtsSrcFilePath as E, isOutputTargetDocsCustomElementsManifest as F, isOutputTargetTypes as G, isOutputTargetStandalone as H, isOutputTargetDocsJson as I, relativeImport as J, isOutputTargetWww as K, isOutputTargetDocsReadme as L, isOutputTargetDistLazy as M, isOutputTargetDocs as N, getComponentsFromModules as O, isOutputTargetDocsCustom as P, loadTypeScriptDiagnostics as Q, isOutputTargetDocsVscode as R, ok as S, formatLazyBundleRuntimeMeta as St, filterExcludedComponents as T, isOutputTargetStats as U, isOutputTargetSsr as V, isOutputTargetStencilRebundle as W, augmentDiagnosticWithNode as X, shouldExcludeComponent as Y, loadTypeScriptDiagnostic as Z, getSourceMappingUrlForEndOfFile as _, hasWarning as _t, getTextDocs as a, resolve as at, err as b, isGlob as bt, isJsFile as c, escapeHtml as ct, isTsxFile as d, TASK_CANCELED_MSG as dt, normalize as et, parsePackageJson as f, buildError as ft, getInlineSourceMappingUrlLinker as g, hasError as gt, isRemoteUrl as h, catchError as ht, generatePreamble as i, relative$1 as it, isOutputTargetCustom as j, isOutputTargetAssets as k, isJsxFile as l, normalizeDiagnostics as lt, readPackageJson as m, buildWarn as mt, addDocBlock as n, normalizeFsPathQuery as nt, hasDependency as o, createOnWarnFn as ot, readOnlyArrayHasStringMember as p, buildJsonFileError as pt, isValidConfigOutputTarget as q, createJsVarName as r, normalizePath as rt, isDtsFile as s, loadRolldownDiagnostics as st, validateComponentTag as t, normalizeFsPath as tt, isTsFile as u, splitLineBreaks as ut, getSourceMappingUrlLinker as v, shouldIgnoreError as vt, filterActiveTargets as w, byteSize as wt, map as x, formatComponentRuntimeMeta as xt, rolldownToStencilSourceMap as y, isRootPath as yt, isOutputTargetGlobalStyle as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.5",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -92,33 +92,32 @@
92
92
  "dependencies": {
93
93
  "@parcel/watcher": "^2.5.1",
94
94
  "@rollup/pluginutils": "^5.3.0",
95
- "@stencil/vitest": "^1.10.0",
96
95
  "browserslist": "^4.24.0",
97
96
  "chalk": "^5.6.2",
98
97
  "css-what": "^7.0.0",
99
- "glob": "^10.0.0",
100
- "graceful-fs": "^4.2.11",
101
98
  "lightningcss": "^1.32.0",
102
99
  "magic-string": "^0.30.0",
103
- "minimatch": "^10.1.2",
100
+ "picomatch": "^4.0.3",
104
101
  "postcss": "^8.5.6",
105
102
  "postcss-safe-parser": "^7.0.1",
106
103
  "postcss-selector-parser": "^7.1.1",
107
104
  "resolve": "^1.22.0",
108
- "rolldown": "^1.0.0-rc.13",
105
+ "rolldown": "^1.0.0-rc.15",
109
106
  "semver": "^7.7.4",
110
107
  "terser": "5.37.0",
111
- "typescript": "~6.0.2",
112
- "@stencil/cli": "5.0.0-alpha.4",
113
- "@stencil/dev-server": "5.0.0-alpha.4",
114
- "@stencil/mock-doc": "5.0.0-alpha.4"
108
+ "tinyglobby": "^0.2.15",
109
+ "typescript": ">4.0.0",
110
+ "@stencil/cli": "5.0.0-alpha.5",
111
+ "@stencil/dev-server": "5.0.0-alpha.5",
112
+ "@stencil/mock-doc": "5.0.0-alpha.5"
115
113
  },
116
114
  "devDependencies": {
117
115
  "@ionic/prettier-config": "^4.0.0",
116
+ "@stencil/vitest": "^1.11.6",
118
117
  "prettier": "^3.5.0",
119
- "tsdown": "^0.21.6",
118
+ "tsdown": "^0.21.7",
120
119
  "vitest": "^4.1.1",
121
- "vitest-environment-stencil": "^1.10.0"
120
+ "vitest-environment-stencil": "^1.11.6"
122
121
  },
123
122
  "volta": {
124
123
  "extends": "../../package.json"