@tamagui/static 2.0.0-rc.4 → 2.0.0-rc.40

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 (185) hide show
  1. package/dist/check-dep-versions.cjs +201 -96
  2. package/dist/checkDeps.cjs +250 -46
  3. package/dist/constants.cjs +32 -30
  4. package/dist/exports.cjs +18 -13
  5. package/dist/extractor/accessSafe.cjs +25 -23
  6. package/dist/extractor/babelParse.cjs +30 -28
  7. package/dist/extractor/buildClassName.cjs +59 -35
  8. package/dist/extractor/bundle.cjs +177 -101
  9. package/dist/extractor/bundleConfig.cjs +554 -167
  10. package/dist/extractor/concatClassName.cjs +41 -29
  11. package/dist/extractor/createEvaluator.cjs +54 -41
  12. package/dist/extractor/createExtractor.cjs +1400 -581
  13. package/dist/extractor/createLogger.cjs +30 -25
  14. package/dist/extractor/detectModuleFormat.cjs +55 -0
  15. package/dist/extractor/ensureImportingConcat.cjs +31 -25
  16. package/dist/extractor/errors.cjs +12 -10
  17. package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
  18. package/dist/extractor/esbuildTsconfigPaths.cjs +60 -36
  19. package/dist/extractor/evaluateAstNode.cjs +104 -59
  20. package/dist/extractor/extractHelpers.cjs +130 -67
  21. package/dist/extractor/extractMediaStyle.cjs +110 -69
  22. package/dist/extractor/extractToClassNames.cjs +337 -229
  23. package/dist/extractor/extractToNative.cjs +248 -154
  24. package/dist/extractor/findTopmostFunction.cjs +22 -13
  25. package/dist/extractor/generatedUid.cjs +39 -28
  26. package/dist/extractor/getPrefixLogs.cjs +12 -10
  27. package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
  28. package/dist/extractor/getSourceModule.cjs +73 -37
  29. package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
  30. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +20 -14
  31. package/dist/extractor/hasTopLevelAwait.cjs +62 -0
  32. package/dist/extractor/hoistClassNames.cjs +46 -32
  33. package/dist/extractor/literalToAst.cjs +67 -42
  34. package/dist/extractor/loadFile.cjs +9 -3
  35. package/dist/extractor/loadTamagui.cjs +149 -104
  36. package/dist/extractor/logLines.cjs +27 -19
  37. package/dist/extractor/normalizeTernaries.cjs +66 -44
  38. package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
  39. package/dist/extractor/regenerateConfig.cjs +109 -81
  40. package/dist/extractor/removeUnusedHooks.cjs +73 -41
  41. package/dist/extractor/timer.cjs +23 -14
  42. package/dist/extractor/validHTMLAttributes.cjs +61 -59
  43. package/dist/extractor/watchTamaguiConfig.cjs +35 -23
  44. package/dist/getPragmaOptions.cjs +38 -19
  45. package/dist/helpers/memoize.cjs +24 -16
  46. package/dist/helpers/requireTamaguiCore.cjs +22 -15
  47. package/dist/index.cjs +26 -24
  48. package/dist/registerRequire.cjs +167 -65
  49. package/dist/server.cjs +35 -28
  50. package/dist/types.cjs +7 -5
  51. package/dist/worker.cjs +62 -40
  52. package/package.json +26 -22
  53. package/src/checkDeps.ts +305 -68
  54. package/src/exports.ts +1 -0
  55. package/src/extractor/babelParse.ts +1 -0
  56. package/src/extractor/bundle.ts +140 -37
  57. package/src/extractor/bundleConfig.ts +435 -61
  58. package/src/extractor/createExtractor.ts +283 -48
  59. package/src/extractor/detectModuleFormat.ts +42 -0
  60. package/src/extractor/esbuildTsconfigPaths.ts +6 -1
  61. package/src/extractor/extractToClassNames.ts +15 -9
  62. package/src/extractor/extractToNative.ts +66 -33
  63. package/src/extractor/hasTopLevelAwait.ts +28 -0
  64. package/src/extractor/loadTamagui.ts +2 -2
  65. package/src/getPragmaOptions.ts +6 -1
  66. package/src/registerRequire.ts +88 -8
  67. package/types/checkDeps.d.ts.map +1 -1
  68. package/types/exports.d.ts +1 -0
  69. package/types/exports.d.ts.map +1 -1
  70. package/types/extractor/babelParse.d.ts.map +1 -1
  71. package/types/extractor/bundle.d.ts +83 -1
  72. package/types/extractor/bundle.d.ts.map +1 -1
  73. package/types/extractor/bundleConfig.d.ts +15 -2
  74. package/types/extractor/bundleConfig.d.ts.map +1 -1
  75. package/types/extractor/createExtractor.d.ts.map +1 -1
  76. package/types/extractor/detectModuleFormat.d.ts +5 -0
  77. package/types/extractor/detectModuleFormat.d.ts.map +1 -0
  78. package/types/extractor/esbuildTsconfigPaths.d.ts +8 -0
  79. package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
  80. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  81. package/types/extractor/extractToNative.d.ts.map +1 -1
  82. package/types/extractor/hasTopLevelAwait.d.ts +2 -0
  83. package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
  84. package/types/getPragmaOptions.d.ts.map +1 -1
  85. package/types/registerRequire.d.ts.map +1 -1
  86. package/dist/check-dep-versions.js +0 -389
  87. package/dist/check-dep-versions.js.map +0 -6
  88. package/dist/checkDeps.js +0 -60
  89. package/dist/checkDeps.js.map +0 -6
  90. package/dist/constants.js +0 -34
  91. package/dist/constants.js.map +0 -6
  92. package/dist/exports.js +0 -34
  93. package/dist/exports.js.map +0 -6
  94. package/dist/extractor/accessSafe.js +0 -47
  95. package/dist/extractor/accessSafe.js.map +0 -6
  96. package/dist/extractor/babelParse.js +0 -59
  97. package/dist/extractor/babelParse.js.map +0 -6
  98. package/dist/extractor/buildClassName.js +0 -72
  99. package/dist/extractor/buildClassName.js.map +0 -6
  100. package/dist/extractor/bundle.js +0 -135
  101. package/dist/extractor/bundle.js.map +0 -6
  102. package/dist/extractor/bundleConfig.js +0 -352
  103. package/dist/extractor/bundleConfig.js.map +0 -6
  104. package/dist/extractor/concatClassName.js +0 -69
  105. package/dist/extractor/concatClassName.js.map +0 -6
  106. package/dist/extractor/createEvaluator.js +0 -66
  107. package/dist/extractor/createEvaluator.js.map +0 -6
  108. package/dist/extractor/createExtractor.js +0 -1215
  109. package/dist/extractor/createExtractor.js.map +0 -6
  110. package/dist/extractor/createLogger.js +0 -32
  111. package/dist/extractor/createLogger.js.map +0 -6
  112. package/dist/extractor/ensureImportingConcat.js +0 -50
  113. package/dist/extractor/ensureImportingConcat.js.map +0 -6
  114. package/dist/extractor/errors.js +0 -22
  115. package/dist/extractor/errors.js.map +0 -6
  116. package/dist/extractor/esbuildAliasPlugin.js +0 -36
  117. package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
  118. package/dist/extractor/esbuildTsconfigPaths.js +0 -79
  119. package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
  120. package/dist/extractor/evaluateAstNode.js +0 -99
  121. package/dist/extractor/evaluateAstNode.js.map +0 -6
  122. package/dist/extractor/extractHelpers.js +0 -108
  123. package/dist/extractor/extractHelpers.js.map +0 -6
  124. package/dist/extractor/extractMediaStyle.js +0 -123
  125. package/dist/extractor/extractMediaStyle.js.map +0 -6
  126. package/dist/extractor/extractToClassNames.js +0 -351
  127. package/dist/extractor/extractToClassNames.js.map +0 -6
  128. package/dist/extractor/extractToNative.js +0 -286
  129. package/dist/extractor/extractToNative.js.map +0 -6
  130. package/dist/extractor/findTopmostFunction.js +0 -32
  131. package/dist/extractor/findTopmostFunction.js.map +0 -6
  132. package/dist/extractor/generatedUid.js +0 -42
  133. package/dist/extractor/generatedUid.js.map +0 -6
  134. package/dist/extractor/getPrefixLogs.js +0 -24
  135. package/dist/extractor/getPrefixLogs.js.map +0 -6
  136. package/dist/extractor/getPropValueFromAttributes.js +0 -65
  137. package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
  138. package/dist/extractor/getSourceModule.js +0 -62
  139. package/dist/extractor/getSourceModule.js.map +0 -6
  140. package/dist/extractor/getStaticBindingsForScope.js +0 -145
  141. package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
  142. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
  143. package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
  144. package/dist/extractor/hoistClassNames.js +0 -63
  145. package/dist/extractor/hoistClassNames.js.map +0 -6
  146. package/dist/extractor/literalToAst.js +0 -90
  147. package/dist/extractor/literalToAst.js.map +0 -6
  148. package/dist/extractor/loadFile.js +0 -14
  149. package/dist/extractor/loadFile.js.map +0 -6
  150. package/dist/extractor/loadTamagui.js +0 -306
  151. package/dist/extractor/loadTamagui.js.map +0 -6
  152. package/dist/extractor/logLines.js +0 -30
  153. package/dist/extractor/logLines.js.map +0 -6
  154. package/dist/extractor/normalizeTernaries.js +0 -61
  155. package/dist/extractor/normalizeTernaries.js.map +0 -6
  156. package/dist/extractor/propsToFontFamilyCache.js +0 -33
  157. package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
  158. package/dist/extractor/regenerateConfig.js +0 -123
  159. package/dist/extractor/regenerateConfig.js.map +0 -6
  160. package/dist/extractor/removeUnusedHooks.js +0 -72
  161. package/dist/extractor/removeUnusedHooks.js.map +0 -6
  162. package/dist/extractor/timer.js +0 -38
  163. package/dist/extractor/timer.js.map +0 -6
  164. package/dist/extractor/validHTMLAttributes.js +0 -72
  165. package/dist/extractor/validHTMLAttributes.js.map +0 -6
  166. package/dist/extractor/watchTamaguiConfig.js +0 -57
  167. package/dist/extractor/watchTamaguiConfig.js.map +0 -6
  168. package/dist/getPragmaOptions.js +0 -46
  169. package/dist/getPragmaOptions.js.map +0 -6
  170. package/dist/helpers/memoize.js +0 -33
  171. package/dist/helpers/memoize.js.map +0 -6
  172. package/dist/helpers/requireTamaguiCore.js +0 -30
  173. package/dist/helpers/requireTamaguiCore.js.map +0 -6
  174. package/dist/index.js +0 -30
  175. package/dist/index.js.map +0 -6
  176. package/dist/registerRequire.js +0 -100
  177. package/dist/registerRequire.js.map +0 -6
  178. package/dist/server.js +0 -58
  179. package/dist/server.js.map +0 -6
  180. package/dist/setup.js +0 -1
  181. package/dist/setup.js.map +0 -6
  182. package/dist/types.js +0 -14
  183. package/dist/types.js.map +0 -6
  184. package/dist/worker.js +0 -72
  185. package/dist/worker.js.map +0 -6
@@ -2,103 +2,250 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var bundleConfig_exports = {};
33
35
  __export(bundleConfig_exports, {
34
36
  bundleConfig: () => bundleConfig,
35
37
  esbuildOptions: () => esbuildOptions,
38
+ esbuildOptionsWithPlugins: () => esbuildOptionsWithPlugins,
36
39
  getBundledConfig: () => getBundledConfig,
37
40
  getLoadedConfig: () => getLoadedConfig,
38
41
  hasBundledConfigChanged: () => hasBundledConfigChanged,
39
42
  loadComponents: () => loadComponents,
40
43
  loadComponentsInner: () => loadComponentsInner,
44
+ loadComponentsInnerSync: () => loadComponentsInnerSync,
45
+ loadComponentsSync: () => loadComponentsSync,
41
46
  writeTamaguiCSS: () => writeTamaguiCSS
42
47
  });
43
48
  module.exports = __toCommonJS(bundleConfig_exports);
44
- var import_generator = __toESM(require("@babel/generator")),
45
- import_traverse = __toESM(require("@babel/traverse")),
46
- t = __toESM(require("@babel/types")),
47
- import_node_fs = require("node:fs"),
48
- import_node_path = require("node:path"),
49
- import_cli_color = require("@tamagui/cli-color"),
50
- import_esbuild = __toESM(require("esbuild")),
51
- FS = __toESM(require("fs-extra")),
52
- import_promises = require("node:fs/promises"),
53
- import_registerRequire = require("../registerRequire.cjs"),
54
- import_babelParse = require("./babelParse.cjs"),
55
- import_bundle = require("./bundle.cjs"),
56
- import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs"),
57
- import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
58
- const external = ["@tamagui/core", "@tamagui/web", "react", "react-dom", "react-native-svg"],
59
- esbuildExtraOptions = {
60
- define: {
61
- __DEV__: `${process.env.NODE_ENV === "development"}`
62
- }
63
- },
64
- esbuildOptions = {
65
- target: "es2018",
66
- format: "cjs",
67
- jsx: "automatic",
68
- platform: "node",
69
- ...esbuildExtraOptions
70
- };
71
- let currentBundle = null,
72
- isBundling = !1,
73
- lastBundle = null;
49
+ var import_generator = __toESM(require("@babel/generator"));
50
+ var import_traverse = __toESM(require("@babel/traverse"));
51
+ var t = __toESM(require("@babel/types"));
52
+ var import_node_crypto = require("node:crypto");
53
+ var import_node_fs = require("node:fs");
54
+ var import_node_path = require("node:path");
55
+ var import_node_url = require("node:url");
56
+ var import_cli_color = require("@tamagui/cli-color");
57
+ var import_esbuild = __toESM(require("esbuild"));
58
+ var FS = __toESM(require("fs-extra"));
59
+ var import_promises = require("node:fs/promises");
60
+ var import_registerRequire = require("../registerRequire.cjs");
61
+ var import_babelParse = require("./babelParse.cjs");
62
+ var import_bundle = require("./bundle.cjs");
63
+ var import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs");
64
+ var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
65
+ var import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs");
66
+ var import_detectModuleFormat = require("./detectModuleFormat.cjs");
67
+ const activeTempFiles = /* @__PURE__ */new Set();
68
+ function getDynamicEvalOutfile(name, format, contents) {
69
+ const ext = format === "esm" ? "mjs" : "cjs";
70
+ const hash = (0, import_node_crypto.createHash)("sha1").update(name).update("\0").update(format).update("\0").update(contents).digest("hex").slice(0, 10);
71
+ return (0, import_node_path.join)(process.cwd(), ".tamagui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
72
+ }
73
+ function getEsbuildStdinLoader(filePath) {
74
+ if (filePath.endsWith(".tsx")) return "tsx";
75
+ if (filePath.endsWith(".ts")) return "ts";
76
+ if (filePath.endsWith(".jsx")) return "jsx";
77
+ return "js";
78
+ }
79
+ function resolvePackageEntry(packageName, format) {
80
+ if (format === "cjs") {
81
+ return require.resolve(packageName);
82
+ }
83
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
84
+ const packageJson = JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf-8"));
85
+ const packageRoot = (0, import_node_path.dirname)(packageJsonPath);
86
+ const exportEntry = packageJson.exports?.["."];
87
+ const esmEntry = exportEntry?.import || exportEntry?.module || exportEntry?.browser || packageJson.module;
88
+ if (typeof esmEntry === "string") {
89
+ return (0, import_node_path.join)(packageRoot, esmEntry);
90
+ }
91
+ return require.resolve(packageName);
92
+ }
93
+ function cleanupTempFiles() {
94
+ for (const f of activeTempFiles) {
95
+ try {
96
+ (0, import_node_fs.unlinkSync)(f);
97
+ } catch {}
98
+ }
99
+ activeTempFiles.clear();
100
+ }
101
+ process.on("exit", cleanupTempFiles);
102
+ process.on("SIGINT", () => {
103
+ cleanupTempFiles();
104
+ process.exit();
105
+ });
106
+ process.on("SIGTERM", () => {
107
+ cleanupTempFiles();
108
+ process.exit();
109
+ });
110
+ const external = ["@tamagui/core", "@tamagui/web", "react", "react-dom", "react-native-svg"];
111
+ const esbuildExtraOptions = {
112
+ define: {
113
+ __DEV__: `${process.env.NODE_ENV === "development"}`
114
+ }
115
+ };
116
+ const handleEsmFeaturesPlugin = {
117
+ name: "handle-esm-features",
118
+ setup(build) {
119
+ const isCjs = build.initialOptions.format === "cjs" || !build.initialOptions.format;
120
+ build.onLoad({
121
+ filter: /\.(ts|tsx|js|jsx|mjs)$/
122
+ }, args => {
123
+ if (!isCjs) {
124
+ return null;
125
+ }
126
+ if (args.path.includes("node_modules") && !args.path.includes("@tamagui")) {
127
+ return null;
128
+ }
129
+ let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
130
+ let modified = false;
131
+ if (contents.includes("import.meta.env")) {
132
+ contents = contents.replace(/import\.meta\.env/g, "process.env");
133
+ modified = true;
134
+ }
135
+ if (contents.includes("import.meta.url")) {
136
+ contents = contents.replace(/import\.meta\.url/g, '""');
137
+ modified = true;
138
+ }
139
+ if (contents.includes("import.meta.main")) {
140
+ contents = contents.replace(/import\.meta\.main/g, "false");
141
+ modified = true;
142
+ }
143
+ if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
144
+ if (process.env.DEBUG?.startsWith("tamagui")) {
145
+ console.info(`[tamagui] stubbing file with top-level await: ${args.path}`);
146
+ }
147
+ return {
148
+ // Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
149
+ // `module.exports = {}` into the parent bundle and wipe its exports.
150
+ contents: `// stubbed - contains top-level await
151
+ export default {}`,
152
+ loader: "js"
153
+ };
154
+ }
155
+ if (modified) {
156
+ return {
157
+ contents,
158
+ loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
159
+ };
160
+ }
161
+ return null;
162
+ });
163
+ }
164
+ };
165
+ const esbuildTransformOptions = {
166
+ target: "es2022",
167
+ format: "cjs",
168
+ jsx: "automatic",
169
+ platform: "node",
170
+ ...esbuildExtraOptions
171
+ };
172
+ const esbuildOptions = {
173
+ ...esbuildTransformOptions
174
+ };
175
+ const esbuildOptionsWithPlugins = {
176
+ ...esbuildTransformOptions,
177
+ plugins: [handleEsmFeaturesPlugin]
178
+ };
179
+ let currentBundle = null;
180
+ let isBundling = false;
181
+ let lastBundle = null;
74
182
  const waitForBundle = /* @__PURE__ */new Set();
75
183
  function hasBundledConfigChanged() {
76
- return lastBundle === currentBundle ? !1 : (lastBundle = currentBundle, !0);
184
+ if (lastBundle === currentBundle) {
185
+ return false;
186
+ }
187
+ lastBundle = currentBundle;
188
+ return true;
77
189
  }
78
190
  let loadedConfig = null;
79
191
  const getLoadedConfig = () => loadedConfig;
80
- async function getBundledConfig(props, rebuild = !1) {
81
- if (isBundling) await new Promise(res => {
82
- waitForBundle.add(res);
83
- });else if (!currentBundle || rebuild) return await bundleConfig(props);
192
+ async function getBundledConfig(props, rebuild = false) {
193
+ if (isBundling) {
194
+ await new Promise(res => {
195
+ waitForBundle.add(res);
196
+ });
197
+ } else if (!currentBundle || rebuild) {
198
+ return await bundleConfig(props);
199
+ }
84
200
  return currentBundle;
85
201
  }
86
202
  global.tamaguiLastLoaded ||= 0;
87
203
  function updateLastLoaded(config) {
88
- global.tamaguiLastLoaded = Date.now(), global.tamaguiLastBundledConfig = config;
204
+ global.tamaguiLastLoaded = Date.now();
205
+ global.tamaguiLastBundledConfig = config;
89
206
  }
90
- let hasBundledOnce = !1,
91
- hasLoggedBuild = !1;
207
+ let hasBundledOnce = false;
208
+ let hasLoggedBuild = false;
92
209
  async function bundleConfig(props) {
93
- if (global.tamaguiLastBundledConfig && Date.now() - global.tamaguiLastLoaded < 3e3) return global.tamaguiLastBundledConfig;
210
+ if (global.tamaguiLastBundledConfig && Date.now() - global.tamaguiLastLoaded < 3e3) {
211
+ return global.tamaguiLastBundledConfig;
212
+ }
94
213
  try {
95
- isBundling = !0;
96
- const configEntry = props.config ? (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(props.config) : "",
97
- tmpDir = (0, import_node_path.join)(process.cwd(), ".tamagui"),
98
- configOutPath = (0, import_node_path.join)(tmpDir, "tamagui.config.cjs"),
99
- baseComponents = (props.components || []).filter(x => x !== "@tamagui/core"),
100
- componentOutPaths = baseComponents.map(componentModule => (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config.cjs`));
101
- if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui") && console.info("Building config entry", configEntry), !props.disableInitialBuild) {
214
+ isBundling = true;
215
+ const configEntry = props.config ? (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(props.config) : "";
216
+ const tmpDir = (0, import_node_path.join)(process.cwd(), ".tamagui");
217
+ const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
218
+ const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
219
+ const configOutPath = (0, import_node_path.join)(tmpDir, `tamagui.config${configExt}`);
220
+ const baseComponents = (props.components || []).filter(x => x !== "@tamagui/core");
221
+ const componentFormats = baseComponents.map(mod => {
222
+ try {
223
+ const pkgJson = require.resolve(mod + "/package.json");
224
+ const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJson, "utf-8"));
225
+ return pkg.type === "module" ? "esm" : "cjs";
226
+ } catch {
227
+ return "cjs";
228
+ }
229
+ });
230
+ const componentOutPaths = baseComponents.map((componentModule, i) => {
231
+ const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
232
+ return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
233
+ });
234
+ if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui")) {
235
+ console.info(`Building config entry`, configEntry);
236
+ }
237
+ let shouldBuild = !props.disableInitialBuild;
238
+ if (shouldBuild && props.config) {
239
+ const allOutFiles = [configOutPath, ...componentOutPaths];
240
+ try {
241
+ const stats = await Promise.all(allOutFiles.map(f => FS.stat(f).catch(() => null)));
242
+ const allExistAndRecent = stats.every(s => s !== null && Date.now() - s.mtimeMs < 3e3);
243
+ if (allExistAndRecent) {
244
+ shouldBuild = false;
245
+ }
246
+ } catch {}
247
+ }
248
+ if (shouldBuild) {
102
249
  try {
103
250
  await FS.ensureDir(tmpDir);
104
251
  } catch {}
@@ -107,92 +254,277 @@ async function bundleConfig(props) {
107
254
  entryPoints: [configEntry],
108
255
  external,
109
256
  outfile: configOutPath,
110
- target: "node20",
111
- ...esbuildExtraOptions
112
- }, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => (0, import_bundle.esbundleTamaguiConfig)({
113
- entryPoints: [componentModule],
114
- resolvePlatformSpecificEntries: !0,
115
- external,
116
- outfile: componentOutPaths[i],
117
- target: "node20",
257
+ target: "node24",
258
+ format: configFormat,
118
259
  ...esbuildExtraOptions
119
- }, props.platform || "web"))]), !hasLoggedBuild && !props._skipBuildLog && (hasLoggedBuild = !0, (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
120
- \u27A1 [tamagui] built config, components, prompt (${Date.now() - start}ms)`), process.env.DEBUG?.startsWith("tamagui") && (0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
260
+ }, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => {
261
+ return (0, import_bundle.esbundleTamaguiConfig)({
262
+ entryPoints: [componentModule],
263
+ resolvePlatformSpecificEntries: true,
264
+ external,
265
+ outfile: componentOutPaths[i],
266
+ target: "node24",
267
+ format: componentFormats[i],
268
+ ...esbuildExtraOptions
269
+ }, props.platform || "web");
270
+ })]);
271
+ if (!hasLoggedBuild && !props["_skipBuildLog"]) {
272
+ hasLoggedBuild = true;
273
+ (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
274
+ \u27A1 [tamagui] built config, components, prompt (${Date.now() - start}ms)`);
275
+ if (process.env.DEBUG?.startsWith("tamagui")) {
276
+ (0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
121
277
  Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
122
- Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join(`
123
- `)}
124
- `));
278
+ Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join("\n ")}
279
+ `);
280
+ }
281
+ }
282
+ }
283
+ if (hasBundledOnce) {
284
+ try {
285
+ delete require.cache[require.resolve(configOutPath)];
286
+ } catch {}
287
+ for (const p of componentOutPaths) {
288
+ try {
289
+ delete require.cache[require.resolve(p)];
290
+ } catch {}
291
+ }
292
+ } else {
293
+ hasBundledOnce = true;
125
294
  }
126
295
  let out;
127
- const {
128
- unregister
129
- } = (0, import_registerRequire.registerRequire)(props.platform || "web");
130
- try {
131
- if (hasBundledOnce) for (const key in require.cache) /(core|web)[/\\]dist/.test(key) || delete require.cache[key];else hasBundledOnce = !0;
296
+ if (configFormat === "esm") {
297
+ out = await import((0, import_node_url.pathToFileURL)(configOutPath).href);
298
+ } else {
132
299
  out = require(configOutPath);
133
- } finally {
134
- unregister();
135
300
  }
136
301
  let config = out.default || out || out.config;
137
- if (config && config.config && !config.tokens && (config = config.config), !config) throw new Error(`No config: ${config}`);
138
- if (loadedConfig = config, !config.parsed) {
302
+ if (config && config.config && !config.tokens) {
303
+ config = config.config;
304
+ }
305
+ if (!config) {
306
+ throw new Error(`No config: ${config}`);
307
+ }
308
+ if (config._isProxyWorm) {
309
+ throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=tamagui for details.`);
310
+ }
311
+ loadedConfig = config;
312
+ if (!config.parsed) {
139
313
  const {
140
314
  createTamagui
141
315
  } = (0, import_requireTamaguiCore.requireTamaguiCore)(props.platform || "web");
142
316
  config = createTamagui(config);
143
317
  }
144
- props.outputCSS && (await writeTamaguiCSS(props.outputCSS, config));
145
- let components = loadComponents({
318
+ if (props.outputCSS) {
319
+ await writeTamaguiCSS(props.outputCSS, config);
320
+ }
321
+ let components = await loadComponents({
146
322
  ...props,
147
323
  components: componentOutPaths
148
324
  });
149
- if (!components) throw new Error(`No components found: ${componentOutPaths.join(", ")}`);
150
- for (const component of components) component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName, component.moduleName || (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) && console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
151
- process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui") && console.info("Loaded components", components);
325
+ if (!components) {
326
+ throw new Error(`No components found: ${componentOutPaths.join(", ")}`);
327
+ }
328
+ for (const component of components) {
329
+ component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName;
330
+ if (!component.moduleName) {
331
+ if (process.env.DEBUG?.includes("tamagui") || process.env.IS_TAMAGUI_DEV) {
332
+ console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
333
+ }
334
+ }
335
+ }
336
+ if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui")) {
337
+ console.info("Loaded components", components);
338
+ }
152
339
  const res = {
153
340
  components,
154
341
  nameToPaths: {},
155
342
  tamaguiConfig: config
156
343
  };
157
- return currentBundle = res, updateLastLoaded(res), res;
344
+ currentBundle = res;
345
+ updateLastLoaded(res);
346
+ return res;
158
347
  } catch (err) {
159
- console.error(`Error bundling tamagui config: ${err?.message} (run with DEBUG=tamagui to see stack)`), process.env.DEBUG?.includes("tamagui") && console.error(err.stack);
348
+ console.error(`Error bundling tamagui config: ${err?.message} (run with DEBUG=tamagui to see stack)`);
349
+ if (process.env.DEBUG?.includes("tamagui")) {
350
+ console.error(err.stack);
351
+ }
160
352
  } finally {
161
- isBundling = !1, waitForBundle.forEach(cb => cb()), waitForBundle.clear();
353
+ isBundling = false;
354
+ waitForBundle.forEach(cb => cb());
355
+ waitForBundle.clear();
162
356
  }
163
357
  }
164
358
  async function writeTamaguiCSS(outputCSS, config) {
165
359
  const flush = async () => {
166
- (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [tamagui] output css: ${outputCSS}`), await FS.writeFile(outputCSS, css);
167
- },
168
- css = config.getCSS();
169
- if (typeof css != "string") throw new Error(`Invalid CSS: ${typeof css} ${css}`);
360
+ (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [tamagui] output css: ${outputCSS}`);
361
+ await FS.writeFile(outputCSS, css);
362
+ };
363
+ const css = config.getCSS();
364
+ if (typeof css !== "string") {
365
+ throw new Error(`Invalid CSS: ${typeof css} ${css}`);
366
+ }
170
367
  try {
171
- (0, import_node_fs.existsSync)(outputCSS) && (await (0, import_promises.readFile)(outputCSS, "utf8")) === css || (await flush());
368
+ if ((0, import_node_fs.existsSync)(outputCSS) && (await (0, import_promises.readFile)(outputCSS, "utf8")) === css) {} else {
369
+ await flush();
370
+ }
172
371
  } catch (err) {
173
372
  console.info("Error writing themes", err);
174
373
  }
175
374
  }
176
- function loadComponents(props, forceExports = !1) {
177
- const coreComponents = getCoreComponents(props),
178
- otherComponents = loadComponentsInner(props, forceExports);
375
+ async function loadComponents(props, forceExports = false) {
376
+ const coreComponents = getCoreComponentsSync(props);
377
+ const otherComponents = await loadComponentsInner(props, forceExports);
378
+ return [...coreComponents, ...(otherComponents || [])];
379
+ }
380
+ function loadComponentsSync(props, forceExports = false) {
381
+ const coreComponents = getCoreComponentsSync(props);
382
+ const otherComponents = loadComponentsInnerSync(props, forceExports);
179
383
  return [...coreComponents, ...(otherComponents || [])];
180
384
  }
181
- function getCoreComponents(props) {
182
- const loaded = loadComponentsInner({
385
+ function getCoreComponentsSync(props) {
386
+ const loaded = loadComponentsInnerSync({
183
387
  ...props,
184
388
  components: ["@tamagui/core"]
185
389
  });
186
- if (!loaded) throw new Error("Core should always load");
390
+ if (!loaded) {
391
+ throw new Error(`Core should always load`);
392
+ }
187
393
  return [{
188
394
  ...loaded[0],
189
395
  moduleName: "@tamagui/core"
190
396
  }];
191
397
  }
192
- function loadComponentsInner(props, forceExports = !1) {
193
- const componentsModules = props.components || [],
194
- key = componentsModules.join("");
195
- if (!forceExports && cacheComponents[key]) return cacheComponents[key];
398
+ async function loadComponentsInner(props, forceExports = false) {
399
+ const componentsModules = props.components || [];
400
+ const key = componentsModules.join("\0");
401
+ if (!forceExports && cacheComponents[key]) {
402
+ return cacheComponents[key];
403
+ }
404
+ const {
405
+ unregister
406
+ } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
407
+ proxyWormImports: forceExports
408
+ });
409
+ try {
410
+ const results = [];
411
+ for (const name of componentsModules) {
412
+ const extension = (0, import_node_path.extname)(name);
413
+ const isLocal = Boolean(extension);
414
+ const isDynamic = isLocal && forceExports;
415
+ const format = isLocal ? (0, import_detectModuleFormat.detectModuleFormat)(name) : "cjs";
416
+ const fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
417
+ let loadModule = name;
418
+ let writtenContents = fileContents;
419
+ let didBabel = false;
420
+ const attemptLoad = async ({
421
+ forceExports: forceExports2 = false
422
+ } = {}) => {
423
+ if (isDynamic) {
424
+ writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents;
425
+ loadModule = getDynamicEvalOutfile(name, format, writtenContents);
426
+ FS.ensureDirSync((0, import_node_path.dirname)(loadModule));
427
+ activeTempFiles.add(loadModule);
428
+ await import_esbuild.default.build({
429
+ ...esbuildOptionsWithPlugins,
430
+ format,
431
+ outfile: loadModule,
432
+ stdin: {
433
+ contents: writtenContents,
434
+ resolveDir: (0, import_node_path.dirname)(name),
435
+ sourcefile: name,
436
+ loader: getEsbuildStdinLoader(name)
437
+ },
438
+ alias: {
439
+ "react-native": resolvePackageEntry("@tamagui/react-native-web-lite", format),
440
+ "@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", format),
441
+ "@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", format)
442
+ },
443
+ bundle: true,
444
+ packages: "external",
445
+ allowOverwrite: true,
446
+ sourcemap: false,
447
+ loader: import_bundle.esbuildLoaderConfig
448
+ });
449
+ }
450
+ if (process.env.DEBUG === "tamagui") {
451
+ console.info(`loadModule`, loadModule, format);
452
+ }
453
+ let moduleResult;
454
+ if (format === "esm") {
455
+ moduleResult = await import((0, import_node_url.pathToFileURL)(loadModule).href);
456
+ } else {
457
+ moduleResult = require(loadModule);
458
+ }
459
+ if (!forceExports2) {
460
+ (0, import_registerRequire.setRequireResult)(name, moduleResult);
461
+ }
462
+ const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
463
+ return {
464
+ moduleName: name,
465
+ nameToInfo
466
+ };
467
+ };
468
+ const dispose = () => {
469
+ if (isDynamic) {
470
+ FS.removeSync(loadModule);
471
+ activeTempFiles.delete(loadModule);
472
+ }
473
+ };
474
+ let loaded;
475
+ try {
476
+ loaded = await attemptLoad({
477
+ forceExports: true
478
+ });
479
+ didBabel = true;
480
+ } catch (err) {
481
+ console.info("babel err", err, writtenContents);
482
+ writtenContents = fileContents;
483
+ if (process.env.DEBUG?.startsWith("tamagui")) {
484
+ console.info(`Error parsing babel likely`, err);
485
+ }
486
+ try {
487
+ loaded = await attemptLoad({
488
+ forceExports: false
489
+ });
490
+ } catch (err2) {
491
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
492
+ console.info(`
493
+ Tamagui attempted but failed to dynamically optimize components in:
494
+ ${name}
495
+ `);
496
+ console.info(err2);
497
+ console.info(`At: ${loadModule}`, `
498
+ didBabel: ${didBabel}`, `
499
+ In:`, writtenContents, `
500
+ isDynamic: `, isDynamic);
501
+ }
502
+ loaded = [];
503
+ }
504
+ } finally {
505
+ dispose();
506
+ }
507
+ if (Array.isArray(loaded)) {
508
+ results.push(...loaded);
509
+ } else if (loaded) {
510
+ results.push(loaded);
511
+ }
512
+ }
513
+ cacheComponents[key] = results;
514
+ return results;
515
+ } catch (err) {
516
+ console.info(`Tamagui error bundling components`, err.message, err.stack);
517
+ return null;
518
+ } finally {
519
+ unregister();
520
+ }
521
+ }
522
+ function loadComponentsInnerSync(props, forceExports = false) {
523
+ const componentsModules = props.components || [];
524
+ const key = componentsModules.join("\0");
525
+ if (!forceExports && cacheComponents[key]) {
526
+ return cacheComponents[key];
527
+ }
196
528
  const {
197
529
  unregister
198
530
  } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
@@ -200,30 +532,49 @@ function loadComponentsInner(props, forceExports = !1) {
200
532
  });
201
533
  try {
202
534
  const info = componentsModules.flatMap(name => {
203
- const isDynamic = !!(0, import_node_path.extname)(name) && forceExports,
204
- fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "",
205
- loadModule = isDynamic ? (0, import_node_path.join)((0, import_node_path.dirname)(name), `.tamagui-dynamic-eval-${(0, import_node_path.basename)(name)}.tsx`) : name;
206
- let writtenContents = fileContents,
207
- didBabel = !1;
535
+ const extension = (0, import_node_path.extname)(name);
536
+ const isLocal = Boolean(extension);
537
+ const isDynamic = isLocal && forceExports;
538
+ const fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
539
+ let loadModule = name;
540
+ let writtenContents = fileContents;
541
+ let didBabel = false;
208
542
  function attemptLoad({
209
- forceExports: forceExports2 = !1
543
+ forceExports: forceExports2 = false
210
544
  } = {}) {
211
- isDynamic && (writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents, FS.writeFileSync(loadModule, writtenContents), import_esbuild.default.buildSync({
212
- ...esbuildOptions,
213
- entryPoints: [loadModule],
214
- outfile: loadModule,
215
- alias: {
216
- "react-native": require.resolve("@tamagui/react-native-web-lite")
217
- },
218
- bundle: !0,
219
- packages: "external",
220
- allowOverwrite: !0,
221
- // logLevel: 'silent',
222
- sourcemap: !1,
223
- loader: import_bundle.esbuildLoaderConfig
224
- })), process.env.DEBUG === "tamagui" && console.info("loadModule", loadModule, require.resolve(loadModule));
545
+ if (isDynamic) {
546
+ writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents;
547
+ loadModule = getDynamicEvalOutfile(name, "cjs", writtenContents);
548
+ FS.ensureDirSync((0, import_node_path.dirname)(loadModule));
549
+ activeTempFiles.add(loadModule);
550
+ import_esbuild.default.buildSync({
551
+ ...esbuildOptions,
552
+ outfile: loadModule,
553
+ stdin: {
554
+ contents: writtenContents,
555
+ resolveDir: (0, import_node_path.dirname)(name),
556
+ sourcefile: name,
557
+ loader: getEsbuildStdinLoader(name)
558
+ },
559
+ alias: {
560
+ "react-native": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
561
+ "@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
562
+ "@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", "esm")
563
+ },
564
+ bundle: true,
565
+ packages: "external",
566
+ allowOverwrite: true,
567
+ sourcemap: false,
568
+ loader: import_bundle.esbuildLoaderConfig
569
+ });
570
+ }
571
+ if (process.env.DEBUG === "tamagui") {
572
+ console.info(`loadModule`, loadModule, require.resolve(loadModule));
573
+ }
225
574
  const moduleResult = require(loadModule);
226
- forceExports2 || (0, import_registerRequire.setRequireResult)(name, moduleResult);
575
+ if (!forceExports2) {
576
+ (0, import_registerRequire.setRequireResult)(name, moduleResult);
577
+ }
227
578
  const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
228
579
  return {
229
580
  moduleName: name,
@@ -231,56 +582,74 @@ function loadComponentsInner(props, forceExports = !1) {
231
582
  };
232
583
  }
233
584
  const dispose = () => {
234
- isDynamic && FS.removeSync(loadModule);
585
+ if (isDynamic) {
586
+ FS.removeSync(loadModule);
587
+ activeTempFiles.delete(loadModule);
588
+ }
235
589
  };
236
590
  try {
237
591
  const res = attemptLoad({
238
- forceExports: !0
592
+ forceExports: true
239
593
  });
240
- return didBabel = !0, res;
594
+ didBabel = true;
595
+ return res;
241
596
  } catch (err) {
242
- console.info("babel err", err, writtenContents), writtenContents = fileContents, process.env.DEBUG?.startsWith("tamagui") && console.info("Error parsing babel likely", err);
597
+ console.info("babel err", err, writtenContents);
598
+ writtenContents = fileContents;
599
+ if (process.env.DEBUG?.startsWith("tamagui")) {
600
+ console.info(`Error parsing babel likely`, err);
601
+ }
243
602
  } finally {
244
603
  dispose();
245
604
  }
246
605
  try {
247
606
  return attemptLoad({
248
- forceExports: !1
607
+ forceExports: false
249
608
  });
250
609
  } catch (err) {
251
- return process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.info(`
252
-
610
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
611
+ console.info(`
253
612
  Tamagui attempted but failed to dynamically optimize components in:
254
613
  ${name}
255
- `), console.info(err), console.info(`At: ${loadModule}`, `
614
+ `);
615
+ console.info(err);
616
+ console.info(`At: ${loadModule}`, `
256
617
  didBabel: ${didBabel}`, `
257
618
  In:`, writtenContents, `
258
- isDynamic: `, isDynamic)), [];
619
+ isDynamic: `, isDynamic);
620
+ }
621
+ return [];
259
622
  } finally {
260
623
  dispose();
261
624
  }
262
625
  });
263
- return cacheComponents[key] = info, info;
626
+ cacheComponents[key] = info;
627
+ return info;
264
628
  } catch (err) {
265
- return console.info("Tamagui error bundling components", err.message, err.stack), null;
629
+ console.info(`Tamagui error bundling components`, err.message, err.stack);
630
+ return null;
266
631
  } finally {
267
632
  unregister();
268
633
  }
269
634
  }
270
- const esbuildit = (src, target) => import_esbuild.default.transformSync(src, {
271
- ...esbuildOptions,
272
- ...(target === "modern" && {
273
- target: "es2022",
274
- jsx: "automatic",
275
- loader: "tsx",
276
- platform: "neutral",
277
- format: "esm"
278
- })
279
- }).code;
635
+ const esbuildit = (src, target) => {
636
+ return import_esbuild.default.transformSync(src, {
637
+ ...esbuildTransformOptions,
638
+ ...(target === "modern" && {
639
+ target: "es2022",
640
+ jsx: "automatic",
641
+ loader: "tsx",
642
+ platform: "neutral",
643
+ format: "esm"
644
+ })
645
+ }).code;
646
+ };
280
647
  function getComponentStaticConfigByName(name, exported) {
281
648
  const components = {};
282
649
  try {
283
- if (!exported || typeof exported != "object" || Array.isArray(exported)) throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
650
+ if (!exported || typeof exported !== "object" || Array.isArray(exported)) {
651
+ throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
652
+ }
284
653
  for (const key in exported) {
285
654
  const found = getTamaguiComponent(key, exported[key]);
286
655
  if (found) {
@@ -294,13 +663,21 @@ function getComponentStaticConfigByName(name, exported) {
294
663
  }
295
664
  }
296
665
  } catch (err) {
297
- process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.error(`Tamagui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`), console.error(err));
666
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
667
+ console.error(`Tamagui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
668
+ console.error(err);
669
+ }
298
670
  }
299
671
  return components;
300
672
  }
301
673
  function getTamaguiComponent(name, Component) {
302
- if (name[0].toUpperCase() !== name[0]) return;
303
- if (Component?.staticConfig) return Component;
674
+ if (name[0].toUpperCase() !== name[0]) {
675
+ return;
676
+ }
677
+ const staticConfig = Component?.staticConfig;
678
+ if (staticConfig) {
679
+ return Component;
680
+ }
304
681
  }
305
682
  function interopDefaultExport(mod) {
306
683
  return mod?.default ?? mod;
@@ -308,22 +685,32 @@ function interopDefaultExport(mod) {
308
685
  const cacheComponents = {};
309
686
  function transformAddExports(ast) {
310
687
  const usedNames = /* @__PURE__ */new Set();
311
- return (0, import_traverse.default)(ast, {
688
+ (0, import_traverse.default)(ast, {
312
689
  ExportNamedDeclaration(nodePath) {
313
- if (nodePath.node.specifiers) for (const spec of nodePath.node.specifiers) usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value);
690
+ if (nodePath.node.specifiers) {
691
+ for (const spec of nodePath.node.specifiers) {
692
+ usedNames.add(t.isIdentifier(spec.exported) ? spec.exported.name : spec.exported.value);
693
+ }
694
+ }
314
695
  }
315
- }), (0, import_traverse.default)(ast, {
696
+ });
697
+ (0, import_traverse.default)(ast, {
316
698
  VariableDeclaration(nodePath) {
317
699
  if (!t.isProgram(nodePath.parent)) return;
318
700
  const decs = nodePath.node.declarations;
319
701
  if (decs.length > 1) return;
320
702
  const [dec] = decs;
321
- t.isIdentifier(dec.id) && dec.init && (usedNames.has(dec.id.name) || (usedNames.add(dec.id.name), nodePath.replaceWith(t.exportNamedDeclaration(t.variableDeclaration("let", [dec]), [t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name))]))));
703
+ if (!t.isIdentifier(dec.id)) return;
704
+ if (!dec.init) return;
705
+ if (usedNames.has(dec.id.name)) return;
706
+ usedNames.add(dec.id.name);
707
+ nodePath.replaceWith(t.exportNamedDeclaration(t.variableDeclaration("let", [dec]), [t.exportSpecifier(t.identifier(dec.id.name), t.identifier(dec.id.name))]));
322
708
  }
323
- }), (0, import_generator.default)(ast, {
324
- concise: !1,
709
+ });
710
+ return (0, import_generator.default)(ast, {
711
+ concise: false,
325
712
  filename: "test.tsx",
326
- retainLines: !1,
327
- sourceMaps: !1
713
+ retainLines: false,
714
+ sourceMaps: false
328
715
  }).code;
329
716
  }