@stencil/core 5.0.0-beta.7 → 5.0.0-beta.9

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.
@@ -1832,7 +1832,7 @@ const validateComponentTag = (tag) => {
1832
1832
  };
1833
1833
  //#endregion
1834
1834
  //#region src/version.ts
1835
- const version = "5.0.0-beta.7";
1835
+ const version = "5.0.0-beta.9";
1836
1836
  //#endregion
1837
1837
  //#region src/compiler/events.ts
1838
1838
  const buildEvents = () => {
@@ -3789,10 +3789,11 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
3789
3789
  const devMode = isBoolean$1(config.devMode) ? config.devMode : false;
3790
3790
  config._isTesting = !!(process.env.VITEST || process.env.PLAYWRIGHT_TEST || process.env.TEST_WORKER_INDEX || process.env.TEST_PARALLEL_INDEX || false);
3791
3791
  const sys = config.sys ?? bootstrapConfig.sys ?? createNodeSys({ logger });
3792
+ const hasExplicitGlobalStyleWithInput = (config.outputTargets || []).some((o) => isOutputTargetGlobalStyle(o) && isString$1(o.input));
3792
3793
  if ((!isString$1(config.globalStyle) || !isString$1(config.globalScript)) && typeof sys.accessSync === "function") {
3793
3794
  const preRootDir = typeof config.rootDir !== "string" ? "/" : config.rootDir;
3794
3795
  const srcDir = typeof config.srcDir === "string" ? isAbsolute(config.srcDir) ? config.srcDir : join(preRootDir, config.srcDir) : join(preRootDir, "src");
3795
- if (!isString$1(config.globalStyle)) for (const ext of STYLE_EXT) {
3796
+ if (!isString$1(config.globalStyle) && !hasExplicitGlobalStyleWithInput) for (const ext of STYLE_EXT) {
3796
3797
  const candidate = join(srcDir, `global.${ext}`);
3797
3798
  if (sys.accessSync(candidate)) {
3798
3799
  config.globalStyle = candidate;
@@ -1,3 +1,3 @@
1
- import { _ as buildId, a as createPrerenderer, b as versions, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as getScopeId, h as cmpMetaToDocsComponent, i as createSystem, l as createWorkerMessageHandler, m as generateManifest, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as vermoji, x as scopeCss, y as version } from "../compiler-K2S5pO1u.mjs";
1
+ import { _ as buildId, a as createPrerenderer, b as versions, c as createWorkerContext, d as nodeRequire, f as optimizeCss, g as getScopeId, h as cmpMetaToDocsComponent, i as createSystem, l as createWorkerMessageHandler, m as generateManifest, n as transpile, o as loadConfig, p as validateConfig, r as transpileSync, s as createCompiler, t as ts, u as optimizeJs, v as vermoji, x as scopeCss, y as version } from "../compiler-wLrjuSOK.mjs";
2
2
  import { a as LOG_LEVELS, i as CustomElementsExportBehaviorOptions } from "../node-75gQKkFz.mjs";
3
3
  export { CustomElementsExportBehaviorOptions, LOG_LEVELS, buildId, cmpMetaToDocsComponent, createCompiler, createPrerenderer, createSystem, createWorkerContext, createWorkerMessageHandler, generateManifest, getScopeId, loadConfig, nodeRequire, optimizeCss, optimizeJs, scopeCss, transpile, transpileSync, ts, validateConfig, vermoji, version, versions };
@@ -461,9 +461,9 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
461
461
  };
462
462
  //#endregion
463
463
  //#region src/version.ts
464
- const version = "5.0.0-beta.7";
465
- const buildId = "1788951557";
466
- const vermoji = "🐬";
464
+ const version = "5.0.0-beta.9";
465
+ const buildId = "1788990226";
466
+ const vermoji = "🐛";
467
467
  /**
468
468
  * Get the installed version of a tool/dependency.
469
469
  * Handles packages with exports maps that point to subdirectories.
@@ -7372,7 +7372,13 @@ function createEntryModule(cmps) {
7372
7372
  }
7373
7373
  const getLazyEntry = (isBrowser, assetPath, externalRuntime = false) => {
7374
7374
  const s = new MagicString(``);
7375
- s.append(`export { setNonce, setRegistry, setTagTransformer } from '${STENCIL_CORE_ID}';\n`);
7375
+ const platformExports = [
7376
+ "setNonce",
7377
+ "setRegistry",
7378
+ "setTagTransformer"
7379
+ ];
7380
+ if (assetPath) platformExports.push("setAssetPath");
7381
+ s.append(`export { ${platformExports.join(", ")} } from '${STENCIL_CORE_ID}';\n`);
7376
7382
  s.append(`import { bootstrapLazy } from '${STENCIL_CORE_ID}';\n`);
7377
7383
  if (isBrowser) {
7378
7384
  if (assetPath) s.append(`import { setAssetPath } from '${STENCIL_CORE_ID}';\n`);
@@ -9387,15 +9393,17 @@ const generateStandaloneTypesOutput = async (config, compilerCtx, buildCtx, type
9387
9393
  if (outputTarget.autoLoader) {
9388
9394
  const loaderFileName = typeof outputTarget.autoLoader === "object" ? outputTarget.autoLoader.fileName || "loader" : "loader";
9389
9395
  const loaderDtsPath = join$2(outputTarget.dir, `${loaderFileName}.d.ts`);
9390
- const loaderDtsCode = generateLoaderType();
9396
+ const hasAssets = buildCtx.components.some((cmp) => cmp.assetsDirs != null && cmp.assetsDirs.length > 0);
9397
+ const loaderDtsCode = generateLoaderType(hasAssets);
9391
9398
  await compilerCtx.fs.writeFile(loaderDtsPath, loaderDtsCode, { outputTargetType: outputTarget.type });
9392
9399
  }
9393
9400
  };
9394
9401
  /**
9395
9402
  * Generate a type declaration file for the auto-loader module
9403
+ * @param hasAssets whether any component declares assets, matching whether setAssetPath is actually exported
9396
9404
  * @returns the contents of the type declaration file for the loader
9397
9405
  */
9398
- const generateLoaderType = () => {
9406
+ const generateLoaderType = (hasAssets) => {
9399
9407
  return [
9400
9408
  `/**`,
9401
9409
  ` * Start the auto-loader, scanning the DOM and watching for changes.`,
@@ -9409,7 +9417,18 @@ const generateLoaderType = () => {
9409
9417
  ` * Stop the auto-loader and disconnect the MutationObserver.`,
9410
9418
  ` */`,
9411
9419
  `export declare function stop(): void;`,
9412
- ``
9420
+ ``,
9421
+ ...hasAssets ? [
9422
+ `/**`,
9423
+ ` * Used to manually set the base path where component assets can be found. The`,
9424
+ ` * default is relative to this module's own location, which may not hold once a`,
9425
+ ` * consuming bundler relocates it - call this before start() to override.`,
9426
+ ` * @param path the asset path to set`,
9427
+ ` * @returns the set path`,
9428
+ ` */`,
9429
+ `export declare function setAssetPath(path: string): string;`,
9430
+ ``
9431
+ ] : []
9413
9432
  ].join("\n");
9414
9433
  };
9415
9434
  /**
@@ -10354,8 +10373,9 @@ const generateTypesOutput = async (config, compilerCtx, buildCtx, outputTarget)
10354
10373
  await generateAppTypes(config, compilerCtx, buildCtx, distPath);
10355
10374
  const typesDir = outputTarget.dir;
10356
10375
  if (distDtsFilePath) await generateStandaloneTypes(config, compilerCtx, buildCtx, typesDir);
10357
- if (config.outputTargets.some(isOutputTargetLoaderBundle)) await generateLoaderTypes(compilerCtx, typesDir);
10358
- if (config.outputTargets.some(isOutputTargetStandalone)) await generateStandaloneApiTypes(compilerCtx, typesDir);
10376
+ const hasAssets = buildCtx.components.some((cmp) => cmp.assetsDirs != null && cmp.assetsDirs.length > 0);
10377
+ if (config.outputTargets.some(isOutputTargetLoaderBundle)) await generateLoaderTypes(compilerCtx, typesDir, hasAssets);
10378
+ if (config.outputTargets.some(isOutputTargetStandalone)) await generateStandaloneApiTypes(compilerCtx, typesDir, hasAssets);
10359
10379
  };
10360
10380
  /**
10361
10381
  * Generate loader.d.ts file for the loader entry point.
@@ -10363,8 +10383,9 @@ const generateTypesOutput = async (config, compilerCtx, buildCtx, outputTarget)
10363
10383
  *
10364
10384
  * @param compilerCtx the current compiler context
10365
10385
  * @param typesDir the directory to write the loader.d.ts file to
10386
+ * @param hasAssets whether any component declares assets, matching whether setAssetPath is actually exported
10366
10387
  */
10367
- const generateLoaderTypes = async (compilerCtx, typesDir) => {
10388
+ const generateLoaderTypes = async (compilerCtx, typesDir, hasAssets) => {
10368
10389
  const loaderDtsContent = `export * from './components';
10369
10390
  export interface CustomElementsDefineOptions {
10370
10391
  exclude?: string[];
@@ -10400,7 +10421,17 @@ export type TagTransformer = (tag: string) => string;
10400
10421
  * Useful for namespacing (e.g. \`my-button\` → \`acme-button\`) in multi-library pages.
10401
10422
  */
10402
10423
  export declare function setTagTransformer(transformer: TagTransformer): void;
10403
- `;
10424
+ ${hasAssets ? `
10425
+ /**
10426
+ * Used to manually set the base path where component assets can be found. The
10427
+ * default is relative to this module's own location, which may not hold once a
10428
+ * bundler relocates it, or once its CDN URL diverges from the assets' own -
10429
+ * import and call this before the module's default has been used to override it.
10430
+ * @param path the asset path to set
10431
+ * @returns the set path
10432
+ */
10433
+ export declare function setAssetPath(path: string): string;
10434
+ ` : ""}`;
10404
10435
  const loaderDtsPath = join$2(typesDir, "loader.d.ts");
10405
10436
  await compilerCtx.fs.writeFile(loaderDtsPath, loaderDtsContent);
10406
10437
  };
@@ -10410,8 +10441,9 @@ export declare function setTagTransformer(transformer: TagTransformer): void;
10410
10441
  *
10411
10442
  * @param compilerCtx the current compiler context
10412
10443
  * @param typesDir the directory to write the standalone.d.ts file to
10444
+ * @param hasAssets whether any component declares assets, matching whether setAssetPath is actually exported
10413
10445
  */
10414
- const generateStandaloneApiTypes = async (compilerCtx, typesDir) => {
10446
+ const generateStandaloneApiTypes = async (compilerCtx, typesDir, hasAssets) => {
10415
10447
  const standaloneDtsContent = `/**
10416
10448
  * Used to specify a nonce value that corresponds with an application's CSP.
10417
10449
  * When set, the nonce will be added to all dynamically created script and style tags at runtime.
@@ -10444,7 +10476,16 @@ export interface SetPlatformOptions {
10444
10476
  rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
10445
10477
  }
10446
10478
  export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
10447
- `;
10479
+ ${hasAssets ? `
10480
+ /**
10481
+ * Used to manually set the base path where component assets can be found. The
10482
+ * default is relative to this module's own location, which may not hold once a
10483
+ * consuming bundler relocates it - call this before any component module is imported to override.
10484
+ * @param path the asset path to set
10485
+ * @returns the set path
10486
+ */
10487
+ export declare const setAssetPath: (path: string) => string;
10488
+ ` : ""}`;
10448
10489
  const standaloneDtsPath = join$2(typesDir, "standalone.d.ts");
10449
10490
  await compilerCtx.fs.writeFile(standaloneDtsPath, standaloneDtsContent);
10450
10491
  };
@@ -12405,7 +12446,7 @@ const generateLoaderModule = (components, outputTarget, relativeAssetPath) => {
12405
12446
  const autoStart = typeof autoLoaderConfig === "object" ? autoLoaderConfig.autoStart !== false : true;
12406
12447
  const tagsList = components.map((cmp) => `'${cmp.tagName}'`).join(", ");
12407
12448
  const switchCases = components.map((cmp) => ` case '${cmp.tagName}': module = await import('./${cmp.tagName}.js'); break;`).join("\n");
12408
- const assetPathImport = relativeAssetPath ? `import { setAssetPath } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';\n` : "";
12449
+ const assetPathImport = relativeAssetPath ? `import { setAssetPath } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';\nexport { setAssetPath };\n` : "";
12409
12450
  const assetPathInit = relativeAssetPath ? `setAssetPath(new URL('${relativeAssetPath}', String(import.meta.url)).href);\n` : "";
12410
12451
  return `
12411
12452
  import { transformTag, getRegistry } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';
@@ -12766,12 +12807,25 @@ const addStandaloneInputs = (config, buildCtx, bundleOpts, outputTarget) => {
12766
12807
  const indexImports = [];
12767
12808
  const indexExports = [];
12768
12809
  const exportNames = [];
12810
+ let relativeAssetPath;
12811
+ if (components.some((cmp) => cmp.assetsDirs != null && cmp.assetsDirs.length > 0)) {
12812
+ const assetsTarget = config.outputTargets.find(isOutputTargetAssets);
12813
+ if (assetsTarget?.dir && outputTarget.dir) {
12814
+ const rel = relative$1(outputTarget.dir, assetsTarget.dir);
12815
+ relativeAssetPath = rel.endsWith("/") ? rel : rel + "/";
12816
+ }
12817
+ }
12769
12818
  components.forEach((cmp) => {
12770
12819
  const exp = [];
12771
12820
  const exportName = dashToPascalCase(cmp.tagName);
12772
12821
  const importName = cmp.componentClassName;
12773
12822
  const importAs = `$Cmp${exportName}`;
12774
12823
  const coreKey = `\0${exportName}`;
12824
+ if (relativeAssetPath) {
12825
+ exp.push(`import { setAssetPath } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';`);
12826
+ exp.push(`export { setAssetPath };`);
12827
+ exp.push(`setAssetPath(new URL('${relativeAssetPath}', import.meta.url).href);`);
12828
+ }
12775
12829
  if (cmp.isPlain) {
12776
12830
  exp.push(`export { ${importName} as ${exportName} } from '${cmp.sourceFilePath}';`);
12777
12831
  indexExports.push(`export { ${exportName} } from '${coreKey}';`);
@@ -12786,14 +12840,6 @@ const addStandaloneInputs = (config, buildCtx, bundleOpts, outputTarget) => {
12786
12840
  bundleOpts.inputs[cmp.tagName] = coreKey;
12787
12841
  bundleOpts.loader[coreKey] = exp.join("\n");
12788
12842
  });
12789
- let relativeAssetPath;
12790
- if (components.some((cmp) => cmp.assetsDirs != null && cmp.assetsDirs.length > 0)) {
12791
- const assetsTarget = config.outputTargets.find(isOutputTargetAssets);
12792
- if (assetsTarget?.dir && outputTarget.dir) {
12793
- const rel = relative$1(outputTarget.dir, assetsTarget.dir);
12794
- relativeAssetPath = rel.endsWith("/") ? rel : rel + "/";
12795
- }
12796
- }
12797
12843
  bundleOpts.loader["\0core"] = generateEntryPoint(outputTarget, indexImports, indexExports, exportNames, relativeAssetPath);
12798
12844
  if (outputTarget.autoLoader) {
12799
12845
  const loaderFileName = typeof outputTarget.autoLoader === "object" ? outputTarget.autoLoader.fileName || "loader" : "loader";
@@ -12817,6 +12863,7 @@ const generateEntryPoint = (outputTarget, cmpImports = [], cmpExports = [], cmpN
12817
12863
  exports.push(`export { setNonce, setRegistry, setTagTransformer, setPlatformOptions } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';`, `export * from '${USER_INDEX_ENTRY_ID}';`);
12818
12864
  if (relativeAssetPath) {
12819
12865
  imports.push(`import { setAssetPath } from '${STENCIL_INTERNAL_STANDALONE_CLIENT_PLATFORM_ID}';`);
12866
+ exports.push(`export { setAssetPath };`);
12820
12867
  body.push(`setAssetPath(new URL('${relativeAssetPath}', import.meta.url).href);`);
12821
12868
  }
12822
12869
  if (outputTarget.includeGlobalScripts !== false) {
@@ -20661,10 +20708,11 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
20661
20708
  const devMode = isBoolean$1(config.devMode) ? config.devMode : false;
20662
20709
  config._isTesting = !!(process.env.VITEST || process.env.PLAYWRIGHT_TEST || process.env.TEST_WORKER_INDEX || process.env.TEST_PARALLEL_INDEX || process.env.NODE_ENV === "test");
20663
20710
  const sys = config.sys ?? bootstrapConfig.sys ?? createNodeSys({ logger });
20711
+ const hasExplicitGlobalStyleWithInput = (config.outputTargets || []).some((o) => isOutputTargetGlobalStyle(o) && isString$1(o.input));
20664
20712
  if ((!isString$1(config.globalStyle) || !isString$1(config.globalScript)) && typeof sys.accessSync === "function") {
20665
20713
  const preRootDir = typeof config.rootDir !== "string" ? "/" : config.rootDir;
20666
20714
  const srcDir = typeof config.srcDir === "string" ? isAbsolute$1(config.srcDir) ? config.srcDir : join$1(preRootDir, config.srcDir) : join$1(preRootDir, "src");
20667
- if (!isString$1(config.globalStyle)) for (const ext of STYLE_EXT) {
20715
+ if (!isString$1(config.globalStyle) && !hasExplicitGlobalStyleWithInput) for (const ext of STYLE_EXT) {
20668
20716
  const candidate = join$1(srcDir, `global.${ext}`);
20669
20717
  if (sys.accessSync(candidate)) {
20670
20718
  config.globalStyle = candidate;
@@ -1,4 +1,4 @@
1
- import { l as createWorkerMessageHandler } from "../../compiler-K2S5pO1u.mjs";
1
+ import { l as createWorkerMessageHandler } from "../../compiler-wLrjuSOK.mjs";
2
2
  import { t as createNodeSys } from "../../node-75gQKkFz.mjs";
3
3
  //#region src/sys/node/node-worker-thread.ts
4
4
  /**
@@ -32,7 +32,7 @@ import "@rollup/pluginutils";
32
32
  import { createHash } from "crypto";
33
33
  import { afterAll, vi } from "vitest";
34
34
  //#region src/version.ts
35
- const version = "5.0.0-beta.7";
35
+ const version = "5.0.0-beta.9";
36
36
  const MEMBER_FLAGS = {
37
37
  String: 1,
38
38
  Number: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stencil/core",
3
- "version": "5.0.0-beta.7",
3
+ "version": "5.0.0-beta.9",
4
4
  "description": "A Compiler for Web Components and Progressive Web Apps",
5
5
  "keywords": [
6
6
  "components",
@@ -125,9 +125,9 @@
125
125
  "terser": "^5.50.0",
126
126
  "tinyglobby": "^0.2.17",
127
127
  "typescript": ">5.0.0 <7.0.0",
128
- "@stencil/cli": "5.0.0-beta.7",
129
- "@stencil/mock-doc": "5.0.0-beta.7",
130
- "@stencil/dev-server": "5.0.0-beta.7"
128
+ "@stencil/cli": "5.0.0-beta.9",
129
+ "@stencil/dev-server": "5.0.0-beta.9",
130
+ "@stencil/mock-doc": "5.0.0-beta.9"
131
131
  },
132
132
  "devDependencies": {
133
133
  "@ionic/prettier-config": "^4.0.0",