@stencil/core 5.0.0-beta.0 → 5.0.0-beta.2

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.
@@ -973,10 +973,19 @@ interface StencilConfig {
973
973
  */
974
974
  rolldownConfig?: RolldownConfig;
975
975
  /**
976
- * Sets if the JS browser files are minified or not. Stencil uses `terser` under the hood.
976
+ * Sets if the JS browser files are minified or not.
977
977
  * Defaults to `false` in dev mode and `true` in production mode.
978
978
  */
979
979
  minifyJs?: boolean;
980
+ /**
981
+ * Which minifier to use for JS output when `minifyJs` is enabled.
982
+ *
983
+ * - `oxc`: built into rolldown. Much faster than terser. Output may be slightly larger.
984
+ * - `terser`: slower, but currently produces the smallest output.
985
+ *
986
+ * Defaults to `oxc`.
987
+ */
988
+ jsMinifier?: 'terser' | 'oxc';
980
989
  /**
981
990
  * Sets if the CSS is minified or not.
982
991
  * Defaults to `false` in dev mode and `true` in production mode.
@@ -1322,7 +1331,7 @@ type RequireFields<T, K extends keyof T> = T & { [P in K]-?: T[P]; };
1322
1331
  /**
1323
1332
  * Fields in {@link Config} to make required for {@link ValidatedConfig}
1324
1333
  */
1325
- type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
1334
+ type StrictConfigFields = keyof Pick<Config, 'cacheDir' | 'devServer' | 'compat' | 'fsNamespace' | 'hydratedFlag' | 'jsMinifier' | 'logLevel' | 'logger' | 'minifyCss' | 'minifyJs' | 'namespace' | 'outputTargets' | 'packageJsonFilePath' | 'rolldownConfig' | 'rootDir' | 'srcDir' | 'srcIndexHtml' | 'sys' | 'transformAliasedImportPaths'>;
1326
1335
  /**
1327
1336
  * A version of {@link Config} that makes certain fields required. This type represents a valid configuration entity.
1328
1337
  * When a configuration is received by the user, it is a bag of unverified data. In order to make stricter guarantees
@@ -4480,6 +4489,12 @@ interface TransformCssToEsmOutput {
4480
4489
  varName: string;
4481
4490
  importPath: string;
4482
4491
  }[];
4492
+ /**
4493
+ * Whether `output` itself has an observable side effect (a plain, untagged CSS file's
4494
+ * generated module self-injects CSSStyleSheets; a Stencil component's tagged `styleUrl`
4495
+ * output doesn't)
4496
+ */
4497
+ moduleSideEffects?: boolean;
4483
4498
  }
4484
4499
  interface PackageJsonData {
4485
4500
  name?: string;
@@ -1,6 +1,6 @@
1
1
  import nodePath from "node:path";
2
2
  import { MockWindow, setupGlobal } from "@stencil/mock-doc";
3
- import ts from "typescript";
3
+ import "typescript";
4
4
  import fs from "node:fs";
5
5
  import "picomatch";
6
6
  import { effect, effect as effect$1, signal } from "@preact/signals-core";
@@ -11,6 +11,7 @@ import "postcss-selector-parser";
11
11
  import "magic-string";
12
12
  import "rolldown";
13
13
  import resolve from "resolve";
14
+ import "rolldown/utils";
14
15
  import "terser";
15
16
  import "css-what";
16
17
  import { execFile } from "node:child_process";
@@ -31,7 +32,7 @@ import "@rollup/pluginutils";
31
32
  import { createHash } from "crypto";
32
33
  import { afterAll, vi } from "vitest";
33
34
  //#region src/version.ts
34
- const version = "5.0.0-beta.0";
35
+ const version = "5.0.0-beta.2";
35
36
  const MEMBER_FLAGS = {
36
37
  String: 1,
37
38
  Number: 2,
@@ -378,10 +379,6 @@ const trimFalsy = (data) => {
378
379
  */
379
380
  const isDef = (v) => v != null && v !== void 0;
380
381
  /**
381
- * This is just a no-op, don't expect it to do anything.
382
- */
383
- const noop = () => {};
384
- /**
385
382
  * Check whether a value is a 'complex type', defined here as an object or a
386
383
  * function.
387
384
  *
@@ -534,23 +531,6 @@ function join(...paths) {
534
531
  */
535
532
  return normalizePath(nodePath.join(...paths), false);
536
533
  }
537
- /**
538
- * A wrapped version of node.js' {@link path.resolve} which adds our custom
539
- * normalization logic. This resolves a path to a given (relative or absolute)
540
- * path.
541
- *
542
- * @throws the underlying node function will throw if any argument is not a
543
- * string
544
- * @param paths a path or path fragments to resolve
545
- * @returns a resolved path!
546
- */
547
- function resolve$1(...paths) {
548
- /**
549
- * When normalizing, we should _not_ attempt to relativize the path returned by the native Node `resolve` method. When
550
- * calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
551
- */
552
- return normalizePath(nodePath.resolve(...paths), false);
553
- }
554
534
  //#endregion
555
535
  //#region src/utils/query-nonce-meta-tag-content.ts
556
536
  /**
@@ -4116,12 +4096,13 @@ const restoreSafeSelector = (placeholders, content) => {
4116
4096
  const _polyfillHost = "-shadowcsshost";
4117
4097
  const _polyfillSlotted = "-shadowcssslotted";
4118
4098
  const _polyfillHostContext = "-shadowcsscontext";
4099
+ const _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
4119
4100
  let _cssColonHostRe;
4120
4101
  let _cssColonHostContextRe;
4121
4102
  let _cssColonSlottedRe;
4122
- const getCssColonHostRe = () => _cssColonHostRe ??= /* @__PURE__ */ new RegExp("(-shadowcsshost)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
4123
- const getCssColonHostContextRe = () => _cssColonHostContextRe ??= /* @__PURE__ */ new RegExp("(-shadowcsscontext)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
4124
- const getCssColonSlottedRe = () => _cssColonSlottedRe ??= /* @__PURE__ */ new RegExp("(-shadowcssslotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
4103
+ const getCssColonHostRe = () => _cssColonHostRe ??= new RegExp("(-shadowcsshost" + _parenSuffix, "gim");
4104
+ const getCssColonHostContextRe = () => _cssColonHostContextRe ??= new RegExp("(-shadowcsscontext" + _parenSuffix, "gim");
4105
+ const getCssColonSlottedRe = () => _cssColonSlottedRe ??= new RegExp("(-shadowcssslotted" + _parenSuffix, "gim");
4125
4106
  const _polyfillHostNoCombinator = "-shadowcsshost-no-combinator";
4126
4107
  const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
4127
4108
  const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
@@ -4384,12 +4365,13 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
4384
4365
  else return shallowPart.trim();
4385
4366
  }).join(", ");
4386
4367
  };
4368
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
4387
4369
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
4388
4370
  return processRules(cssText, (rule) => {
4389
4371
  let selector = rule.selector;
4390
4372
  let content = rule.content;
4391
4373
  if (rule.selector[0] !== "@") selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
4392
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
4374
+ else if (isScopableAtRule(rule.selector)) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
4393
4375
  return {
4394
4376
  selector: selector.replace(/\s{2,}/g, " ").trim(),
4395
4377
  content
@@ -4481,14 +4463,12 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
4481
4463
  rule.selector = placeholder + rule.selector;
4482
4464
  return rule;
4483
4465
  };
4484
- cssText = processRules(cssText, (rule) => {
4466
+ const commentSelectors = (input) => processRules(input, (rule) => {
4485
4467
  if (rule.selector[0] !== "@") return processCommentedSelector(rule);
4486
- else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
4487
- rule.content = processRules(rule.content, processCommentedSelector);
4488
- return rule;
4489
- }
4468
+ if (isScopableAtRule(rule.selector)) rule.content = commentSelectors(rule.content);
4490
4469
  return rule;
4491
4470
  });
4471
+ cssText = commentSelectors(cssText);
4492
4472
  }
4493
4473
  const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
4494
4474
  cssText = [scoped.cssText, ...commentsWithHash].join("\n");
@@ -4686,6 +4666,14 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
4686
4666
  //#endregion
4687
4667
  //#region src/runtime/proxy-component.ts
4688
4668
  /**
4669
+ * Serialize a prop value the way `setAccessor()` does when it reflects it, so the runtime can
4670
+ * recognize an `attributeChangedCallback` it triggered itself.
4671
+ *
4672
+ * @param propValue the current value of a reflected prop
4673
+ * @returns the string the attribute would hold, or `null` if the attribute would be removed
4674
+ */
4675
+ const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
4676
+ /**
4689
4677
  * Attach a series of runtime constructs to a compiled Stencil component
4690
4678
  * constructor, including getters and setters for the `@Prop` and `@State`
4691
4679
  * decorators, callbacks for when attributes change, and so on.
@@ -4833,7 +4821,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
4833
4821
  return;
4834
4822
  }
4835
4823
  const propFlags = members.find(([m]) => m === propName);
4836
- const isBooleanTarget = propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean;
4824
+ const propMemberFlags = propFlags ? propFlags[1][0] : 0;
4825
+ const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
4826
+ if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
4837
4827
  const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4838
4828
  if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
4839
4829
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
@@ -5863,28 +5853,6 @@ new RegExp(`^(${[.../* @__PURE__ */ new Set([
5863
5853
  ])].join("|")})$`);
5864
5854
  promisify(execFile);
5865
5855
  process.platform;
5866
- //#endregion
5867
- //#region src/compiler/sys/typescript/typescript-sys.ts
5868
- const patchTypeScriptSysMinimum = () => {
5869
- if (!ts.sys) ts.sys = {
5870
- args: [],
5871
- createDirectory: noop,
5872
- directoryExists: () => false,
5873
- exit: noop,
5874
- fileExists: () => false,
5875
- getCurrentDirectory: process.cwd,
5876
- getDirectories: () => [],
5877
- getExecutingFilePath: () => "./",
5878
- readDirectory: () => [],
5879
- readFile: noop,
5880
- newLine: "\n",
5881
- resolvePath: resolve$1,
5882
- useCaseSensitiveFileNames: false,
5883
- write: noop,
5884
- writeFile: noop
5885
- };
5886
- };
5887
- patchTypeScriptSysMinimum();
5888
5856
  new Set([
5889
5857
  "CheckboxStateChange",
5890
5858
  "DOMContentLoaded",
@@ -7764,6 +7732,7 @@ function mockValidatedConfig(overrides = {}) {
7764
7732
  logger: mockLogger(),
7765
7733
  minifyCss: false,
7766
7734
  minifyJs: false,
7735
+ jsMinifier: "oxc",
7767
7736
  namespace: "Testing",
7768
7737
  outputTargets: baseConfig.outputTargets ?? [],
7769
7738
  packageJsonFilePath: nodePath.join(rootDir, "package.json"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.2",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -43,6 +43,10 @@
43
43
  "types": "./dist/compiler/utils/index.d.mts",
44
44
  "import": "./dist/compiler/utils/index.mjs"
45
45
  },
46
+ "./compiler/browser": {
47
+ "types": "./dist/compiler/browser.d.ts",
48
+ "import": "./dist/compiler/browser.js"
49
+ },
46
50
  "./jsx-runtime": {
47
51
  "types": "./dist/jsx-runtime.d.mts",
48
52
  "import": "./dist/jsx-runtime.mjs"
@@ -116,14 +120,14 @@
116
120
  "postcss-safe-parser": "^7.0.1",
117
121
  "postcss-selector-parser": "^7.1.5",
118
122
  "resolve": "^1.22.12",
119
- "rolldown": "^1.2.4",
123
+ "rolldown": "^1.2.6",
120
124
  "semver": "^7.8.5",
121
125
  "terser": "^5.50.0",
122
126
  "tinyglobby": "^0.2.17",
123
127
  "typescript": ">5.0.0 <7.0.0",
124
- "@stencil/cli": "5.0.0-beta.0",
125
- "@stencil/dev-server": "5.0.0-beta.0",
126
- "@stencil/mock-doc": "5.0.0-beta.0"
128
+ "@stencil/dev-server": "5.0.0-beta.2",
129
+ "@stencil/cli": "5.0.0-beta.2",
130
+ "@stencil/mock-doc": "5.0.0-beta.2"
127
131
  },
128
132
  "devDependencies": {
129
133
  "@ionic/prettier-config": "^4.0.0",