@tamagui/vite-plugin 3.0.0-beta.924.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,14 +27,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  var loadTamagui_exports = {};
28
28
  __export(loadTamagui_exports, {
29
29
  TAMAGUI_EVALUATION_ENVIRONMENT: () => TAMAGUI_EVALUATION_ENVIRONMENT,
30
- createViteTamaguiLoader: () => createViteTamaguiLoader
30
+ createViteTamaguiLoader: () => createViteTamaguiLoader,
31
+ viteBuildConfigLoader: () => viteBuildConfigLoader
31
32
  });
32
33
  module.exports = __toCommonJS(loadTamagui_exports);
33
34
  var import_static = __toESM(require("@tamagui/static"), 1);
34
35
  var import_node_module = require("node:module");
35
36
  var import_node_path = __toESM(require("node:path"), 1);
37
+ var import_vite = require("vite");
36
38
  const import_meta = {};
37
39
  const TAMAGUI_EVALUATION_ENVIRONMENT = "tamagui";
40
+ const viteBuildConfigLoader = async (absolutePath, root) => {
41
+ const { module: module2, dependencies } = await (0, import_vite.runnerImport)(absolutePath, { root });
42
+ return {
43
+ exports: module2,
44
+ dependencies: [absolutePath, ...dependencies]
45
+ };
46
+ };
38
47
  const requireFromLoader = (0, import_node_module.createRequire)(typeof __filename === "string" ? __filename : import_meta.url);
39
48
  const vitePluginVersions = [`@tamagui/vite-plugin@${requireFromLoader("@tamagui/vite-plugin/package.json").version}`];
40
49
  function createViteTamaguiLoader(optionsIn = {}) {
@@ -43,11 +52,14 @@ function createViteTamaguiLoader(optionsIn = {}) {
43
52
  let loadPromise = null;
44
53
  let loadedOptions = null;
45
54
  let projectPromise = null;
55
+ let loadingProject = null;
56
+ const invalidatedFiles = /* @__PURE__ */ new Set();
46
57
  const evaluationDependencies = /* @__PURE__ */ new Set();
47
58
  const stampSources = /* @__PURE__ */ new Set();
48
59
  let generation = 0;
49
60
  const normalizeDependency = (id) => id.split("?")[0];
50
61
  const captureEvaluationDependencies = (modules) => {
62
+ evaluationDependencies.clear();
51
63
  stampSources.clear();
52
64
  for (const { id } of modules) {
53
65
  const dependency = normalizeDependency(id);
@@ -70,14 +82,18 @@ function createViteTamaguiLoader(optionsIn = {}) {
70
82
  const loadTamaguiBuildConfig = async () => {
71
83
  if (loadedOptions) return loadedOptions;
72
84
  if (loadPromise) return loadPromise;
73
- loadPromise = import_static.default.loadTamaguiBuildConfigAsync({
85
+ const pending = import_static.default.loadTamaguiBuildConfigAsync({
74
86
  ...optionsIn,
75
87
  platform: "web"
76
- }).then((options) => {
88
+ }, viteBuildConfigLoader).then((options) => {
77
89
  loadedOptions = options;
78
90
  return options;
91
+ }, (error) => {
92
+ if (loadPromise === pending) loadPromise = null;
93
+ throw error;
79
94
  });
80
- return loadPromise;
95
+ loadPromise = pending;
96
+ return pending;
81
97
  };
82
98
  const resolveAndImport = async (moduleName, root, kind) => {
83
99
  if (!environment) {
@@ -113,16 +129,34 @@ function createViteTamaguiLoader(optionsIn = {}) {
113
129
  };
114
130
  const loadProject = async (options) => {
115
131
  if (projectPromise) return projectPromise;
132
+ const previous = loadingProject;
133
+ const projectGeneration = generation;
134
+ const changedFiles = [...invalidatedFiles];
135
+ invalidatedFiles.clear();
116
136
  projectPromise = (async () => {
137
+ try {
138
+ await previous;
139
+ } catch {}
117
140
  if (!environment) {
118
141
  throw new Error(`Cannot load Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`);
119
142
  }
143
+ for (const file of changedFiles) {
144
+ const evaluated2 = environment.runner.evaluatedModules;
145
+ const affected = new Set(evaluated2.getModulesByFile(file));
146
+ for (const module2 of affected) {
147
+ for (const importer of module2.importers) {
148
+ const parent = evaluated2.getModuleById(importer);
149
+ if (parent) affected.add(parent);
150
+ }
151
+ evaluated2.invalidateModule(module2);
152
+ }
153
+ }
120
154
  let evaluated = null;
121
155
  return import_static.default.loadCompilerProject({
122
156
  root: environment.config.root,
123
157
  target: "web",
124
158
  options,
125
- generation: `vite:${generation}`,
159
+ generation: `vite:${projectGeneration}`,
126
160
  hostVersions: vitePluginVersions,
127
161
  async load(normalizedOptions) {
128
162
  evaluated = await evaluateProjectModules(normalizedOptions);
@@ -151,7 +185,16 @@ function createViteTamaguiLoader(optionsIn = {}) {
151
185
  }
152
186
  });
153
187
  })();
154
- return projectPromise;
188
+ loadingProject = projectPromise;
189
+ const pending = projectPromise;
190
+ try {
191
+ return await pending;
192
+ } catch (error) {
193
+ if (projectPromise === pending) projectPromise = null;
194
+ throw error;
195
+ } finally {
196
+ if (loadingProject === pending) loadingProject = null;
197
+ }
155
198
  };
156
199
  return {
157
200
  getEnvironment: () => environment,
@@ -190,9 +233,7 @@ function createViteTamaguiLoader(optionsIn = {}) {
190
233
  projectPromise = null;
191
234
  },
192
235
  invalidate(file) {
193
- if (file && environment) {
194
- environment.runner.clearCache();
195
- }
236
+ if (file) invalidatedFiles.add(normalizeDependency(file));
196
237
  generation++;
197
238
  projectPromise = null;
198
239
  },
@@ -205,6 +246,7 @@ function createViteTamaguiLoader(optionsIn = {}) {
205
246
  },
206
247
  async cleanup() {
207
248
  try {
249
+ await loadingProject?.catch(() => {});
208
250
  if (ownsEnvironment && environment) {
209
251
  await environment.close();
210
252
  }
@@ -214,6 +256,10 @@ function createViteTamaguiLoader(optionsIn = {}) {
214
256
  loadPromise = null;
215
257
  loadedOptions = null;
216
258
  projectPromise = null;
259
+ loadingProject = null;
260
+ invalidatedFiles.clear();
261
+ evaluationDependencies.clear();
262
+ stampSources.clear();
217
263
  }
218
264
  }
219
265
  };
@@ -199,6 +199,7 @@ async function createOwnedEvaluationConfig(config, configuredEvaluationPackages)
199
199
  const plugins = environment.plugins.filter(isEvaluationUserPlugin).map((plugin) => createEvaluationPluginFacade(plugin));
200
200
  const resolve2 = getEvaluationResolve(environment.resolve, config.root, plugins.some((plugin) => plugin.name === oneTsconfigPathsPluginName), configuredEvaluationPackages);
201
201
  const { createEnvironment: _createEnvironment, ...dev } = environment.dev;
202
+ const { esbuildOptions: _esbuildOptions, ...optimizeDeps } = environment.optimizeDeps;
202
203
  return (0, import_vite.resolveConfig)({
203
204
  configFile: false,
204
205
  root: config.root,
@@ -212,7 +213,7 @@ async function createOwnedEvaluationConfig(config, configuredEvaluationPackages)
212
213
  keepProcessEnv: environment.keepProcessEnv,
213
214
  define: environment.define,
214
215
  resolve: resolve2,
215
- optimizeDeps: environment.optimizeDeps,
216
+ optimizeDeps,
216
217
  dev: {
217
218
  ...dev,
218
219
  moduleRunnerTransform: true
@@ -253,12 +254,34 @@ function addIfInstalled(userConf, projectRoot, ids) {
253
254
  userConf.optimizeDeps.include ||= [];
254
255
  for (const id of ids) if (!userConf.optimizeDeps.include.includes(id) && isInstalled(root, id)) userConf.optimizeDeps.include.push(id);
255
256
  }
257
+ function svgWebEntry() {
258
+ return normalizePath(import_node_path.default.join(import_node_path.default.dirname(resolve("@tamagui/react-native-svg/package.json")), "dist/esm/index.mjs"));
259
+ }
260
+ function resolveSvgWeb(source) {
261
+ if (source === "react-native-svg" || source === "@tamagui/react-native-svg") return svgWebEntry();
262
+ }
263
+ const svgOptimizerPlugin = {
264
+ name: "tamagui-svg-optimizer",
265
+ enforce: "pre",
266
+ resolveId: {
267
+ filter: { id: /^(?:react-native-svg|@tamagui\/react-native-svg)$/ },
268
+ handler(source) {
269
+ return resolveSvgWeb(source);
270
+ }
271
+ }
272
+ };
256
273
  function tamaguiAliases(options = {}) {
257
274
  const aliases = [];
258
- if (options.svg) aliases.push({
259
- find: "react-native-svg",
260
- replacement: resolve("@tamagui/react-native-svg")
261
- });
275
+ if (options.svg) {
276
+ const svg = svgWebEntry();
277
+ aliases.push({
278
+ find: "react-native-svg",
279
+ replacement: svg
280
+ }, {
281
+ find: "@tamagui/react-native-svg",
282
+ replacement: svg
283
+ });
284
+ }
262
285
  if (options.rnwLite) {
263
286
  const rnwlBase = import_node_path.default.dirname(resolve("@tamagui/react-native-web-lite/package.json"));
264
287
  const rnwl = normalizePath(import_node_path.default.join(rnwlBase, options.rnwLite === "without-animated" ? "dist/esm/without-animated.mjs" : "dist/esm/index.mjs"));
@@ -301,7 +324,7 @@ function createTamaguiNativePlugin(tamaguiOptionsIn, nativeContext) {
301
324
  root,
302
325
  platform: "native",
303
326
  outputCSS: void 0
304
- });
327
+ }, import_loadTamagui.viteBuildConfigLoader);
305
328
  const options = {
306
329
  ...loadedOptions,
307
330
  root,
@@ -499,12 +522,14 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
499
522
  dev: {
500
523
  createEnvironment(name, resolved) {
501
524
  const evaluationConfig = createServeEvaluationConfig(resolved, configuredEvaluationPackages);
502
- return (0, import_vite.createRunnableDevEnvironment)(name, evaluationConfig);
525
+ const environment = (0, import_vite.createRunnableDevEnvironment)(name, evaluationConfig, { hot: false });
526
+ tamaguiLoader.setEnvironment(environment);
527
+ return environment;
503
528
  },
504
529
  moduleRunnerTransform: true
505
530
  }
506
531
  });
507
- tamaguiLoader.loadTamaguiBuildConfig();
532
+ tamaguiLoader.loadTamaguiBuildConfig().catch(() => {});
508
533
  const ensureLoaded = async () => {
509
534
  const promise = tamaguiLoader.getLoadPromise();
510
535
  if (promise) await promise;
@@ -517,6 +542,7 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
517
542
  const transformedModuleIds = /* @__PURE__ */ new Set();
518
543
  const compilerHotUpdateSignatures = /* @__PURE__ */ new Map();
519
544
  const compilerHotReloadSignatures = /* @__PURE__ */ new Map();
545
+ let watchedDependencies = /* @__PURE__ */ new Set();
520
546
  let config;
521
547
  let server;
522
548
  let zero = null;
@@ -540,6 +566,7 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
540
566
  function isNotClient(environment) {
541
567
  return environment?.name && environment.name !== "client";
542
568
  }
569
+ const isDevEnvironment = (environment) => environment.mode === "dev";
543
570
  function isNative(environment) {
544
571
  return environment?.name && (environment.name === "ios" || environment.name === "android");
545
572
  }
@@ -562,11 +589,13 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
562
589
  {
563
590
  name: "tamagui",
564
591
  enforce: "pre",
592
+ resolveId(source) {
593
+ if (disableResolveConfig || tamaguiOptionsIn.platform === "native" || isNative(this.environment)) return;
594
+ return resolveSvgWeb(source);
595
+ },
565
596
  configureServer(_server) {
566
597
  server = _server;
567
- const evaluationEnvironment = server.environments[import_loadTamagui.TAMAGUI_EVALUATION_ENVIRONMENT];
568
- if (!(0, import_vite.isRunnableDevEnvironment)(evaluationEnvironment)) throw new Error(`The ${import_loadTamagui.TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment must support ModuleRunner evaluation`);
569
- tamaguiLoader.setEnvironment(evaluationEnvironment);
598
+ watchedDependencies = /* @__PURE__ */ new Set();
570
599
  },
571
600
  async buildEnd() {
572
601
  await releaseBuildEnvironment(this.environment);
@@ -595,7 +624,7 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
595
624
  [import_loadTamagui.TAMAGUI_EVALUATION_ENVIRONMENT]: getEvaluationEnvironmentOptions(resolvedRoot, userConfig.environments?.[import_loadTamagui.TAMAGUI_EVALUATION_ENVIRONMENT]?.resolve?.noExternal)
596
625
  },
597
626
  define: {
598
- "process.env.TAMAGUI_RUNTIME": JSON.stringify("full"),
627
+ "process.env.TAMAGUI_RUNTIME": JSON.stringify(zeroIslandBuild ? "island" : "full"),
599
628
  _frameTimestamp: void 0,
600
629
  _WORKLET: false,
601
630
  __DEV__: `${env.mode === "development"}`,
@@ -610,7 +639,6 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
610
639
  alias: { ...options.platform !== "native" && {
611
640
  "react-native/Libraries/Renderer/shims/ReactFabric": resolve("@tamagui/proxy-worm"),
612
641
  "react-native/Libraries/Utilities/codegenNativeComponent": resolve("@tamagui/proxy-worm"),
613
- "react-native-svg": resolve("@tamagui/react-native-svg"),
614
642
  ...!useReactNativeWebLite && { "react-native": resolve("react-native-web") }
615
643
  } }
616
644
  }
@@ -649,6 +677,11 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
649
677
  await ensureLoaded();
650
678
  userConf.optimizeDeps ||= {};
651
679
  userConf.optimizeDeps.include ||= [];
680
+ if (!disableResolveConfig && tamaguiOptionsIn.platform !== "native") {
681
+ userConf.optimizeDeps.rolldownOptions ||= {};
682
+ const existingPlugins = userConf.optimizeDeps.rolldownOptions.plugins;
683
+ userConf.optimizeDeps.rolldownOptions.plugins = [svgOptimizerPlugin, ...Array.isArray(existingPlugins) ? existingPlugins : existingPlugins ? [existingPlugins] : []];
684
+ }
652
685
  userConf.optimizeDeps.include.push("inline-style-prefixer");
653
686
  addIfInstalled(userConf, userConf.root, ["@react-native/normalize-color"]);
654
687
  addIfInstalled(userConf, userConf.root, [
@@ -682,7 +715,13 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
682
715
  },
683
716
  async buildStart() {
684
717
  const buildConfig = this.environment.getTopLevelConfig();
685
- if (buildConfig.command !== "build") return;
718
+ if (buildConfig.command !== "build") {
719
+ if (this.environment.name === "client") {
720
+ const dependencies = await tamaguiLoader.ensureFullConfigLoaded();
721
+ for (const dependency of dependencies) this.addWatchFile(dependency);
722
+ }
723
+ return;
724
+ }
686
725
  const pendingCleanup = buildCleanupPromise;
687
726
  if (pendingCleanup) await pendingCleanup;
688
727
  const buildEnvironment = this.environment;
@@ -714,13 +753,18 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
714
753
  if (!tamaguiLoader.isEvaluationDependency(options.file)) {
715
754
  if (this.environment.name !== "client") return;
716
755
  const compilerFrontend = getCompilerFrontend(this.environment);
717
- const source = options.type === "delete" ? null : await options.read();
756
+ let source = null;
757
+ if (options.type !== "delete") try {
758
+ source = await options.read();
759
+ } catch (error) {
760
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
761
+ }
718
762
  const affectedModules = /* @__PURE__ */ new Set();
719
763
  const compilerHmrRoots = new Set(compilerFrontend.dependentsOf(options.file));
720
764
  if (compilerHmrRoots.size || compilerFrontend.has(options.file)) compilerHmrRoots.add(options.file);
721
765
  if (compilerFrontend.has(options.file) || compilerHmrRoots.size > 0) {
722
766
  if (!(await ensureLoaded())?.disable) {
723
- const invalidatedIds = options.type === "delete" ? (await compilerFrontend.remove(options.file)).invalidatedIds : await compilerFrontend.update({
767
+ const invalidatedIds = source === null ? (await compilerFrontend.remove(options.file)).invalidatedIds : await compilerFrontend.update({
724
768
  id: options.file,
725
769
  source,
726
770
  root: config.root,
@@ -754,7 +798,10 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
754
798
  }
755
799
  const cssId = getAbsoluteVirtualFileId(`${invalidatedId}${virtualExt}`);
756
800
  const cssModule = this.environment.moduleGraph.getModuleById(cssId);
757
- if (cssModule) this.environment.moduleGraph.invalidateModule(cssModule);
801
+ if (cssModule) {
802
+ this.environment.moduleGraph.invalidateModule(cssModule);
803
+ affectedModules.add(cssModule);
804
+ }
758
805
  }
759
806
  }
760
807
  }
@@ -773,6 +820,11 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
773
820
  tamaguiLoader.invalidate(options.file);
774
821
  invalidateCompilerModules();
775
822
  }
823
+ const unwatched = (await tamaguiLoader.ensureFullConfigLoaded()).filter((file) => !watchedDependencies.has(file));
824
+ if (unwatched.length) {
825
+ for (const file of unwatched) watchedDependencies.add(file);
826
+ server.watcher.add(unwatched);
827
+ }
776
828
  if (this.environment.name === "client" && compilerHotReloadSignatures.get(options.file) !== signature) {
777
829
  compilerHotReloadSignatures.set(options.file, signature);
778
830
  this.environment.hot.send({
@@ -806,6 +858,11 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
806
858
  if (isNotClient(this.environment)) return;
807
859
  if (!shouldExtract) return;
808
860
  const [validId] = id.split("?");
861
+ if (!validId.endsWith(virtualExt)) return;
862
+ if (isDevEnvironment(this.environment)) {
863
+ const importer = this.environment.moduleGraph.getModuleById(validId.slice(0, -virtualExt.length));
864
+ if (importer && importer.transformResult == null) await this.environment.transformRequest(importer.url);
865
+ }
809
866
  return cssMap.get(validId);
810
867
  }
811
868
  },
@@ -902,7 +959,7 @@ function createTamaguiPlugins({ disableResolveConfig, wrapExtractedCSS = (css) =
902
959
  }
903
960
  if (zero.isEnforcing) {
904
961
  import_static.default.mergeIslandBridges(zero.bridges, zeroResult.bridges);
905
- const moduleCSS = [wrapExtractedCSS(result.plan.css), ...[...zeroResult.bridgeCSS.values()]].filter(Boolean).join("\n");
962
+ const moduleCSS = [wrapExtractedCSS(result.plan.css), ...zeroResult.bridgeCSS.values()].filter(Boolean).join("\n");
906
963
  if (config.command !== "build") {
907
964
  let cssImport2 = "";
908
965
  if (moduleCSS) {
@@ -85,7 +85,6 @@ async function buildIsland(input) {
85
85
  mode: "production",
86
86
  logLevel: "warn",
87
87
  define: {
88
- "process.env.TAMAGUI_RUNTIME": JSON.stringify("full"),
89
88
  "process.env.TAMAGUI_DID_OUTPUT_CSS": JSON.stringify("1"),
90
89
  "process.env.NODE_ENV": JSON.stringify("production")
91
90
  },
@@ -1,8 +1,16 @@
1
1
  import Static from "@tamagui/static";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
+ import { runnerImport } from "vite";
4
5
 
5
6
  const TAMAGUI_EVALUATION_ENVIRONMENT = "tamagui";
7
+ const viteBuildConfigLoader = async (absolutePath, root) => {
8
+ const { module, dependencies } = await runnerImport(absolutePath, { root });
9
+ return {
10
+ exports: module,
11
+ dependencies: [absolutePath, ...dependencies]
12
+ };
13
+ };
6
14
  const requireFromLoader = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
7
15
  const vitePluginVersions = [`@tamagui/vite-plugin@${requireFromLoader("@tamagui/vite-plugin/package.json").version}`];
8
16
  function createViteTamaguiLoader(optionsIn = {}) {
@@ -11,11 +19,14 @@ function createViteTamaguiLoader(optionsIn = {}) {
11
19
  let loadPromise = null;
12
20
  let loadedOptions = null;
13
21
  let projectPromise = null;
22
+ let loadingProject = null;
23
+ const invalidatedFiles = /* @__PURE__ */ new Set();
14
24
  const evaluationDependencies = /* @__PURE__ */ new Set();
15
25
  const stampSources = /* @__PURE__ */ new Set();
16
26
  let generation = 0;
17
27
  const normalizeDependency = (id) => id.split("?")[0];
18
28
  const captureEvaluationDependencies = (modules) => {
29
+ evaluationDependencies.clear();
19
30
  stampSources.clear();
20
31
  for (const { id } of modules) {
21
32
  const dependency = normalizeDependency(id);
@@ -38,14 +49,18 @@ function createViteTamaguiLoader(optionsIn = {}) {
38
49
  const loadTamaguiBuildConfig = async () => {
39
50
  if (loadedOptions) return loadedOptions;
40
51
  if (loadPromise) return loadPromise;
41
- loadPromise = Static.loadTamaguiBuildConfigAsync({
52
+ const pending = Static.loadTamaguiBuildConfigAsync({
42
53
  ...optionsIn,
43
54
  platform: "web"
44
- }).then((options) => {
55
+ }, viteBuildConfigLoader).then((options) => {
45
56
  loadedOptions = options;
46
57
  return options;
58
+ }, (error) => {
59
+ if (loadPromise === pending) loadPromise = null;
60
+ throw error;
47
61
  });
48
- return loadPromise;
62
+ loadPromise = pending;
63
+ return pending;
49
64
  };
50
65
  const resolveAndImport = async (moduleName, root, kind) => {
51
66
  if (!environment) {
@@ -81,16 +96,34 @@ function createViteTamaguiLoader(optionsIn = {}) {
81
96
  };
82
97
  const loadProject = async (options) => {
83
98
  if (projectPromise) return projectPromise;
99
+ const previous = loadingProject;
100
+ const projectGeneration = generation;
101
+ const changedFiles = [...invalidatedFiles];
102
+ invalidatedFiles.clear();
84
103
  projectPromise = (async () => {
104
+ try {
105
+ await previous;
106
+ } catch {}
85
107
  if (!environment) {
86
108
  throw new Error(`Cannot load Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`);
87
109
  }
110
+ for (const file of changedFiles) {
111
+ const evaluated2 = environment.runner.evaluatedModules;
112
+ const affected = new Set(evaluated2.getModulesByFile(file));
113
+ for (const module of affected) {
114
+ for (const importer of module.importers) {
115
+ const parent = evaluated2.getModuleById(importer);
116
+ if (parent) affected.add(parent);
117
+ }
118
+ evaluated2.invalidateModule(module);
119
+ }
120
+ }
88
121
  let evaluated = null;
89
122
  return Static.loadCompilerProject({
90
123
  root: environment.config.root,
91
124
  target: "web",
92
125
  options,
93
- generation: `vite:${generation}`,
126
+ generation: `vite:${projectGeneration}`,
94
127
  hostVersions: vitePluginVersions,
95
128
  async load(normalizedOptions) {
96
129
  evaluated = await evaluateProjectModules(normalizedOptions);
@@ -119,7 +152,16 @@ function createViteTamaguiLoader(optionsIn = {}) {
119
152
  }
120
153
  });
121
154
  })();
122
- return projectPromise;
155
+ loadingProject = projectPromise;
156
+ const pending = projectPromise;
157
+ try {
158
+ return await pending;
159
+ } catch (error) {
160
+ if (projectPromise === pending) projectPromise = null;
161
+ throw error;
162
+ } finally {
163
+ if (loadingProject === pending) loadingProject = null;
164
+ }
123
165
  };
124
166
  return {
125
167
  getEnvironment: () => environment,
@@ -158,9 +200,7 @@ function createViteTamaguiLoader(optionsIn = {}) {
158
200
  projectPromise = null;
159
201
  },
160
202
  invalidate(file) {
161
- if (file && environment) {
162
- environment.runner.clearCache();
163
- }
203
+ if (file) invalidatedFiles.add(normalizeDependency(file));
164
204
  generation++;
165
205
  projectPromise = null;
166
206
  },
@@ -173,6 +213,7 @@ function createViteTamaguiLoader(optionsIn = {}) {
173
213
  },
174
214
  async cleanup() {
175
215
  try {
216
+ await loadingProject?.catch(() => {});
176
217
  if (ownsEnvironment && environment) {
177
218
  await environment.close();
178
219
  }
@@ -182,10 +223,14 @@ function createViteTamaguiLoader(optionsIn = {}) {
182
223
  loadPromise = null;
183
224
  loadedOptions = null;
184
225
  projectPromise = null;
226
+ loadingProject = null;
227
+ invalidatedFiles.clear();
228
+ evaluationDependencies.clear();
229
+ stampSources.clear();
185
230
  }
186
231
  }
187
232
  };
188
233
  }
189
234
 
190
- export { TAMAGUI_EVALUATION_ENVIRONMENT, createViteTamaguiLoader };
235
+ export { TAMAGUI_EVALUATION_ENVIRONMENT, createViteTamaguiLoader, viteBuildConfigLoader };
191
236
  //# sourceMappingURL=loadTamagui.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadTamagui.js","names":[],"sources":["esm/loadTamagui.js"],"sourcesContent":["import Static from \"@tamagui/static\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nconst TAMAGUI_EVALUATION_ENVIRONMENT = \"tamagui\";\nconst requireFromLoader = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst vitePluginVersions = [\n `@tamagui/vite-plugin@${requireFromLoader(\"@tamagui/vite-plugin/package.json\").version}`\n];\nfunction createViteTamaguiLoader(optionsIn = {}) {\n let environment = null;\n let ownsEnvironment = false;\n let loadPromise = null;\n let loadedOptions = null;\n let projectPromise = null;\n const evaluationDependencies = /* @__PURE__ */ new Set();\n const stampSources = /* @__PURE__ */ new Set();\n let generation = 0;\n const normalizeDependency = (id) => id.split(\"?\")[0];\n const captureEvaluationDependencies = (modules) => {\n stampSources.clear();\n for (const { id } of modules) {\n const dependency = normalizeDependency(id);\n if (path.isAbsolute(dependency)) {\n evaluationDependencies.add(dependency);\n stampSources.add(dependency);\n }\n }\n if (environment) {\n for (const module of environment.runner.evaluatedModules.urlToIdModuleMap.values()) {\n const dependency = normalizeDependency(module.file);\n if (!path.isAbsolute(dependency)) continue;\n stampSources.add(dependency);\n if (!dependency.includes(\"/node_modules/\")) {\n evaluationDependencies.add(dependency);\n }\n }\n }\n };\n const loadTamaguiBuildConfig = async () => {\n if (loadedOptions) return loadedOptions;\n if (loadPromise) return loadPromise;\n loadPromise = Static.loadTamaguiBuildConfigAsync({\n ...optionsIn,\n platform: \"web\"\n }).then((options) => {\n loadedOptions = options;\n return options;\n });\n return loadPromise;\n };\n const resolveAndImport = async (moduleName, root, kind) => {\n if (!environment) {\n throw new Error(\n `The Tamagui Vite evaluation environment is not ready. Config and component evaluation requires Vite's ModuleRunner.`\n );\n }\n const source = path.isAbsolute(moduleName) ? moduleName : kind === \"config\" || moduleName.startsWith(\".\") ? path.resolve(root, moduleName) : moduleName;\n let environmentResolution = await environment.pluginContainer.resolveId(source);\n if (!environmentResolution && kind === \"config\" && source !== moduleName) {\n environmentResolution = await environment.pluginContainer.resolveId(moduleName);\n }\n const resolvedId = environmentResolution?.id;\n if (!resolvedId) {\n throw new Error(\n `Unable to resolve ${moduleName} in the Tamagui Vite environment (plugins: ${environment.plugins.map((plugin) => plugin.name).join(\", \")})`\n );\n }\n return {\n moduleName,\n id: resolvedId,\n module: await environment.runner.import(resolvedId)\n };\n };\n const evaluateProjectModules = async (options) => {\n if (!environment) {\n throw new Error(\n `Cannot evaluate Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`\n );\n }\n const root = environment.config.root;\n const config = await resolveAndImport(\n options.config || \"tamagui.config.ts\",\n root,\n \"config\"\n );\n const components = await Promise.all(\n (options.components || []).map((name) => resolveAndImport(name, root, \"component\"))\n );\n captureEvaluationDependencies([config, ...components]);\n return { config, components };\n };\n const loadProject = async (options) => {\n if (projectPromise) return projectPromise;\n projectPromise = (async () => {\n if (!environment) {\n throw new Error(\n `Cannot load Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`\n );\n }\n let evaluated = null;\n return Static.loadCompilerProject({\n root: environment.config.root,\n target: \"web\",\n options,\n generation: `vite:${generation}`,\n hostVersions: vitePluginVersions,\n async load(normalizedOptions) {\n evaluated = await evaluateProjectModules(normalizedOptions);\n return Static.loadTamaguiFromModules(normalizedOptions, {\n config: evaluated.config.module,\n components: evaluated.components.map(({ moduleName, module }) => ({\n moduleName,\n module\n })),\n stampSources: [...stampSources]\n });\n },\n async resolveComponents(moduleNames) {\n if (!evaluated) {\n throw new Error(\"The Tamagui compiler project modules were not evaluated\");\n }\n const byName = new Map(\n evaluated.components.map(({ moduleName, id }) => [moduleName, id])\n );\n return moduleNames.map((moduleName) => {\n const id = byName.get(moduleName);\n if (!id) throw new Error(`Unable to resolve compiler component ${moduleName}`);\n return { moduleName, id };\n });\n }\n });\n })();\n return projectPromise;\n };\n return {\n getEnvironment: () => environment,\n getGeneration: () => generation,\n getLoadPromise: () => loadPromise,\n getTamaguiOptions: () => loadedOptions,\n async getTamaguiConfig() {\n const options = await loadTamaguiBuildConfig();\n if (options.disable) return null;\n return (await loadProject(options)).projectInfo.tamaguiConfig;\n },\n async getCompilerProject() {\n const options = await loadTamaguiBuildConfig();\n return loadProject(options);\n },\n getEvaluationDependencies: () => [...evaluationDependencies],\n isEvaluationDependency: (id) => evaluationDependencies.has(normalizeDependency(id)),\n evaluateProjectModules,\n async evaluateModule(id) {\n if (!environment) return null;\n try {\n return await environment.runner.import(id);\n } catch (error) {\n if (process.env.DEBUG === \"tamagui\") {\n console.info(`[tamagui] component discovery skipped ${id}:`, error);\n }\n return null;\n }\n },\n loadTamaguiBuildConfig,\n setEnvironment(next, options) {\n if (environment === next) return;\n environment = next;\n ownsEnvironment = options?.owned === true;\n generation++;\n projectPromise = null;\n },\n invalidate(file) {\n if (file && environment) {\n environment.runner.clearCache();\n }\n generation++;\n projectPromise = null;\n },\n async ensureFullConfigLoaded() {\n const options = await loadTamaguiBuildConfig();\n if (!options.disable) {\n await loadProject(options);\n }\n return [...evaluationDependencies];\n },\n async cleanup() {\n try {\n if (ownsEnvironment && environment) {\n await environment.close();\n }\n } finally {\n environment = null;\n ownsEnvironment = false;\n loadPromise = null;\n loadedOptions = null;\n projectPromise = null;\n }\n }\n };\n}\nexport {\n TAMAGUI_EVALUATION_ENVIRONMENT,\n createViteTamaguiLoader\n};\n//# sourceMappingURL=loadTamagui.js.map\n"],"mappings":";;;;;AAGA,MAAM,iCAAiC;AACvC,MAAM,oBAAoB,cACxB,OAAO,eAAe,WAAW,aAAa,YAAY,GAC5D;AACA,MAAM,qBAAqB,CACzB,wBAAwB,kBAAkB,mCAAmC,CAAC,CAAC,SACjF;AACA,SAAS,w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YAAY,OAAO,WAAW;GAChC;GACA;GACA,iBAAiB;EACnB;EACA,MAAM,yBAAyB;GAC7B,MAAM,UAAU,MAAM,uBAAuB;GAC7C,IAAI,CAAC,QAAQ,SAAS;IACpB,MAAM,YAAY,OAAO;GAC3B;GACA,OAAO,CAAC,GAAG,sBAAsB;EACnC;EACA,MAAM,UAAU;GACd,IAAI;IACF,IAAI,mBAAmB,aAAa;KAClC,MAAM,YAAY,MAAM;IAC1B;GACF,UAAU;IACR,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;GACnB;EACF;CACF;AACF"}
1
+ {"version":3,"file":"loadTamagui.js","names":[],"sources":["esm/loadTamagui.js"],"sourcesContent":["import Static from \"@tamagui/static\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { runnerImport } from \"vite\";\nconst TAMAGUI_EVALUATION_ENVIRONMENT = \"tamagui\";\nconst viteBuildConfigLoader = async (absolutePath, root) => {\n const { module, dependencies } = await runnerImport(\n absolutePath,\n { root }\n );\n return { exports: module, dependencies: [absolutePath, ...dependencies] };\n};\nconst requireFromLoader = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst vitePluginVersions = [\n `@tamagui/vite-plugin@${requireFromLoader(\"@tamagui/vite-plugin/package.json\").version}`\n];\nfunction createViteTamaguiLoader(optionsIn = {}) {\n let environment = null;\n let ownsEnvironment = false;\n let loadPromise = null;\n let loadedOptions = null;\n let projectPromise = null;\n let loadingProject = null;\n const invalidatedFiles = /* @__PURE__ */ new Set();\n const evaluationDependencies = /* @__PURE__ */ new Set();\n const stampSources = /* @__PURE__ */ new Set();\n let generation = 0;\n const normalizeDependency = (id) => id.split(\"?\")[0];\n const captureEvaluationDependencies = (modules) => {\n evaluationDependencies.clear();\n stampSources.clear();\n for (const { id } of modules) {\n const dependency = normalizeDependency(id);\n if (path.isAbsolute(dependency)) {\n evaluationDependencies.add(dependency);\n stampSources.add(dependency);\n }\n }\n if (environment) {\n for (const module of environment.runner.evaluatedModules.urlToIdModuleMap.values()) {\n const dependency = normalizeDependency(module.file);\n if (!path.isAbsolute(dependency)) continue;\n stampSources.add(dependency);\n if (!dependency.includes(\"/node_modules/\")) {\n evaluationDependencies.add(dependency);\n }\n }\n }\n };\n const loadTamaguiBuildConfig = async () => {\n if (loadedOptions) return loadedOptions;\n if (loadPromise) return loadPromise;\n const pending = Static.loadTamaguiBuildConfigAsync(\n { ...optionsIn, platform: \"web\" },\n viteBuildConfigLoader\n ).then(\n (options) => {\n loadedOptions = options;\n return options;\n },\n (error) => {\n if (loadPromise === pending) loadPromise = null;\n throw error;\n }\n );\n loadPromise = pending;\n return pending;\n };\n const resolveAndImport = async (moduleName, root, kind) => {\n if (!environment) {\n throw new Error(\n `The Tamagui Vite evaluation environment is not ready. Config and component evaluation requires Vite's ModuleRunner.`\n );\n }\n const source = path.isAbsolute(moduleName) ? moduleName : kind === \"config\" || moduleName.startsWith(\".\") ? path.resolve(root, moduleName) : moduleName;\n let environmentResolution = await environment.pluginContainer.resolveId(source);\n if (!environmentResolution && kind === \"config\" && source !== moduleName) {\n environmentResolution = await environment.pluginContainer.resolveId(moduleName);\n }\n const resolvedId = environmentResolution?.id;\n if (!resolvedId) {\n throw new Error(\n `Unable to resolve ${moduleName} in the Tamagui Vite environment (plugins: ${environment.plugins.map((plugin) => plugin.name).join(\", \")})`\n );\n }\n return {\n moduleName,\n id: resolvedId,\n module: await environment.runner.import(resolvedId)\n };\n };\n const evaluateProjectModules = async (options) => {\n if (!environment) {\n throw new Error(\n `Cannot evaluate Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`\n );\n }\n const root = environment.config.root;\n const config = await resolveAndImport(\n options.config || \"tamagui.config.ts\",\n root,\n \"config\"\n );\n const components = await Promise.all(\n (options.components || []).map((name) => resolveAndImport(name, root, \"component\"))\n );\n captureEvaluationDependencies([config, ...components]);\n return { config, components };\n };\n const loadProject = async (options) => {\n if (projectPromise) return projectPromise;\n const previous = loadingProject;\n const projectGeneration = generation;\n const changedFiles = [...invalidatedFiles];\n invalidatedFiles.clear();\n projectPromise = (async () => {\n try {\n await previous;\n } catch {\n }\n if (!environment) {\n throw new Error(\n `Cannot load Tamagui without the ${TAMAGUI_EVALUATION_ENVIRONMENT} Vite environment`\n );\n }\n for (const file of changedFiles) {\n const evaluated2 = environment.runner.evaluatedModules;\n const affected = new Set(evaluated2.getModulesByFile(file));\n for (const module of affected) {\n for (const importer of module.importers) {\n const parent = evaluated2.getModuleById(importer);\n if (parent) affected.add(parent);\n }\n evaluated2.invalidateModule(module);\n }\n }\n let evaluated = null;\n return Static.loadCompilerProject({\n root: environment.config.root,\n target: \"web\",\n options,\n generation: `vite:${projectGeneration}`,\n hostVersions: vitePluginVersions,\n async load(normalizedOptions) {\n evaluated = await evaluateProjectModules(normalizedOptions);\n return Static.loadTamaguiFromModules(normalizedOptions, {\n config: evaluated.config.module,\n components: evaluated.components.map(({ moduleName, module }) => ({\n moduleName,\n module\n })),\n stampSources: [...stampSources]\n });\n },\n async resolveComponents(moduleNames) {\n if (!evaluated) {\n throw new Error(\"The Tamagui compiler project modules were not evaluated\");\n }\n const byName = new Map(\n evaluated.components.map(({ moduleName, id }) => [moduleName, id])\n );\n return moduleNames.map((moduleName) => {\n const id = byName.get(moduleName);\n if (!id) throw new Error(`Unable to resolve compiler component ${moduleName}`);\n return { moduleName, id };\n });\n }\n });\n })();\n loadingProject = projectPromise;\n const pending = projectPromise;\n try {\n return await pending;\n } catch (error) {\n if (projectPromise === pending) projectPromise = null;\n throw error;\n } finally {\n if (loadingProject === pending) loadingProject = null;\n }\n };\n return {\n getEnvironment: () => environment,\n getGeneration: () => generation,\n getLoadPromise: () => loadPromise,\n getTamaguiOptions: () => loadedOptions,\n async getTamaguiConfig() {\n const options = await loadTamaguiBuildConfig();\n if (options.disable) return null;\n return (await loadProject(options)).projectInfo.tamaguiConfig;\n },\n async getCompilerProject() {\n const options = await loadTamaguiBuildConfig();\n return loadProject(options);\n },\n getEvaluationDependencies: () => [...evaluationDependencies],\n isEvaluationDependency: (id) => evaluationDependencies.has(normalizeDependency(id)),\n evaluateProjectModules,\n async evaluateModule(id) {\n if (!environment) return null;\n try {\n return await environment.runner.import(id);\n } catch (error) {\n if (process.env.DEBUG === \"tamagui\") {\n console.info(`[tamagui] component discovery skipped ${id}:`, error);\n }\n return null;\n }\n },\n loadTamaguiBuildConfig,\n setEnvironment(next, options) {\n if (environment === next) return;\n environment = next;\n ownsEnvironment = options?.owned === true;\n generation++;\n projectPromise = null;\n },\n invalidate(file) {\n if (file) invalidatedFiles.add(normalizeDependency(file));\n generation++;\n projectPromise = null;\n },\n async ensureFullConfigLoaded() {\n const options = await loadTamaguiBuildConfig();\n if (!options.disable) {\n await loadProject(options);\n }\n return [...evaluationDependencies];\n },\n async cleanup() {\n try {\n await loadingProject?.catch(() => {\n });\n if (ownsEnvironment && environment) {\n await environment.close();\n }\n } finally {\n environment = null;\n ownsEnvironment = false;\n loadPromise = null;\n loadedOptions = null;\n projectPromise = null;\n loadingProject = null;\n invalidatedFiles.clear();\n evaluationDependencies.clear();\n stampSources.clear();\n }\n }\n };\n}\nexport {\n TAMAGUI_EVALUATION_ENVIRONMENT,\n createViteTamaguiLoader,\n viteBuildConfigLoader\n};\n//# sourceMappingURL=loadTamagui.js.map\n"],"mappings":";;;;;;AAIA,MAAM,iCAAiC;AACvC,MAAM,wBAAwB,OAAO,cAAc,SAAS;CAC1D,MAAM,EAAE,QAAQ,iBAAiB,MAAM,aACrC,cACA,EAAE,KAAK,CACT;CACA,OAAO;EAAE,SAAS;EAAQ,cAAc,CAAC,cAAc,GAAG,YAAY;CAAE;AAC1E;AACA,MAAM,oBAAoB,cACxB,OAAO,eAAe,WAAW,aAAa,YAAY,GAC5D;AACA,MAAM,qBAAqB,CACzB,wBAAwB,kBAAkB,mCAAmC,CAAC,CAAC,SACjF;AACA,SAAS,wBAAwB,YAAY,CAAC,GAAG;CAC/C,IAAI,cAAc;CAClB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