@fluentic/style 0.1.0-beta.16 → 0.1.0-beta.18

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 (89) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/compiler/compiler/cache_identity.ts +115 -0
  3. package/compiler/compiler/compiler.ts +28 -1
  4. package/compiler/compiler/persistent_cache.ts +310 -0
  5. package/compiler/compiler/types.ts +12 -0
  6. package/compiler/extract/collector.ts +2 -2
  7. package/compiler/transform/evaluator/lazy_bindings.ts +63 -0
  8. package/compiler/transform/evaluator/metadata_cache.ts +124 -0
  9. package/compiler/transform/evaluator/tracer.ts +101 -86
  10. package/compiler/transform/extract/plugin.ts +21 -11
  11. package/compiler/transform/extract/utils/state.ts +3 -2
  12. package/compiler/utils/check_diagnostics.ts +18 -0
  13. package/compiler/utils/file_resolver.ts +24 -0
  14. package/dist/combine-BpOQWCtM.js.map +1 -1
  15. package/dist/compiler/index.mjs +1 -1
  16. package/dist/{compiler-AOb_VaKQ.mjs → compiler-Dpd41bCS.mjs} +646 -69
  17. package/dist/compiler-Dpd41bCS.mjs.map +1 -0
  18. package/dist/entry/rsc-dev.js.map +1 -1
  19. package/dist/{loader-fAuIjIik.mjs → loader-CR_NH6ub.mjs} +3 -3
  20. package/dist/{loader-fAuIjIik.mjs.map → loader-CR_NH6ub.mjs.map} +1 -1
  21. package/dist/{misc-CyZgGtc9.mjs → misc-D5AjOWP-.mjs} +31 -5
  22. package/dist/misc-D5AjOWP-.mjs.map +1 -0
  23. package/dist/plugin/farm/index.mjs +4 -4
  24. package/dist/plugin/farm/index.mjs.map +1 -1
  25. package/dist/plugin/nextjs/index.mjs +6 -6
  26. package/dist/plugin/nextjs/index.mjs.map +1 -1
  27. package/dist/plugin/nextjs/loader.mjs +4 -4
  28. package/dist/plugin/parcel/index.cjs +1 -1
  29. package/dist/plugin/parcel/index.mjs +2 -2
  30. package/dist/plugin/parcel/optimizer.cjs +1 -1
  31. package/dist/plugin/parcel/optimizer.mjs +2 -2
  32. package/dist/plugin/parcel/resolver.cjs +1 -1
  33. package/dist/plugin/parcel/resolver.mjs +2 -2
  34. package/dist/plugin/parcel/runtime.cjs +1 -1
  35. package/dist/plugin/parcel/runtime.mjs +1 -1
  36. package/dist/plugin/parcel/transformer.cjs +1 -1
  37. package/dist/plugin/parcel/transformer.mjs +2 -2
  38. package/dist/plugin/rspack/index.mjs +2 -2
  39. package/dist/plugin/vite/index.mjs +23 -20
  40. package/dist/plugin/vite/index.mjs.map +1 -1
  41. package/dist/plugin/webpack/index.mjs +2 -2
  42. package/dist/plugin/webpack/loader.mjs +2 -2
  43. package/dist/{registry-BMijh1CM.mjs → registry-CdSHrX-o.mjs} +2 -2
  44. package/dist/{registry-BMijh1CM.mjs.map → registry-CdSHrX-o.mjs.map} +1 -1
  45. package/dist/{shared-DY0kuBcN.cjs → shared-CcB1KDFI.cjs} +666 -76
  46. package/dist/shared-CcB1KDFI.cjs.map +1 -0
  47. package/dist/{shared-BfASWZo1.mjs → shared-CobOEWzt.mjs} +5 -5
  48. package/dist/shared-CobOEWzt.mjs.map +1 -0
  49. package/dist/{sidecar-cCzTDkzg.mjs → sidecar-CHDVQqN_.mjs} +3 -3
  50. package/dist/{sidecar-cCzTDkzg.mjs.map → sidecar-CHDVQqN_.mjs.map} +1 -1
  51. package/dist/style-CRs-vfY1.js.map +1 -1
  52. package/dist/types/compiler/compiler/cache_identity.d.ts +4 -0
  53. package/dist/types/compiler/compiler/compiler.d.ts +12 -0
  54. package/dist/types/compiler/compiler/persistent_cache.d.ts +14 -0
  55. package/dist/types/compiler/compiler/types.d.ts +11 -0
  56. package/dist/types/compiler/extract/collector.d.ts +1 -1
  57. package/dist/types/compiler/transform/evaluator/lazy_bindings.d.ts +22 -0
  58. package/dist/types/compiler/transform/evaluator/metadata_cache.d.ts +13 -0
  59. package/dist/types/compiler/transform/evaluator/tracer.d.ts +7 -0
  60. package/dist/types/compiler/transform/extract/utils/state.d.ts +3 -2
  61. package/dist/types/compiler/utils/check_diagnostics.d.ts +7 -0
  62. package/dist/types/compiler/utils/file_resolver.d.ts +4 -0
  63. package/dist/types/plugin/bundler/vite/state.d.ts +24 -0
  64. package/dist/types/plugin/utils/compiler.d.ts +12 -1
  65. package/dist/types/plugin/utils/filter.d.ts +11 -0
  66. package/dist/types/style/tokens.d.ts +1 -1
  67. package/dist/{utils-BO6Ix8t5.mjs → utils-CICsXGqS.mjs} +5 -5
  68. package/dist/utils-CICsXGqS.mjs.map +1 -0
  69. package/dist/{utils-EG9gh2g3.mjs → utils-XfsnoteV.mjs} +3 -3
  70. package/dist/{utils-EG9gh2g3.mjs.map → utils-XfsnoteV.mjs.map} +1 -1
  71. package/dist/{webpack-WXAJ3IYn.mjs → webpack-BAflvDbq.mjs} +7 -7
  72. package/dist/webpack-BAflvDbq.mjs.map +1 -0
  73. package/package.json +1 -1
  74. package/plugin/bundler/farm/plugin.ts +1 -1
  75. package/plugin/bundler/parcel/shared.ts +1 -1
  76. package/plugin/bundler/vite/plugin.ts +20 -17
  77. package/plugin/bundler/vite/state.ts +5 -6
  78. package/plugin/bundler/webpack/plugin.ts +2 -2
  79. package/plugin/nextjs/plugin.ts +2 -2
  80. package/plugin/nextjs/utils.ts +1 -1
  81. package/plugin/utils/compiler.ts +1 -2
  82. package/plugin/utils/filter.ts +65 -1
  83. package/style/tokens.ts +2 -1
  84. package/dist/compiler-AOb_VaKQ.mjs.map +0 -1
  85. package/dist/misc-CyZgGtc9.mjs.map +0 -1
  86. package/dist/shared-BfASWZo1.mjs.map +0 -1
  87. package/dist/shared-DY0kuBcN.cjs.map +0 -1
  88. package/dist/utils-BO6Ix8t5.mjs.map +0 -1
  89. package/dist/webpack-WXAJ3IYn.mjs.map +0 -1
@@ -1,10 +1,16 @@
1
+ import { createRequire } from "node:module";
1
2
  import * as crypto from "node:crypto";
3
+ import { createHash, randomUUID } from "node:crypto";
2
4
  import * as fs$1 from "node:fs";
3
5
  import * as path$1 from "node:path";
6
+ import path from "node:path";
4
7
  import * as BabelCore from "@babel/core";
5
8
  import picomatch from "picomatch";
6
9
  import { SelectorType, parse } from "css-what";
7
10
  import { ResolverFactory } from "oxc-resolver";
11
+ import { fileURLToPath } from "node:url";
12
+ import { types } from "node:util";
13
+ import { deserialize, serialize } from "node:v8";
8
14
  //#region compiler/compiler/cache.ts
9
15
  function createCompilerCache(args) {
10
16
  const { cacheDir } = args;
@@ -85,8 +91,8 @@ function createCssCollector() {
85
91
  add(item) {
86
92
  items.push(item);
87
93
  },
88
- addMany(items) {
89
- items.push(...items);
94
+ addMany(rules) {
95
+ items.push(...rules);
90
96
  },
91
97
  getItems() {
92
98
  return items;
@@ -621,7 +627,7 @@ const DEV_CONFIG_DEFAULT = {
621
627
  sourcemapLocationMode: "style",
622
628
  isElementClassNameEnabled: true
623
629
  };
624
- globalData("config.dev.isDev", () => ({ isDev: false }));
630
+ const IS_DEV = globalData("config.dev.isDev", () => ({ isDev: false }));
625
631
  const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
626
632
  globalData("config.dev.plugin", () => ({ config: null }));
627
633
  globalData("config.dev.base", () => ({ config: null }));
@@ -5981,6 +5987,20 @@ function transformDebug(internal, args, deps) {
5981
5987
  //#endregion
5982
5988
  //#region compiler/utils/file_resolver.ts
5983
5989
  const contentCache = /* @__PURE__ */ new Map();
5990
+ let resolutionObserver = null;
5991
+ /** Synchronous extraction only; restore the previous observer even when extraction throws. */
5992
+ function observeFileResolutions(observer, run) {
5993
+ const previous = resolutionObserver;
5994
+ resolutionObserver = (source, fromFile, result) => {
5995
+ previous?.(source, fromFile, result);
5996
+ observer(source, fromFile, result);
5997
+ };
5998
+ try {
5999
+ return run();
6000
+ } finally {
6001
+ resolutionObserver = previous;
6002
+ }
6003
+ }
5984
6004
  const resolver = new ResolverFactory({
5985
6005
  conditionNames: [
5986
6006
  "import",
@@ -6005,6 +6025,11 @@ function clearResolverCache() {
6005
6025
  resolver.clearCache();
6006
6026
  }
6007
6027
  function resolveFile(source, fromFile) {
6028
+ const result = readResolvedFile(source, fromFile);
6029
+ resolutionObserver?.(source, fromFile, result);
6030
+ return result;
6031
+ }
6032
+ function readResolvedFile(source, fromFile) {
6008
6033
  const filePath = resolveFilePath(source, fromFile);
6009
6034
  if (!filePath) return null;
6010
6035
  let stat;
@@ -7523,10 +7548,273 @@ function hasGlobalRuntimeValue(value, seen = /* @__PURE__ */ new Set()) {
7523
7548
  return Object.values(value).some((item) => hasGlobalRuntimeValue(item, seen));
7524
7549
  }
7525
7550
  //#endregion
7551
+ //#region compiler/transform/evaluator/lazy_bindings.ts
7552
+ /** Map-compatible bindings whose initializers run only when their values are read. */
7553
+ var LazyBindings = class LazyBindings extends Map {
7554
+ constructor(..._args) {
7555
+ super(..._args);
7556
+ this.initializers = /* @__PURE__ */ new Map();
7557
+ }
7558
+ setLazy(name, initializer) {
7559
+ this.initializers.set(name, initializer);
7560
+ super.set(name, evalFail(`Circular binding: ${name}`));
7561
+ }
7562
+ /** Capture a declaration environment without forcing pending initializers. */
7563
+ fork() {
7564
+ const bindings = new LazyBindings();
7565
+ for (const [name, value] of super.entries()) bindings.set(name, value);
7566
+ for (const [name, initializer] of this.initializers) bindings.setLazy(name, initializer);
7567
+ return bindings;
7568
+ }
7569
+ set(name, value) {
7570
+ this.initializers.delete(name);
7571
+ return super.set(name, value);
7572
+ }
7573
+ delete(name) {
7574
+ this.initializers.delete(name);
7575
+ return super.delete(name);
7576
+ }
7577
+ clear() {
7578
+ this.initializers.clear();
7579
+ super.clear();
7580
+ }
7581
+ get(name) {
7582
+ const initializer = this.initializers.get(name);
7583
+ if (initializer) {
7584
+ this.initializers.delete(name);
7585
+ super.set(name, initializer());
7586
+ }
7587
+ return super.get(name);
7588
+ }
7589
+ forEach(callback, thisArg) {
7590
+ for (const key of this.keys()) callback.call(thisArg, this.get(key), key, this);
7591
+ }
7592
+ *entries() {
7593
+ for (const key of this.keys()) yield [key, this.get(key)];
7594
+ }
7595
+ *values() {
7596
+ for (const key of this.keys()) yield this.get(key);
7597
+ }
7598
+ [Symbol.iterator]() {
7599
+ return this.entries();
7600
+ }
7601
+ };
7602
+ //#endregion
7603
+ //#region compiler/compiler/cache_identity.ts
7604
+ let identity;
7605
+ /** Fingerprint actual compiler and dependency bytes, including locally patched packages.
7606
+ * Computed once per process: replacing loaded compiler code requires restarting Node.
7607
+ */
7608
+ function getCompilerCacheIdentity() {
7609
+ if (identity !== void 0) return identity;
7610
+ try {
7611
+ const filename = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
7612
+ const root = findPackageRoot(filename, "@fluentic/style");
7613
+ const hash = createHash("sha256");
7614
+ hash.update(JSON.stringify([
7615
+ process.versions,
7616
+ process.platform,
7617
+ process.arch,
7618
+ process.execArgv,
7619
+ process.env.NODE_OPTIONS,
7620
+ process.env.NODE_ENV,
7621
+ process.env.BABEL_ENV
7622
+ ]));
7623
+ const visited = /* @__PURE__ */ new Set();
7624
+ const hashTree = (directory, source = false) => {
7625
+ for (const item of fs$1.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
7626
+ if (item.name === "node_modules" || item.name === ".git") continue;
7627
+ const file = path.join(directory, item.name);
7628
+ if (item.isDirectory()) hashTree(file, source);
7629
+ else if (item.isFile()) {
7630
+ if (!(source ? /\.(?:[cm]?[jt]sx?|json|node|wasm)$/ : /\.(?:[cm]?js|json|node|wasm)$/).test(item.name)) continue;
7631
+ hash.update(file).update("\0").update(fs$1.readFileSync(file)).update("\0");
7632
+ } else throw new Error("Unsupported package entry");
7633
+ }
7634
+ };
7635
+ const visit = (directory) => {
7636
+ directory = fs$1.realpathSync(directory);
7637
+ if (visited.has(directory)) return;
7638
+ visited.add(directory);
7639
+ hashTree(directory);
7640
+ const manifest = JSON.parse(fs$1.readFileSync(path.join(directory, "package.json"), "utf8"));
7641
+ const require = createRequire(path.join(directory, "package.json"));
7642
+ const optional = manifest.optionalDependencies ?? {};
7643
+ for (const name of Object.keys({
7644
+ ...manifest.dependencies,
7645
+ ...optional
7646
+ }).sort()) {
7647
+ let dependency;
7648
+ try {
7649
+ dependency = resolvePackageRoot(require, name);
7650
+ } catch (error) {
7651
+ if (name in optional) {
7652
+ hash.update("absent:" + name);
7653
+ continue;
7654
+ }
7655
+ throw error;
7656
+ }
7657
+ visit(dependency);
7658
+ }
7659
+ };
7660
+ const manifest = JSON.parse(fs$1.readFileSync(path.join(root, "package.json"), "utf8"));
7661
+ hash.update(fs$1.readFileSync(path.join(root, "package.json")));
7662
+ if (filename.startsWith(path.join(root, "dist") + path.sep)) hashTree(path.join(root, "dist"));
7663
+ else for (const item of manifest.files) {
7664
+ if (item === "dist") continue;
7665
+ const file = path.join(root, item);
7666
+ if (!fs$1.existsSync(file)) continue;
7667
+ if (fs$1.statSync(file).isDirectory()) hashTree(file, true);
7668
+ else if (/\.[cm]?[jt]sx?$/.test(item)) hash.update(item).update(fs$1.readFileSync(file));
7669
+ }
7670
+ const require = createRequire(path.join(root, "package.json"));
7671
+ for (const name of [
7672
+ "@babel/core",
7673
+ "@jridgewell/trace-mapping",
7674
+ "css-what",
7675
+ "oxc-resolver",
7676
+ "picomatch"
7677
+ ]) visit(resolvePackageRoot(require, name));
7678
+ identity = hash.digest("hex");
7679
+ } catch {
7680
+ identity = null;
7681
+ }
7682
+ return identity;
7683
+ }
7684
+ function resolvePackageRoot(require, name) {
7685
+ for (const directory of require.resolve.paths(name) ?? []) {
7686
+ const root = path.join(directory, name);
7687
+ if (fs$1.existsSync(path.join(root, "package.json"))) return fs$1.realpathSync(root);
7688
+ }
7689
+ try {
7690
+ return path.dirname(require.resolve(name + "/package.json"));
7691
+ } catch {
7692
+ return findPackageRoot(require.resolve(name), name);
7693
+ }
7694
+ }
7695
+ function findPackageRoot(filename, name) {
7696
+ let directory = path.dirname(filename);
7697
+ while (true) {
7698
+ const manifest = path.join(directory, "package.json");
7699
+ if (fs$1.existsSync(manifest) && JSON.parse(fs$1.readFileSync(manifest, "utf8")).name === name) return directory;
7700
+ const parent = path.dirname(directory);
7701
+ if (parent === directory) throw new Error("Package root not found");
7702
+ directory = parent;
7703
+ }
7704
+ }
7705
+ //#endregion
7706
+ //#region compiler/transform/evaluator/metadata_cache.ts
7707
+ const defaultParser = BabelCore.parseSync;
7708
+ const MAX_MEMORY_BYTES = 32 * 1024 * 1024;
7709
+ /** Immutable syntax only. Every consumer gets fresh nodes before annotations/evaluation. */
7710
+ function createTraceMetadataCache(internal) {
7711
+ const memory = /* @__PURE__ */ new Map();
7712
+ let memoryBytes = 0;
7713
+ let memoryVersion = internal.options.cache?.version;
7714
+ const stats = {
7715
+ parses: 0,
7716
+ memoryHits: 0,
7717
+ diskHits: 0,
7718
+ writes: 0
7719
+ };
7720
+ const remember = (filePath, contentHash, json) => {
7721
+ const previous = memory.get(filePath);
7722
+ if (previous) memoryBytes -= previous.json.length * 2;
7723
+ memory.delete(filePath);
7724
+ if (json.length * 2 > MAX_MEMORY_BYTES) return;
7725
+ while (memoryBytes + json.length * 2 > MAX_MEMORY_BYTES) {
7726
+ const oldest = memory.keys().next().value;
7727
+ memoryBytes -= memory.get(oldest).json.length * 2;
7728
+ memory.delete(oldest);
7729
+ }
7730
+ memory.set(filePath, {
7731
+ contentHash,
7732
+ json
7733
+ });
7734
+ memoryBytes += json.length * 2;
7735
+ };
7736
+ const parse = (babel, filePath, content) => {
7737
+ if (!Object.is(memoryVersion, internal.options.cache?.version)) {
7738
+ memory.clear();
7739
+ memoryBytes = 0;
7740
+ memoryVersion = internal.options.cache?.version;
7741
+ }
7742
+ const supportedParser = babel.parseSync === defaultParser;
7743
+ const contentHash = hash(content);
7744
+ const cached = supportedParser ? memory.get(filePath) : void 0;
7745
+ if (cached?.contentHash === contentHash) {
7746
+ stats.memoryHits++;
7747
+ memory.delete(filePath);
7748
+ memory.set(filePath, cached);
7749
+ return JSON.parse(cached.json);
7750
+ }
7751
+ const identity = supportedParser && internal.options.cache?.persistent !== false ? getCompilerCacheIdentity() : null;
7752
+ const filename = identity ? path.join(internal.cacheDir, "trace-metadata-v1", identity, hash(JSON.stringify(internal.options.cache?.version ?? null)), hash(filePath) + ".json") : null;
7753
+ if (filename) try {
7754
+ const record = JSON.parse(fs$1.readFileSync(filename, "utf8"));
7755
+ if (record.version === 1 && record.filePath === filePath && record.contentHash === contentHash && record.ast?.type === "File" && record.ast.program?.type === "Program" && Array.isArray(record.ast.program.body)) {
7756
+ const json = JSON.stringify(record.ast);
7757
+ if (record.checksum === hash(json)) {
7758
+ remember(filePath, contentHash, json);
7759
+ stats.diskHits++;
7760
+ return record.ast;
7761
+ }
7762
+ }
7763
+ } catch {}
7764
+ let ast;
7765
+ try {
7766
+ stats.parses++;
7767
+ ast = babel.parseSync(content, {
7768
+ ...babelTransformOptions(),
7769
+ filename: filePath
7770
+ });
7771
+ } catch {
7772
+ return null;
7773
+ }
7774
+ if (!ast || !supportedParser) return ast;
7775
+ let temporary;
7776
+ try {
7777
+ const json = JSON.stringify(ast, (_key, value) => {
7778
+ if (typeof value === "number" && (!Number.isFinite(value) || Object.is(value, -0)) || typeof value === "bigint" || typeof value === "function" || typeof value === "symbol") throw new Error("Non-JSON syntax data");
7779
+ return value;
7780
+ });
7781
+ remember(filePath, contentHash, json);
7782
+ if (filename) {
7783
+ const record = {
7784
+ version: 1,
7785
+ filePath,
7786
+ contentHash,
7787
+ checksum: hash(json),
7788
+ ast
7789
+ };
7790
+ fs$1.mkdirSync(path.dirname(filename), { recursive: true });
7791
+ temporary = filename + "." + randomUUID() + ".tmp";
7792
+ fs$1.writeFileSync(temporary, JSON.stringify(record), "utf8");
7793
+ fs$1.renameSync(temporary, filename);
7794
+ stats.writes++;
7795
+ }
7796
+ } catch {} finally {
7797
+ if (temporary) try {
7798
+ fs$1.unlinkSync(temporary);
7799
+ } catch {}
7800
+ }
7801
+ return ast;
7802
+ };
7803
+ return {
7804
+ parse,
7805
+ getStats: () => ({ ...stats })
7806
+ };
7807
+ }
7808
+ function hash(content) {
7809
+ return createHash("sha256").update(content).digest("hex");
7810
+ }
7811
+ //#endregion
7526
7812
  //#region compiler/transform/evaluator/tracer.ts
7527
- const CACHE_TYPE = "transform-trace";
7813
+ const CACHE_TYPE = "transform-trace-links-v2";
7528
7814
  function createTracer(internal) {
7529
7815
  const active = /* @__PURE__ */ new Set();
7816
+ const cyclic = /* @__PURE__ */ new Set();
7817
+ const metadata = createTraceMetadataCache(internal);
7530
7818
  const resolveImport = (babel, source, fromFile) => {
7531
7819
  return traceModuleResult(babel, source, fromFile)?.bindings ?? null;
7532
7820
  };
@@ -7539,35 +7827,55 @@ function createTracer(internal) {
7539
7827
  contentHash,
7540
7828
  cacheType: CACHE_TYPE
7541
7829
  });
7542
- if (cached && areDependenciesFresh(cached.dependencies ?? [])) return {
7830
+ if (cached?.bindings instanceof Map && areDependenciesFresh(cached.dependencies ?? [])) return {
7831
+ source,
7832
+ fromFile,
7543
7833
  filePath: resolved.filePath,
7544
7834
  contentHash,
7545
- bindings: new Map(cached.bindings),
7835
+ bindings: cached.bindings,
7546
7836
  dependencies: cached.dependencies ?? []
7547
7837
  };
7548
- if (active.has(resolved.filePath)) return null;
7838
+ if (active.has(resolved.filePath)) {
7839
+ for (const file of active) cyclic.add(file);
7840
+ return null;
7841
+ }
7549
7842
  active.add(resolved.filePath);
7550
7843
  try {
7551
7844
  const dependencies = /* @__PURE__ */ new Map();
7845
+ const dependencyList = [];
7846
+ const onTrack = () => {
7847
+ dependencyList.splice(0, dependencyList.length, ...dependencies.values());
7848
+ };
7552
7849
  const resolveDependency = (source, fromFile) => {
7850
+ const dependency = resolveFile(source, fromFile);
7851
+ addTraceDependency(dependencies, {
7852
+ source,
7853
+ fromFile,
7854
+ filePath: dependency?.filePath ?? null,
7855
+ contentHash: dependency ? hashContent(dependency.content) : null
7856
+ });
7857
+ onTrack();
7553
7858
  const traced = traceModuleResult(babel, source, fromFile);
7554
7859
  if (!traced) return null;
7555
- return createTrackedBindings(traced, dependencies);
7860
+ return createTrackedBindings(traced, dependencies, onTrack, () => traceModuleResult(babel, source, fromFile));
7556
7861
  };
7557
- const bindings = parseAndExtractModule(internal.projectDir, resolved.filePath, resolved.content, babel, resolveDependency, internal.options);
7862
+ const ast = metadata.parse(babel, resolved.filePath, resolved.content);
7863
+ if (!ast) return null;
7864
+ const bindings = extractModuleBindings(internal.projectDir, resolved.filePath, ast, babel, resolveDependency, internal.options);
7558
7865
  if (!bindings) return null;
7559
- const dependencyList = [...dependencies.values()];
7560
- internal.cache.setItem({
7866
+ if (!cyclic.has(resolved.filePath)) internal.cache.setItem({
7561
7867
  filePath: resolved.filePath,
7562
7868
  contentHash,
7563
7869
  cacheType: CACHE_TYPE,
7564
7870
  persistent: false,
7565
7871
  cacheContent: {
7566
- bindings: [...bindings.entries()],
7872
+ bindings,
7567
7873
  dependencies: dependencyList
7568
7874
  }
7569
7875
  });
7570
7876
  return {
7877
+ source,
7878
+ fromFile,
7571
7879
  filePath: resolved.filePath,
7572
7880
  contentHash,
7573
7881
  bindings,
@@ -7582,23 +7890,18 @@ function createTracer(internal) {
7582
7890
  };
7583
7891
  return {
7584
7892
  resolveImport,
7585
- traceModule
7893
+ traceModule,
7894
+ getMetadataCacheStats: metadata.getStats,
7895
+ beginCompilation() {
7896
+ clearResolverCache();
7897
+ cyclic.clear();
7898
+ }
7586
7899
  };
7587
7900
  }
7588
- function parseAndExtractModule(projectDir, filePath, content, babel, resolveImport, options) {
7589
- let ast = null;
7590
- try {
7591
- ast = babel.parseSync(content, {
7592
- ...babelTransformOptions(),
7593
- filename: filePath
7594
- });
7595
- } catch {
7596
- return null;
7597
- }
7598
- if (!ast) return null;
7901
+ function extractModuleBindings(projectDir, filePath, ast, babel, resolveImport, options) {
7599
7902
  const imports = /* @__PURE__ */ new Map();
7600
7903
  const rawBindings = /* @__PURE__ */ new Map();
7601
- const bindings = /* @__PURE__ */ new Map();
7904
+ const bindings = new LazyBindings();
7602
7905
  const styleNames = /* @__PURE__ */ new Set();
7603
7906
  const styleMetas = /* @__PURE__ */ new Map();
7604
7907
  const fileId = getProjectFileId$1(projectDir, filePath);
@@ -7679,9 +7982,9 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
7679
7982
  }
7680
7983
  if (stmt.type === "ExportAllDeclaration") {
7681
7984
  const exported = resolveImport(stmt.source.value, filePath);
7682
- if (exported) exported.forEach((value, key) => {
7683
- if (key !== "default") bindings.set(key, value);
7684
- });
7985
+ if (exported) {
7986
+ for (const key of exported.keys()) if (key !== "default") bindings.setLazy(key, () => exported.get(key));
7987
+ }
7685
7988
  }
7686
7989
  if (stmt.type === "ExportDefaultDeclaration") rawBindings.set("default", stmt.declaration);
7687
7990
  }
@@ -7697,7 +8000,11 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
7697
8000
  bindingNodes: rawBindings
7698
8001
  };
7699
8002
  rawBindings.forEach((node, name) => {
7700
- bindings.set(name, evaluateResolvedNode(node, scope, styleNames, fileId, options));
8003
+ bindings.setLazy(name, () => {
8004
+ const imported = imports.get(name);
8005
+ if (imported && node.type === "Identifier" && node.name === name) return resolveImport(imported.source, filePath)?.get(imported.name) ?? evalFail(`Cannot resolve export: ${name}`);
8006
+ return evaluateResolvedNode(node, scope, styleNames, fileId, options);
8007
+ });
7701
8008
  });
7702
8009
  return bindings;
7703
8010
  }
@@ -7860,47 +8167,52 @@ function createSlotRef(fileId, loc) {
7860
8167
  };
7861
8168
  }
7862
8169
  function hashContent(content) {
7863
- return crypto.createHash("sha256").update(content).digest("hex").slice(0, 16);
8170
+ return crypto.createHash("sha256").update(content).digest("hex");
7864
8171
  }
7865
8172
  function addTraceDependency(dependencies, dependency) {
7866
- dependencies.set(dependency.filePath, dependency);
8173
+ dependencies.set(JSON.stringify([dependency.source, dependency.fromFile]), dependency);
7867
8174
  }
7868
- function createTrackedBindings(traced, dependencies) {
8175
+ function createTrackedBindings(traced, dependencies, onTrack, refresh) {
7869
8176
  const track = () => {
7870
8177
  addTraceDependency(dependencies, traced);
7871
8178
  traced.dependencies.forEach((dependency) => addTraceDependency(dependencies, dependency));
7872
- };
7873
- return new class extends Map {
7874
- constructor() {
7875
- super(traced.bindings);
7876
- }
7877
- get(key) {
7878
- const value = super.get(key);
7879
- if (value !== void 0 || super.has(key)) track();
7880
- return value;
7881
- }
7882
- has(key) {
7883
- const result = super.has(key);
7884
- if (result) track();
7885
- return result;
7886
- }
7887
- forEach(callbackfn, thisArg) {
7888
- track();
7889
- super.forEach(callbackfn, thisArg);
7890
- }
7891
- }();
8179
+ onTrack();
8180
+ };
8181
+ const bindings = new LazyBindings();
8182
+ for (const key of traced.bindings.keys()) bindings.setLazy(key, () => {
8183
+ const current = refresh();
8184
+ if (!current) return evalFail(`Cannot resolve export: ${key}`);
8185
+ traced = current;
8186
+ const value = traced.bindings.get(key) ?? evalFail(`Cannot resolve export: ${key}`);
8187
+ track();
8188
+ return value;
8189
+ });
8190
+ track();
8191
+ return bindings;
7892
8192
  }
7893
8193
  function areDependenciesFresh(dependencies) {
7894
- for (const dependency of dependencies) if (hashFileContent(dependency.filePath) !== dependency.contentHash) return false;
8194
+ for (const dependency of dependencies) {
8195
+ const current = resolveFile(dependency.source, dependency.fromFile);
8196
+ if ((current?.filePath ?? null) !== dependency.filePath || (current ? hashContent(current.content) : null) !== dependency.contentHash) return false;
8197
+ }
7895
8198
  return true;
7896
8199
  }
7897
- function hashFileContent(filePath) {
8200
+ //#endregion
8201
+ //#region compiler/utils/check_diagnostics.ts
8202
+ let observer;
8203
+ /** Extraction is synchronous; restore the previous observer for nested compilations. */
8204
+ function observeCheckDiagnostics(onDiagnostic, run) {
8205
+ const previous = observer;
8206
+ observer = onDiagnostic;
7898
8207
  try {
7899
- return hashContent(fs$1.readFileSync(filePath, "utf8"));
7900
- } catch {
7901
- return null;
8208
+ return run();
8209
+ } finally {
8210
+ observer = previous;
7902
8211
  }
7903
8212
  }
8213
+ function recordCheckDiagnostic(diagnostic) {
8214
+ observer?.(diagnostic);
8215
+ }
7904
8216
  //#endregion
7905
8217
  //#region compiler/utils/imports.ts
7906
8218
  function getStyleRuntimeImportPath(mode) {
@@ -8418,7 +8730,7 @@ function createExtractPlugin(args) {
8418
8730
  this.styleNames = /* @__PURE__ */ new Set();
8419
8731
  this.sheetNames = /* @__PURE__ */ new Set();
8420
8732
  this.styleMetas = /* @__PURE__ */ new Map();
8421
- this.bindings = /* @__PURE__ */ new Map();
8733
+ this.bindings = new LazyBindings();
8422
8734
  this.bindingNodes = /* @__PURE__ */ new Map();
8423
8735
  this.imports = /* @__PURE__ */ new Map();
8424
8736
  this.needsExtractImport = false;
@@ -8473,10 +8785,7 @@ function createExtractPlugin(args) {
8473
8785
  annotateTokenDeclaration(decl, state, t);
8474
8786
  annotateAtRuleDeclaration(decl, state, t);
8475
8787
  const name = decl.id.name;
8476
- const scope = getEvalScope(state);
8477
- const result = evaluateNode(decl.init, scope);
8478
- state.bindings.set(name, result);
8479
- state.bindingNodes.set(name, decl.init);
8788
+ recordLazyBinding(state, name, t.cloneNode(decl.init, true));
8480
8789
  });
8481
8790
  },
8482
8791
  ExportNamedDeclaration(path, state) {
@@ -8487,10 +8796,7 @@ function createExtractPlugin(args) {
8487
8796
  annotateTokenDeclaration(decl, state, t);
8488
8797
  annotateAtRuleDeclaration(decl, state, t);
8489
8798
  const name = decl.id.name;
8490
- const scope = getEvalScope(state);
8491
- const result = evaluateNode(decl.init, scope);
8492
- state.bindings.set(name, result);
8493
- state.bindingNodes.set(name, decl.init);
8799
+ recordLazyBinding(state, name, t.cloneNode(decl.init, true));
8494
8800
  });
8495
8801
  },
8496
8802
  TSEnumDeclaration(path, state) {
@@ -8535,6 +8841,10 @@ function createExtractPlugin(args) {
8535
8841
  }
8536
8842
  if (!result) return;
8537
8843
  checkCompiledImportantUsage(result, options.check?.important, (level, message) => {
8844
+ recordCheckDiagnostic({
8845
+ level,
8846
+ message
8847
+ });
8538
8848
  if (level === "error") throw path.buildCodeFrameError(message);
8539
8849
  console.warn("[fluentic-style] " + message);
8540
8850
  });
@@ -8589,6 +8899,18 @@ function createExtractPlugin(args) {
8589
8899
  };
8590
8900
  });
8591
8901
  }
8902
+ function recordLazyBinding(state, name, initializer) {
8903
+ const bindings = state.bindings.fork();
8904
+ const scope = {
8905
+ ...getEvalScope(state),
8906
+ bindings,
8907
+ bindingNodes: new Map(state.bindingNodes),
8908
+ imports: new Map(state.imports)
8909
+ };
8910
+ bindings.setLazy(name, () => evaluateNode(initializer, scope));
8911
+ state.bindings.setLazy(name, () => bindings.get(name));
8912
+ state.bindingNodes.set(name, initializer);
8913
+ }
8592
8914
  function checkCompiledImportantUsage(result, options, report) {
8593
8915
  if (!options) return;
8594
8916
  let hasRawValue = false;
@@ -8865,15 +9187,254 @@ function createPlugin(rewriteSource) {
8865
9187
  });
8866
9188
  }
8867
9189
  //#endregion
9190
+ //#region compiler/compiler/persistent_cache.ts
9191
+ function createPersistentTransformCache(internal) {
9192
+ const stats = {
9193
+ hits: 0,
9194
+ misses: 0,
9195
+ bypasses: 0,
9196
+ writes: 0
9197
+ };
9198
+ const directory = path.join(internal.cacheDir, "extract-v1");
9199
+ let previousContext = null;
9200
+ const contextFor = () => {
9201
+ if (internal.options.cache?.persistent === false || DEV_CONFIG.isDev) return null;
9202
+ try {
9203
+ const identity = getCompilerCacheIdentity();
9204
+ if (!identity) return null;
9205
+ const options = internal.options;
9206
+ assertDataProperties(options);
9207
+ if (Object.getPrototypeOf(options) !== Object.prototype && Object.getPrototypeOf(options) !== null) throw new Error("Non-plain compiler options");
9208
+ if (options.importSources) assertPlainArray(options.importSources);
9209
+ const importSources = options.importSources?.map((entry) => {
9210
+ assertDataProperties(entry);
9211
+ if (Object.getPrototypeOf(entry) !== Object.prototype && Object.getPrototypeOf(entry) !== null) throw new Error("Non-plain import source");
9212
+ if (entry.styleFn && types.isProxy(entry.styleFn)) throw new Error("Proxy style function");
9213
+ if (!entry.meta && entry.styleFn) {
9214
+ const metadata = Object.getOwnPropertyDescriptor(entry.styleFn, symbol("style.fn:meta"));
9215
+ if (!metadata || !("value" in metadata)) throw new Error("Dynamic style metadata");
9216
+ }
9217
+ return {
9218
+ ...entry,
9219
+ styleFn: void 0,
9220
+ meta: entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null)
9221
+ };
9222
+ });
9223
+ return digest(encode({
9224
+ schema: 1,
9225
+ identity,
9226
+ cwd: process.cwd(),
9227
+ projectDir: internal.projectDir,
9228
+ runtimeMode: internal.runtimeMode,
9229
+ options: {
9230
+ ...options,
9231
+ importSources
9232
+ },
9233
+ globals: {
9234
+ CSS_CONFIG,
9235
+ CSS_EXTRA_CONFIG,
9236
+ DEBUG_CONFIG,
9237
+ DEV_CONFIG,
9238
+ IS_DEV,
9239
+ RUNTIME_CONFIG,
9240
+ CHECK_CONFIG,
9241
+ DEFAULT_CONFIG,
9242
+ PrioritySelectors
9243
+ }
9244
+ }, options.cache?.dynamicConfig !== false));
9245
+ } catch {
9246
+ return null;
9247
+ }
9248
+ };
9249
+ const run = (args, compile) => {
9250
+ const context = contextFor();
9251
+ let key = null;
9252
+ try {
9253
+ if (context) key = digest(encode({
9254
+ context,
9255
+ args
9256
+ }));
9257
+ } catch {}
9258
+ if (!key) {
9259
+ stats.bypasses++;
9260
+ previousContext = null;
9261
+ internal.cache.clear();
9262
+ clearResolverCache();
9263
+ return {
9264
+ result: compile(),
9265
+ hit: false
9266
+ };
9267
+ }
9268
+ const filename = path.join(directory, getCompilerCacheIdentity(), digest(encode(internal.options.cache?.version)), digest(args.filePath) + ".bin");
9269
+ clearResolverCache();
9270
+ let hit;
9271
+ try {
9272
+ const buffer = fs$1.readFileSync(filename);
9273
+ const body = buffer.subarray(65);
9274
+ if (buffer.subarray(0, 64).toString() === digest(body)) {
9275
+ const record = deserialize(body);
9276
+ if (record.key === key && Array.isArray(record.dependencies) && validRecord(record) && record.dependencies.every(isFresh)) hit = record;
9277
+ }
9278
+ } catch {}
9279
+ if (hit) {
9280
+ stats.hits++;
9281
+ for (const diagnostic of hit.diagnostics) if (diagnostic.level === "warn") console.warn("[fluentic-style] " + diagnostic.message);
9282
+ if (hit.error) {
9283
+ const error = new Error(hit.error.message);
9284
+ error.name = hit.error.name;
9285
+ error.stack = hit.error.stack;
9286
+ throw error;
9287
+ }
9288
+ return {
9289
+ result: hit.result,
9290
+ hit: true
9291
+ };
9292
+ }
9293
+ stats.misses++;
9294
+ clearResolverCache();
9295
+ if (context !== previousContext) internal.cache.clear();
9296
+ previousContext = context;
9297
+ const dependencies = /* @__PURE__ */ new Map();
9298
+ const diagnostics = [];
9299
+ let result = null;
9300
+ let failure = null;
9301
+ try {
9302
+ result = observeCheckDiagnostics((diagnostic) => diagnostics.push(diagnostic), () => observeFileResolutions((source, fromFile, resolved) => {
9303
+ dependencies.set(JSON.stringify([source, fromFile]), {
9304
+ source,
9305
+ fromFile,
9306
+ filePath: resolved?.filePath ?? null,
9307
+ hash: resolved ? digest(resolved.content) : null
9308
+ });
9309
+ }, compile));
9310
+ } catch (error) {
9311
+ if (!(error instanceof Error) || diagnostics[diagnostics.length - 1]?.level !== "error") throw error;
9312
+ failure = error;
9313
+ }
9314
+ const cachedError = failure ? {
9315
+ name: failure.name,
9316
+ message: failure.message,
9317
+ stack: failure.stack
9318
+ } : null;
9319
+ if (result || failure) {
9320
+ let temporary;
9321
+ try {
9322
+ encode(result);
9323
+ const records = [...dependencies.values()];
9324
+ clearResolverCache();
9325
+ if (!records.every(isFresh) || contextFor() !== context) throw new Error("Cache snapshot changed");
9326
+ const body = serialize({
9327
+ key,
9328
+ dependencies: records,
9329
+ result,
9330
+ diagnostics,
9331
+ error: cachedError
9332
+ });
9333
+ fs$1.mkdirSync(path.dirname(filename), { recursive: true });
9334
+ temporary = filename + "." + randomUUID() + ".tmp";
9335
+ fs$1.writeFileSync(temporary, Buffer.concat([Buffer.from(digest(body) + "\n"), body]));
9336
+ fs$1.renameSync(temporary, filename);
9337
+ stats.writes++;
9338
+ } catch {} finally {
9339
+ if (temporary) try {
9340
+ fs$1.unlinkSync(temporary);
9341
+ } catch {}
9342
+ }
9343
+ }
9344
+ if (failure) throw failure;
9345
+ return {
9346
+ result,
9347
+ hit: false
9348
+ };
9349
+ };
9350
+ return {
9351
+ run,
9352
+ getStats: () => ({ ...stats })
9353
+ };
9354
+ }
9355
+ function isFresh(dependency) {
9356
+ if (typeof dependency.source !== "string" || typeof dependency.fromFile !== "string") return false;
9357
+ const resolved = resolveFile(dependency.source, dependency.fromFile);
9358
+ return (resolved?.filePath ?? null) === dependency.filePath && (resolved ? digest(resolved.content) : null) === dependency.hash;
9359
+ }
9360
+ function validRecord(record) {
9361
+ if (!Array.isArray(record.diagnostics) || !record.diagnostics.every((item) => item && (item.level === "warn" || item.level === "error") && typeof item.message === "string")) return false;
9362
+ if (record.error) return record.result === null && record.diagnostics[record.diagnostics.length - 1]?.level === "error" && typeof record.error.name === "string" && typeof record.error.message === "string" && (record.error.stack === void 0 || typeof record.error.stack === "string");
9363
+ return record.error === null && record.diagnostics.every((item) => item.level === "warn") && validResult(record.result);
9364
+ }
9365
+ function validResult(result) {
9366
+ return !!result && typeof result.code === "string" && (result.sourcemap === null || typeof result.sourcemap === "string") && Array.isArray(result.rules) && result.rules.every((rule) => typeof rule.css === "string" && typeof rule.dedupe === "string" && typeof rule.className === "string" && Array.isArray(rule.priority));
9367
+ }
9368
+ function digest(value) {
9369
+ return createHash("sha256").update(value).digest("hex");
9370
+ }
9371
+ function assertDataProperties(value) {
9372
+ if (types.isProxy(value)) throw new Error("Proxy configuration");
9373
+ for (const key of Reflect.ownKeys(value)) {
9374
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
9375
+ if (typeof key === "symbol" || !("value" in descriptor) || !descriptor.enumerable && !(Array.isArray(value) && key === "length") && !(value instanceof RegExp && key === "lastIndex")) throw new Error("Dynamic configuration");
9376
+ }
9377
+ }
9378
+ function assertPlainArray(value) {
9379
+ assertDataProperties(value);
9380
+ if (Object.getPrototypeOf(value) !== Array.prototype || Object.keys(value).some((key) => !/^(0|[1-9][0-9]*)$/.test(key))) throw new Error("Non-plain array");
9381
+ }
9382
+ /** Tagged, order-preserving encoding: property order can affect generated CSS. */
9383
+ function encode(value, dynamicConfig = false) {
9384
+ return JSON.stringify(encodeValue(value, /* @__PURE__ */ new Set(), dynamicConfig));
9385
+ }
9386
+ function encodeValue(value, seen = /* @__PURE__ */ new Set(), dynamicConfig = false) {
9387
+ if (typeof value === "function" && dynamicConfig) {
9388
+ if (types.isProxy(value)) throw new Error("Proxy callback");
9389
+ for (const key of Reflect.ownKeys(value)) {
9390
+ if (typeof key !== "string" || ![
9391
+ "length",
9392
+ "name",
9393
+ "prototype",
9394
+ "arguments",
9395
+ "caller"
9396
+ ].includes(key)) throw new Error("Callback with custom properties");
9397
+ if (!("value" in Object.getOwnPropertyDescriptor(value, key))) throw new Error("Callback accessor");
9398
+ }
9399
+ const source = Function.prototype.toString.call(value);
9400
+ if (source.includes("[native code]")) throw new Error("Opaque callback");
9401
+ return ["function", source];
9402
+ }
9403
+ if (value === void 0) return ["undefined"];
9404
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
9405
+ if (typeof value === "number" && Number.isFinite(value)) return ["number", Object.is(value, -0) ? "-0" : value];
9406
+ if (typeof value !== "object" || value === null || seen.has(value)) throw new Error("Unsupported cache input");
9407
+ assertDataProperties(value);
9408
+ if (value instanceof RegExp) {
9409
+ if (value.global || value.sticky || Object.getPrototypeOf(value) !== RegExp.prototype || Object.keys(value).length) throw new Error("Dynamic pattern");
9410
+ return [
9411
+ "regexp",
9412
+ value.source,
9413
+ value.flags
9414
+ ];
9415
+ }
9416
+ if (Array.isArray(value)) assertPlainArray(value);
9417
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new Error("Non-plain cache input");
9418
+ seen.add(value);
9419
+ try {
9420
+ return [Array.isArray(value) ? ["array", value.length] : "object", Object.keys(value).map((key) => [key, encodeValue(value[key], seen, dynamicConfig)])];
9421
+ } finally {
9422
+ seen.delete(value);
9423
+ }
9424
+ }
9425
+ //#endregion
8868
9426
  //#region compiler/compiler/compiler.ts
8869
9427
  function createCompiler(args, options) {
8870
9428
  const internal = createCompilerInternal(args, options);
8871
9429
  const tracer = createTracer(internal);
8872
9430
  const collector = createCssCollector();
9431
+ const persistentCache = createPersistentTransformCache(internal);
8873
9432
  const compileDebug = (args) => {
9433
+ tracer.beginCompilation();
8874
9434
  return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
8875
9435
  };
8876
9436
  const compileDebugRSC = (args) => {
9437
+ tracer.beginCompilation();
8877
9438
  const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
8878
9439
  if (!debugResult) return null;
8879
9440
  const rscCollector = createCssCollector();
@@ -8894,6 +9455,18 @@ function createCompiler(args, options) {
8894
9455
  };
8895
9456
  };
8896
9457
  const compileExtract = (args) => {
9458
+ const startIndex = collector.getItems().length;
9459
+ try {
9460
+ const cached = persistentCache.run(args, () => compileExtractUncached(args));
9461
+ if (cached.hit && cached.result) collector.addMany(cached.result.rules);
9462
+ return cached.result;
9463
+ } catch (error) {
9464
+ collector.getItems().splice(startIndex);
9465
+ throw error;
9466
+ }
9467
+ };
9468
+ const compileExtractUncached = (args) => {
9469
+ tracer.beginCompilation();
8897
9470
  const startIndex = collector.getItems().length;
8898
9471
  const result = transformExtract(internal, args, {
8899
9472
  collector,
@@ -8920,11 +9493,14 @@ function createCompiler(args, options) {
8920
9493
  compileDebugRSC,
8921
9494
  compileExtract,
8922
9495
  getExtractedCss,
8923
- invalidateFile
9496
+ invalidateFile,
9497
+ getPersistentCacheStats: persistentCache.getStats,
9498
+ getTraceMetadataCacheStats: tracer.getMetadataCacheStats
8924
9499
  };
8925
9500
  }
8926
9501
  function createCompilerInternal(args, options) {
8927
- const { projectDir, cacheDir, runtimeMode } = args;
9502
+ const { projectDir, runtimeMode } = args;
9503
+ const cacheDir = options.cache?.location === void 0 ? args.cacheDir : path.resolve(projectDir, options.cache.location);
8928
9504
  return {
8929
9505
  projectDir,
8930
9506
  cacheDir,
@@ -8941,6 +9517,7 @@ function rewriteTransformResult(result, runtimeMode, sourceCode) {
8941
9517
  };
8942
9518
  }
8943
9519
  function rewriteCompilerRuntimeImports(code, runtimeMode, sourceCode) {
9520
+ if (!code.includes("@fluentic/style") && !code.includes("\\")) return code;
8944
9521
  const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
8945
9522
  return rewriteImportSources(code, (source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode));
8946
9523
  }
@@ -9003,4 +9580,4 @@ const CssPropPresets = {
9003
9580
  //#endregion
9004
9581
  export { getDefaultSourcemapUrl as a, getStyleFnMeta as c, babelTransform as d, extractCss as f, createCompilerCache as g, globalData as h, CompilerRuntimeMode as i, isPromiseLike as l, SIDECAR_URL_GLOBAL_SYMBOL as m, createCompiler as n, normalizeSourcemapSourcePath as o, compareLayerPriority as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelPlugin as u };
9005
9582
 
9006
- //# sourceMappingURL=compiler-AOb_VaKQ.mjs.map
9583
+ //# sourceMappingURL=compiler-Dpd41bCS.mjs.map