@tamagui/static 3.0.0-beta.765.1 → 3.0.0-beta.804.1
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.
- package/dist/cjs/compiler.cjs +12 -1
- package/dist/cjs/compilerHost.cjs +642 -315
- package/dist/cjs/extractor/bundle.cjs +41 -17
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +6 -1
- package/dist/cjs/extractor/loadTamagui.cjs +115 -64
- package/dist/esm/compiler.mjs +12 -1
- package/dist/esm/compiler.mjs.map +1 -1
- package/dist/esm/compilerHost.mjs +644 -316
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/dist/esm/extractor/bundle.mjs +39 -16
- package/dist/esm/extractor/bundle.mjs.map +1 -1
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +6 -1
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -1
- package/dist/esm/extractor/loadTamagui.mjs +115 -64
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
- package/package.json +19 -19
- package/src/compiler.ts +16 -1
- package/src/compilerHost.ts +282 -93
- package/src/extractor/bundle.ts +7 -1
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +9 -2
- package/types/compiler.d.ts.map +1 -1
- package/types/compilerHost.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
|
@@ -38,22 +38,33 @@ const esbuildLoaderConfig = {
|
|
|
38
38
|
const dataExtensions = Object.keys(esbuildLoaderConfig).filter((k) => esbuildLoaderConfig[k] === "file" || esbuildLoaderConfig[k] === "dataurl").map((k) => k.slice(1));
|
|
39
39
|
const esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join("|")})$`, "i");
|
|
40
40
|
function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangerouslyIgnoreStaticEvaluationModules = [], define: callerDefine, ...options }, platform, aliases) {
|
|
41
|
-
if (process.env.DEBUG?.startsWith("tamagui"))
|
|
41
|
+
if (process.env.DEBUG?.startsWith("tamagui")) {
|
|
42
|
+
console.info(`Building`, entryPoints);
|
|
43
|
+
}
|
|
42
44
|
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map((entry) => resolveWebOrNativeSpecificEntry(entry, platform));
|
|
43
45
|
const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
|
|
44
|
-
|
|
46
|
+
const platformDefines = platform === "web" ? {
|
|
47
|
+
"process.env.TAMAGUI_TARGET": "\"web\"",
|
|
48
|
+
"process.env.EXPO_OS": "\"web\""
|
|
49
|
+
} : { "process.env.TAMAGUI_TARGET": "\"native\"" };
|
|
50
|
+
const res = {
|
|
45
51
|
bundle: true,
|
|
46
52
|
entryPoints: resolvedEntryPoints,
|
|
47
53
|
format: detectedFormat,
|
|
48
54
|
define: {
|
|
49
|
-
...
|
|
50
|
-
"process.env.TAMAGUI_TARGET": "\"web\"",
|
|
51
|
-
"process.env.EXPO_OS": "\"web\""
|
|
52
|
-
} : { "process.env.TAMAGUI_TARGET": "\"native\"" },
|
|
55
|
+
...platformDefines,
|
|
53
56
|
...callerDefine
|
|
54
57
|
},
|
|
58
|
+
...platform === "native" ? {
|
|
59
|
+
conditions: ["react-native"],
|
|
60
|
+
mainFields: [
|
|
61
|
+
"react-native",
|
|
62
|
+
"module",
|
|
63
|
+
"main"
|
|
64
|
+
]
|
|
65
|
+
} : {},
|
|
55
66
|
...detectedFormat === "esm" ? {
|
|
56
|
-
mainFields: ["module", "main"],
|
|
67
|
+
...platform === "web" ? { mainFields: ["module", "main"] } : {},
|
|
57
68
|
banner: { js: "import { createRequire as __cr } from \"module\"; const require = __cr(import.meta.url);" }
|
|
58
69
|
} : {},
|
|
59
70
|
target: "node24",
|
|
@@ -90,8 +101,12 @@ function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangero
|
|
|
90
101
|
setup(build) {
|
|
91
102
|
const isCjs = build.initialOptions.format === "cjs" || !build.initialOptions.format;
|
|
92
103
|
build.onLoad({ filter: /\.(ts|tsx|js|jsx|mjs)$/ }, (args) => {
|
|
93
|
-
if (!isCjs)
|
|
94
|
-
|
|
104
|
+
if (!isCjs) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
if (args.path.includes("node_modules") && !args.path.includes("@tamagui")) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
95
110
|
let contents = readFileSync(args.path, "utf8");
|
|
96
111
|
let modified = false;
|
|
97
112
|
if (contents.includes("import.meta.env")) {
|
|
@@ -106,10 +121,12 @@ function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangero
|
|
|
106
121
|
contents = contents.replace(/import\.meta\.main/g, "false");
|
|
107
122
|
modified = true;
|
|
108
123
|
}
|
|
109
|
-
if (modified)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
if (modified) {
|
|
125
|
+
return {
|
|
126
|
+
contents,
|
|
127
|
+
loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
113
130
|
return null;
|
|
114
131
|
});
|
|
115
132
|
}
|
|
@@ -118,7 +135,9 @@ function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangero
|
|
|
118
135
|
name: "external",
|
|
119
136
|
setup(build) {
|
|
120
137
|
build.onResolve({ filter: /^@tamagui\/(core|web)$/ }, (args) => {
|
|
121
|
-
if (args.kind === "entry-point")
|
|
138
|
+
if (args.kind === "entry-point") {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
122
141
|
return {
|
|
123
142
|
path: platform === "native" ? "@tamagui/core/native" : args.path,
|
|
124
143
|
external: true
|
|
@@ -148,12 +167,16 @@ function getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangero
|
|
|
148
167
|
],
|
|
149
168
|
...options
|
|
150
169
|
};
|
|
170
|
+
return res;
|
|
151
171
|
}
|
|
152
172
|
function detectEntryFormat(entryPoint) {
|
|
153
|
-
if (entryPoint.startsWith("/") || entryPoint.startsWith("."))
|
|
173
|
+
if (entryPoint.startsWith("/") || entryPoint.startsWith(".")) {
|
|
174
|
+
return detectModuleFormat(entryPoint);
|
|
175
|
+
}
|
|
154
176
|
try {
|
|
155
177
|
const pkgJsonPath = nodeRequire.resolve(entryPoint + "/package.json");
|
|
156
|
-
|
|
178
|
+
const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
179
|
+
return pkg.type === "module" ? "esm" : "cjs";
|
|
157
180
|
} catch {
|
|
158
181
|
return "cjs";
|
|
159
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","names":[],"sources":["esm/extractor/bundle.js"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport esbuild from \"esbuild\";\nimport FS from \"fs-extra\";\nimport { staticEvaluationIgnorePlugin } from \"../staticEvaluationIgnoredModules\";\nimport { detectModuleFormat } from \"./detectModuleFormat\";\nimport { esbuildAliasPlugin } from \"./esbuildAliasPlugin\";\nimport { resolveWebOrNativeSpecificEntry } from \"./loadTamagui\";\nimport { TsconfigPathsPlugin } from \"./esbuildTsconfigPaths\";\n\nconst nodeRequire = createRequire(typeof __filename === \"string\" ? __filename : import.meta.url);\nconst esbuildLoaderConfig = {\n\t\".js\": \"jsx\",\n\t\".png\": \"dataurl\",\n\t\".jpg\": \"dataurl\",\n\t\".jpeg\": \"dataurl\",\n\t\".svg\": \"dataurl\",\n\t\".gif\": \"dataurl\",\n\t\".webp\": \"dataurl\",\n\t\".woff2\": \"dataurl\",\n\t\".woff\": \"dataurl\",\n\t\".eot\": \"dataurl\",\n\t\".otf\": \"dataurl\",\n\t\".ttf\": \"dataurl\",\n\t\".mp4\": \"file\",\n\t\".mpeg4\": \"file\",\n\t\".mov\": \"file\",\n\t\".avif\": \"file\",\n\t\".wmv\": \"file\",\n\t\".webm\": \"file\",\n\t\".wav\": \"file\",\n\t\".aac\": \"file\",\n\t\".ogg\": \"file\",\n\t\".flac\": \"file\",\n\t\".node\": \"empty\"\n};\nconst dataExtensions = Object.keys(esbuildLoaderConfig).filter((k) => esbuildLoaderConfig[k] === \"file\" || esbuildLoaderConfig[k] === \"dataurl\").map((k) => k.slice(1));\nconst esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join(\"|\")})$`, \"i\");\nfunction getESBuildConfig({ entryPoints, resolvePlatformSpecificEntries, dangerouslyIgnoreStaticEvaluationModules = [], define: callerDefine, ...options }, platform, aliases) {\n\tif (process.env.DEBUG?.startsWith(\"tamagui\")) console.info(`Building`, entryPoints);\n\tconst resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map((entry) => resolveWebOrNativeSpecificEntry(entry, platform));\n\tconst detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);\n\treturn {\n\t\tbundle: true,\n\t\tentryPoints: resolvedEntryPoints,\n\t\tformat: detectedFormat,\n\t\tdefine: {\n\t\t\t...platform === \"web\" ? {\n\t\t\t\t\"process.env.TAMAGUI_TARGET\": \"\\\"web\\\"\",\n\t\t\t\t\"process.env.EXPO_OS\": \"\\\"web\\\"\"\n\t\t\t} : { \"process.env.TAMAGUI_TARGET\": \"\\\"native\\\"\" },\n\t\t\t...callerDefine\n\t\t},\n\t\t...detectedFormat === \"esm\" ? {\n\t\t\tmainFields: [\"module\", \"main\"],\n\t\t\tbanner: { js: \"import { createRequire as __cr } from \\\"module\\\"; const require = __cr(import.meta.url);\" }\n\t\t} : {},\n\t\ttarget: \"node24\",\n\t\tjsx: \"transform\",\n\t\tjsxFactory: \"react\",\n\t\tallowOverwrite: true,\n\t\tkeepNames: true,\n\t\tresolveExtensions: [\n\t\t\t...platform === \"web\" ? [\n\t\t\t\t\".web.tsx\",\n\t\t\t\t\".web.ts\",\n\t\t\t\t\".web.jsx\",\n\t\t\t\t\".web.js\"\n\t\t\t] : [\n\t\t\t\t\".native.tsx\",\n\t\t\t\t\".native.ts\",\n\t\t\t\t\".native.jsx\",\n\t\t\t\t\".native.js\"\n\t\t\t],\n\t\t\t\".tsx\",\n\t\t\t\".ts\",\n\t\t\t\".jsx\",\n\t\t\t\".js\"\n\t\t],\n\t\tplatform: \"node\",\n\t\ttsconfigRaw: { compilerOptions: { jsx: \"react-jsx\" } },\n\t\tloader: esbuildLoaderConfig,\n\t\tlogLevel: \"warning\",\n\t\tplugins: [\n\t\t\tTsconfigPathsPlugin(),\n\t\t\tstaticEvaluationIgnorePlugin(dangerouslyIgnoreStaticEvaluationModules),\n\t\t\t{\n\t\t\t\tname: \"handle-esm-features\",\n\t\t\t\tsetup(build) {\n\t\t\t\t\tconst isCjs = build.initialOptions.format === \"cjs\" || !build.initialOptions.format;\n\t\t\t\t\tbuild.onLoad({ filter: /\\.(ts|tsx|js|jsx|mjs)$/ }, (args) => {\n\t\t\t\t\t\tif (!isCjs) return null;\n\t\t\t\t\t\tif (args.path.includes(\"node_modules\") && !args.path.includes(\"@tamagui\")) return null;\n\t\t\t\t\t\tlet contents = readFileSync(args.path, \"utf8\");\n\t\t\t\t\t\tlet modified = false;\n\t\t\t\t\t\tif (contents.includes(\"import.meta.env\")) {\n\t\t\t\t\t\t\tcontents = contents.replace(/import\\.meta\\.env/g, \"process.env\");\n\t\t\t\t\t\t\tmodified = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (contents.includes(\"import.meta.url\")) {\n\t\t\t\t\t\t\tcontents = contents.replace(/import\\.meta\\.url/g, \"\\\"\\\"\");\n\t\t\t\t\t\t\tmodified = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (contents.includes(\"import.meta.main\")) {\n\t\t\t\t\t\t\tcontents = contents.replace(/import\\.meta\\.main/g, \"false\");\n\t\t\t\t\t\t\tmodified = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (modified) return {\n\t\t\t\t\t\t\tcontents,\n\t\t\t\t\t\t\tloader: args.path.endsWith(\".tsx\") ? \"tsx\" : args.path.endsWith(\".ts\") ? \"ts\" : args.path.endsWith(\".jsx\") ? \"jsx\" : \"js\"\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"external\",\n\t\t\t\tsetup(build) {\n\t\t\t\t\tbuild.onResolve({ filter: /^@tamagui\\/(core|web)$/ }, (args) => {\n\t\t\t\t\t\tif (args.kind === \"entry-point\") return null;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpath: platform === \"native\" ? \"@tamagui/core/native\" : args.path,\n\t\t\t\t\t\t\texternal: true\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t\tbuild.onResolve({ filter: /react-native\\/package.json$/ }, () => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpath: \"react-native/package.json\",\n\t\t\t\t\t\t\texternal: true\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t\tbuild.onResolve({ filter: /^(react-native|react-native\\/.*)$/ }, (args) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpath: args.path.replace(/^react-native/, \"@tamagui/react-native-web-lite\"),\n\t\t\t\t\t\t\texternal: true\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t\tbuild.onResolve({ filter: /^(framer-motion|motion)/ }, (args) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\texternal: true\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tesbuildAliasPlugin({ ...aliases })\n\t\t],\n\t\t...options\n\t};\n}\nfunction detectEntryFormat(entryPoint) {\n\tif (entryPoint.startsWith(\"/\") || entryPoint.startsWith(\".\")) return detectModuleFormat(entryPoint);\n\ttry {\n\t\tconst pkgJsonPath = nodeRequire.resolve(entryPoint + \"/package.json\");\n\t\treturn JSON.parse(readFileSync(pkgJsonPath, \"utf-8\")).type === \"module\" ? \"esm\" : \"cjs\";\n\t} catch {\n\t\treturn \"cjs\";\n\t}\n}\nasync function esbundleTamaguiConfig(props, platform, aliases) {\n\tconst config = getESBuildConfig(props, platform, aliases);\n\tconst tmpFile = `${props.outfile}.tmp.${process.pid}-${randomBytes(6).toString(\"hex\")}`;\n\tconst result = await esbuild.build({\n\t\t...config,\n\t\toutfile: tmpFile\n\t});\n\tawait FS.rename(tmpFile, props.outfile);\n\treturn result;\n}\n\nexport { esbuildIgnoreFilesRegex, esbuildLoaderConfig, esbundleTamaguiConfig };"],"mappings":";;;;;;;;;;;;AAWA,MAAM,cAAc,cAAc,OAAO,eAAe,WAAW,aAAa,YAAY,GAAG;AAC/F,MAAM,sBAAsB;CAC3B,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;AACV;AACA,MAAM,iBAAiB,OAAO,KAAK,mBAAmB,CAAC,CAAC,QAAQ,MAAM,oBAAoB,OAAO,UAAU,oBAAoB,OAAO,SAAS,CAAC,CAAC,KAAK,MAAM,EAAE,MAAM,CAAC,CAAC;AACtK,MAAM,0BAA0B,IAAI,OAAO,KAAK,eAAe,KAAK,GAAG,EAAE,KAAK,GAAG;AACjF,SAAS,iBAAiB,EAAE,aAAa,gCAAgC,2CAA2C,CAAC,GAAG,QAAQ,cAAc,GAAG,WAAW,UAAU,SAAS;CAC9K,IAAI,QAAQ,IAAI,OAAO,WAAW,SAAS,GAAG,Q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AO,UAAU,SAAS;CAC9D,MAAM,SAAS,iBAAiB,OAAO,UAAU,OAAO;CACxD,MAAM,UAAU,GAAG,MAAM,QAAQ,OAAO,QAAQ,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK;CACpF,MAAM,SAAS,MAAM,QAAQ,MAAM;EAClC,GAAG;EACH,SAAS;CACV,CAAC;CACD,MAAM,GAAG,OAAO,SAAS,MAAM,OAAO;CACtC,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"bundle.js","names":[],"sources":["esm/extractor/bundle.js"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport esbuild from \"esbuild\";\nimport FS from \"fs-extra\";\nimport { staticEvaluationIgnorePlugin } from \"../staticEvaluationIgnoredModules\";\nimport { detectModuleFormat } from \"./detectModuleFormat\";\nimport { esbuildAliasPlugin } from \"./esbuildAliasPlugin\";\nimport { resolveWebOrNativeSpecificEntry } from \"./loadTamagui\";\nimport { TsconfigPathsPlugin } from \"./esbuildTsconfigPaths\";\nconst nodeRequire = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst esbuildLoaderConfig = {\n \".js\": \"jsx\",\n \".png\": \"dataurl\",\n \".jpg\": \"dataurl\",\n \".jpeg\": \"dataurl\",\n \".svg\": \"dataurl\",\n \".gif\": \"dataurl\",\n \".webp\": \"dataurl\",\n \".woff2\": \"dataurl\",\n \".woff\": \"dataurl\",\n \".eot\": \"dataurl\",\n \".otf\": \"dataurl\",\n \".ttf\": \"dataurl\",\n \".mp4\": \"file\",\n \".mpeg4\": \"file\",\n \".mov\": \"file\",\n \".avif\": \"file\",\n \".wmv\": \"file\",\n \".webm\": \"file\",\n \".wav\": \"file\",\n \".aac\": \"file\",\n \".ogg\": \"file\",\n \".flac\": \"file\",\n \".node\": \"empty\"\n};\nconst dataExtensions = Object.keys(esbuildLoaderConfig).filter(\n (k) => esbuildLoaderConfig[k] === \"file\" || esbuildLoaderConfig[k] === \"dataurl\"\n).map((k) => k.slice(1));\nconst esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join(\"|\")})$`, \"i\");\nfunction getESBuildConfig({\n entryPoints,\n resolvePlatformSpecificEntries,\n dangerouslyIgnoreStaticEvaluationModules = [],\n define: callerDefine,\n ...options\n}, platform, aliases) {\n if (process.env.DEBUG?.startsWith(\"tamagui\")) {\n console.info(`Building`, entryPoints);\n }\n const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map((entry) => resolveWebOrNativeSpecificEntry(entry, platform));\n const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);\n const platformDefines = platform === \"web\" ? {\n \"process.env.TAMAGUI_TARGET\": '\"web\"',\n \"process.env.EXPO_OS\": '\"web\"'\n } : {\n \"process.env.TAMAGUI_TARGET\": '\"native\"'\n // EXPO_OS doesn't have a useful \"native\" value (it's ios/android),\n // so leave it alone here and let the consumer set it if needed.\n };\n const res = {\n bundle: true,\n entryPoints: resolvedEntryPoints,\n format: detectedFormat,\n define: {\n ...platformDefines,\n ...callerDefine\n },\n ...platform === \"native\" ? {\n conditions: [\"react-native\"],\n mainFields: [\"react-native\", \"module\", \"main\"]\n } : {},\n // for ESM: prefer \"module\" field for resolution, add require() shim for bundled CJS deps\n ...detectedFormat === \"esm\" ? {\n ...platform === \"web\" ? { mainFields: [\"module\", \"main\"] } : {},\n banner: {\n js: 'import { createRequire as __cr } from \"module\"; const require = __cr(import.meta.url);'\n }\n } : {},\n target: \"node24\",\n jsx: \"transform\",\n jsxFactory: \"react\",\n allowOverwrite: true,\n keepNames: true,\n resolveExtensions: [\n ...platform === \"web\" ? [\".web.tsx\", \".web.ts\", \".web.jsx\", \".web.js\"] : [\".native.tsx\", \".native.ts\", \".native.jsx\", \".native.js\"],\n \".tsx\",\n \".ts\",\n \".jsx\",\n \".js\"\n ],\n platform: \"node\",\n tsconfigRaw: {\n compilerOptions: {\n jsx: \"react-jsx\"\n }\n },\n loader: esbuildLoaderConfig,\n logLevel: \"warning\",\n plugins: [\n TsconfigPathsPlugin(),\n staticEvaluationIgnorePlugin(dangerouslyIgnoreStaticEvaluationModules),\n // handle ESM-only features that can't be used with CJS output\n {\n name: \"handle-esm-features\",\n setup(build) {\n const isCjs = build.initialOptions.format === \"cjs\" || !build.initialOptions.format;\n build.onLoad({ filter: /\\.(ts|tsx|js|jsx|mjs)$/ }, (args) => {\n if (!isCjs) {\n return null;\n }\n if (args.path.includes(\"node_modules\") && !args.path.includes(\"@tamagui\")) {\n return null;\n }\n let contents = readFileSync(args.path, \"utf8\");\n let modified = false;\n if (contents.includes(\"import.meta.env\")) {\n contents = contents.replace(/import\\.meta\\.env/g, \"process.env\");\n modified = true;\n }\n if (contents.includes(\"import.meta.url\")) {\n contents = contents.replace(/import\\.meta\\.url/g, '\"\"');\n modified = true;\n }\n if (contents.includes(\"import.meta.main\")) {\n contents = contents.replace(/import\\.meta\\.main/g, \"false\");\n modified = true;\n }\n if (modified) {\n return {\n contents,\n loader: args.path.endsWith(\".tsx\") ? \"tsx\" : args.path.endsWith(\".ts\") ? \"ts\" : args.path.endsWith(\".jsx\") ? \"jsx\" : \"js\"\n };\n }\n return null;\n });\n }\n },\n {\n name: \"external\",\n setup(build) {\n build.onResolve({ filter: /^@tamagui\\/(core|web)$/ }, (args) => {\n if (args.kind === \"entry-point\") {\n return null;\n }\n return {\n path: platform === \"native\" ? \"@tamagui/core/native\" : args.path,\n external: true\n };\n });\n build.onResolve({ filter: /react-native\\/package.json$/ }, () => {\n return {\n path: \"react-native/package.json\",\n external: true\n };\n });\n build.onResolve({ filter: /^(react-native|react-native\\/.*)$/ }, (args) => {\n return {\n path: args.path.replace(/^react-native/, \"@tamagui/react-native-web-lite\"),\n external: true\n };\n });\n build.onResolve({ filter: /^(framer-motion|motion)/ }, (args) => {\n return {\n path: args.path,\n external: true\n };\n });\n }\n },\n esbuildAliasPlugin({\n ...aliases\n })\n ],\n ...options\n };\n return res;\n}\nfunction detectEntryFormat(entryPoint) {\n if (entryPoint.startsWith(\"/\") || entryPoint.startsWith(\".\")) {\n return detectModuleFormat(entryPoint);\n }\n try {\n const pkgJsonPath = nodeRequire.resolve(entryPoint + \"/package.json\");\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf-8\"));\n return pkg.type === \"module\" ? \"esm\" : \"cjs\";\n } catch {\n return \"cjs\";\n }\n}\nasync function esbundleTamaguiConfig(props, platform, aliases) {\n const config = getESBuildConfig(props, platform, aliases);\n const tmpFile = `${props.outfile}.tmp.${process.pid}-${randomBytes(6).toString(\"hex\")}`;\n const result = await esbuild.build({\n ...config,\n outfile: tmpFile\n });\n await FS.rename(tmpFile, props.outfile);\n return result;\n}\nexport {\n esbuildIgnoreFilesRegex,\n esbuildLoaderConfig,\n esbundleTamaguiConfig\n};\n//# sourceMappingURL=bundle.js.map\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,cAAc,cAClB,OAAO,eAAe,WAAW,aAAa,YAAY,GAC5D;AACA,MAAM,sBAAsB;CAC1B,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;AACX;AACA,MAAM,iBAAiB,OAAO,KAAK,mBAAmB,CAAC,CAAC,QACrD,MAAM,oBAAoB,OAAO,UAAU,oBAAoB,OAAO,SACzE,CAAC,CAAC,KAAK,MAAM,EAAE,MAAM,CAAC,CAAC;AACvB,MAAM,0BAA0B,IAAI,OAAO,KAAK,eAAe,KAAK,GAAG,EAAE,KAAK,GAAG;AACjF,SAAS,iBAAiB,EACxB,aACA,gCACA,2CAA2C,CAAC,GAC5C,QAAQ,cACR,GAAG,W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AACA,SAAS,kBAAkB,YAAY;CACrC,IAAI,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,GAAG,GAAG;EAC5D,OAAO,mBAAmB,UAAU;CACtC;CACA,IAAI;EACF,MAAM,cAAc,YAAY,QAAQ,aAAa,eAAe;EACpE,MAAM,MAAM,KAAK,MAAM,aAAa,aAAa,OAAO,CAAC;EACzD,OAAO,IAAI,SAAS,WAAW,QAAQ;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AACA,eAAe,sBAAsB,OAAO,UAAU,SAAS;CAC7D,MAAM,SAAS,iBAAiB,OAAO,UAAU,OAAO;CACxD,MAAM,UAAU,GAAG,MAAM,QAAQ,OAAO,QAAQ,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,KAAK;CACpF,MAAM,SAAS,MAAM,QAAQ,MAAM;EACjC,GAAG;EACH,SAAS;CACX,CAAC;CACD,MAAM,GAAG,OAAO,SAAS,MAAM,OAAO;CACtC,OAAO;AACT"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
4
|
|
|
4
5
|
function getTamaguiConfigPathFromOptionsConfig(config, root = process.cwd()) {
|
|
5
6
|
if (isAbsolute(config)) {
|
|
@@ -11,6 +12,10 @@ function getTamaguiConfigPathFromOptionsConfig(config, root = process.cwd()) {
|
|
|
11
12
|
return fullPath;
|
|
12
13
|
}
|
|
13
14
|
} catch {}
|
|
15
|
+
try {
|
|
16
|
+
const customRequire = createRequire(join(root, "package.json"));
|
|
17
|
+
return customRequire.resolve(config);
|
|
18
|
+
} catch {}
|
|
14
19
|
return resolve(config);
|
|
15
20
|
}
|
|
16
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTamaguiConfigPathFromOptionsConfig.js","names":[],"sources":["esm/extractor/getTamaguiConfigPathFromOptionsConfig.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getTamaguiConfigPathFromOptionsConfig.js","names":[],"sources":["esm/extractor/getTamaguiConfigPathFromOptionsConfig.js"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { statSync } from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nfunction getTamaguiConfigPathFromOptionsConfig(config, root = process.cwd()) {\n if (isAbsolute(config)) {\n return config;\n }\n const fullPath = join(root, config);\n try {\n if (statSync(fullPath).isFile()) {\n return fullPath;\n }\n } catch {\n }\n try {\n const customRequire = createRequire(join(root, \"package.json\"));\n return customRequire.resolve(config);\n } catch {\n }\n return resolve(config);\n}\nexport {\n getTamaguiConfigPathFromOptionsConfig\n};\n//# sourceMappingURL=getTamaguiConfigPathFromOptionsConfig.js.map\n"],"mappings":";;;;;AAGA,SAAS,sCAAsC,QAAQ,OAAO,QAAQ,IAAI,GAAG;CAC3E,IAAI,WAAW,MAAM,GAAG;EACtB,OAAO;CACT;CACA,MAAM,WAAW,KAAK,MAAM,MAAM;CAClC,IAAI;EACF,IAAI,SAAS,QAAQ,CAAC,CAAC,OAAO,GAAG;GAC/B,OAAO;EACT;CACF,QAAQ,CACR;CACA,IAAI;EACF,MAAM,gBAAgB,cAAc,KAAK,MAAM,cAAc,CAAC;EAC9D,OAAO,cAAc,QAAQ,MAAM;CACrC,QAAQ,CACR;CACA,OAAO,QAAQ,MAAM;AACvB"}
|
|
@@ -11,7 +11,7 @@ import { generateTamaguiThemes, regenerateConfig, regenerateConfigSync } from ".
|
|
|
11
11
|
|
|
12
12
|
const nodeRequire = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
13
13
|
const getFilledOptions = (propsIn) => ({
|
|
14
|
-
platform: "web",
|
|
14
|
+
platform: process.env.TAMAGUI_TARGET || "web",
|
|
15
15
|
config: "tamagui.config.ts",
|
|
16
16
|
components: ["tamagui"],
|
|
17
17
|
...propsIn
|
|
@@ -22,14 +22,18 @@ async function loadTamagui(propsIn, rebuild = false) {
|
|
|
22
22
|
isLoadingPromise = (async () => {
|
|
23
23
|
const props = getFilledOptions(propsIn);
|
|
24
24
|
const bundleInfo = await getBundledConfig(props, rebuild);
|
|
25
|
-
if (!bundleInfo)
|
|
25
|
+
if (!bundleInfo) {
|
|
26
|
+
throw new Error(`[tamagui] The config and component bundle completed without a project result`);
|
|
27
|
+
}
|
|
26
28
|
await generateThemesAndLog(props, rebuild);
|
|
27
29
|
const maybeTamaguiConfig = bundleInfo.tamaguiConfig;
|
|
28
30
|
if (maybeTamaguiConfig && !maybeTamaguiConfig.parsed) {
|
|
29
31
|
const { createTamagui } = requireTamaguiCore(props.platform || "web");
|
|
30
32
|
bundleInfo.tamaguiConfig = createTamagui(bundleInfo.tamaguiConfig);
|
|
31
33
|
}
|
|
32
|
-
if (!hasBundledConfigChanged())
|
|
34
|
+
if (!hasBundledConfigChanged()) {
|
|
35
|
+
return bundleInfo;
|
|
36
|
+
}
|
|
33
37
|
await regenerateConfig(props, bundleInfo);
|
|
34
38
|
return bundleInfo;
|
|
35
39
|
})();
|
|
@@ -44,25 +48,35 @@ async function loadTamaguiFromModules(propsIn, evaluated) {
|
|
|
44
48
|
await generateThemesAndLog(props);
|
|
45
49
|
const configModule = evaluated.config;
|
|
46
50
|
let tamaguiConfig = configModule.default || configModule.config || configModule;
|
|
47
|
-
if ("config" in tamaguiConfig && tamaguiConfig.config && !("tokens" in tamaguiConfig))
|
|
48
|
-
|
|
51
|
+
if ("config" in tamaguiConfig && tamaguiConfig.config && !("tokens" in tamaguiConfig)) {
|
|
52
|
+
tamaguiConfig = tamaguiConfig.config;
|
|
53
|
+
}
|
|
54
|
+
if (!tamaguiConfig) {
|
|
55
|
+
throw new Error(`The Vite module runner did not return a valid Tamagui config`);
|
|
56
|
+
}
|
|
49
57
|
const hostCore = requireTamaguiCore(props.platform || "web");
|
|
50
|
-
if (!tamaguiConfig.parsed)
|
|
51
|
-
|
|
58
|
+
if (!tamaguiConfig.parsed) {
|
|
59
|
+
tamaguiConfig = hostCore.createTamagui(tamaguiConfig);
|
|
60
|
+
} else {
|
|
61
|
+
hostCore.installTamaguiConfig(tamaguiConfig);
|
|
62
|
+
}
|
|
52
63
|
setLoadedConfig(tamaguiConfig);
|
|
64
|
+
const components = evaluated.components.map(({ moduleName, module }) => {
|
|
65
|
+
setRequireResult(moduleName, module);
|
|
66
|
+
return {
|
|
67
|
+
moduleName,
|
|
68
|
+
nameToInfo: getComponentStaticConfigByName(moduleName, module.default ?? module)
|
|
69
|
+
};
|
|
70
|
+
});
|
|
53
71
|
const projectInfo = {
|
|
54
|
-
components
|
|
55
|
-
setRequireResult(moduleName, module);
|
|
56
|
-
return {
|
|
57
|
-
moduleName,
|
|
58
|
-
nameToInfo: getComponentStaticConfigByName(moduleName, module.default ?? module)
|
|
59
|
-
};
|
|
60
|
-
}),
|
|
72
|
+
components,
|
|
61
73
|
nameToPaths: {},
|
|
62
74
|
tamaguiConfig,
|
|
63
75
|
stampSources: evaluated.stampSources
|
|
64
76
|
};
|
|
65
|
-
if (props.outputCSS)
|
|
77
|
+
if (props.outputCSS) {
|
|
78
|
+
await writeTamaguiCSS(props.outputCSS, projectInfo.tamaguiConfig);
|
|
79
|
+
}
|
|
66
80
|
return projectInfo;
|
|
67
81
|
}
|
|
68
82
|
let waiting = false;
|
|
@@ -72,11 +86,15 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
72
86
|
try {
|
|
73
87
|
waiting = true;
|
|
74
88
|
await new Promise((res) => setTimeout(res, 30));
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
const didGenerate = await generateTamaguiThemes(options, force);
|
|
90
|
+
if (didGenerate) {
|
|
91
|
+
const whitespaceBefore = ` `;
|
|
92
|
+
colorLog(Color.FgYellow, `${whitespaceBefore}\u27A1 [tamagui] generated themes: ${relative(options.root || process.cwd(), options.themeBuilder.output)}`);
|
|
77
93
|
if (options.outputCSS) {
|
|
78
94
|
const loadedConfig = getLoadedConfig();
|
|
79
|
-
if (loadedConfig)
|
|
95
|
+
if (loadedConfig) {
|
|
96
|
+
await writeTamaguiCSS(options.outputCSS, loadedConfig);
|
|
97
|
+
}
|
|
80
98
|
}
|
|
81
99
|
}
|
|
82
100
|
} finally {
|
|
@@ -93,37 +111,44 @@ async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
|
93
111
|
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
94
112
|
const root = tamaguiOptions?.root || process.cwd();
|
|
95
113
|
const absolutePath = resolve(root, buildFilePath);
|
|
96
|
-
if (fsExtra.existsSync(absolutePath))
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
if (fsExtra.existsSync(absolutePath)) {
|
|
115
|
+
try {
|
|
116
|
+
const result = await esbuild.build({
|
|
117
|
+
entryPoints: [absolutePath],
|
|
118
|
+
absWorkingDir: root,
|
|
119
|
+
bundle: true,
|
|
120
|
+
packages: "external",
|
|
121
|
+
platform: "node",
|
|
122
|
+
format: "cjs",
|
|
123
|
+
target: "node18",
|
|
124
|
+
write: false,
|
|
125
|
+
metafile: true
|
|
126
|
+
});
|
|
127
|
+
const module = { exports: {} };
|
|
128
|
+
const projectRequire = createRequire(absolutePath);
|
|
129
|
+
const code = result.outputFiles[0]?.text;
|
|
130
|
+
if (!code) throw new Error(`No output generated for ${buildFilePath}`);
|
|
131
|
+
const fn = new Function("module", "exports", "require", "process", code);
|
|
132
|
+
fn(module, module.exports, projectRequire, process);
|
|
133
|
+
const out = module.exports.default || module.exports;
|
|
134
|
+
if (!out || typeof out !== "object") {
|
|
135
|
+
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
136
|
+
}
|
|
137
|
+
const loadedOptions = {
|
|
138
|
+
...tamaguiOptions,
|
|
139
|
+
...out
|
|
140
|
+
};
|
|
141
|
+
const dependencies2 = Object.keys(result.metafile.inputs).map((input) => resolve(root, input));
|
|
142
|
+
buildConfigDependencies.set(loadedOptions, dependencies2);
|
|
143
|
+
tamaguiOptions = loadedOptions;
|
|
144
|
+
} catch (err) {
|
|
145
|
+
console.error(`[tamagui] Error loading ${buildFilePath}:`, err);
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (!tamaguiOptions) {
|
|
150
|
+
throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);
|
|
125
151
|
}
|
|
126
|
-
if (!tamaguiOptions) throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);
|
|
127
152
|
const options = {
|
|
128
153
|
config: "tamagui.config.ts",
|
|
129
154
|
components: ["tamagui", "@tamagui/core"],
|
|
@@ -135,12 +160,15 @@ async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
|
135
160
|
}
|
|
136
161
|
function loadTamaguiBuildConfigSync(tamaguiOptions) {
|
|
137
162
|
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
138
|
-
const
|
|
163
|
+
const root = tamaguiOptions?.root || process.cwd();
|
|
164
|
+
const absolutePath = resolve(root, buildFilePath);
|
|
139
165
|
if (fsExtra.existsSync(absolutePath)) {
|
|
140
166
|
const registered = registerRequire("web", { ignoredModules: tamaguiOptions?.dangerouslyIgnoreStaticEvaluationModules });
|
|
141
167
|
try {
|
|
142
168
|
const out = nodeRequire(absolutePath).default;
|
|
143
|
-
if (!out)
|
|
169
|
+
if (!out) {
|
|
170
|
+
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
171
|
+
}
|
|
144
172
|
tamaguiOptions = {
|
|
145
173
|
...tamaguiOptions,
|
|
146
174
|
...out
|
|
@@ -149,7 +177,9 @@ function loadTamaguiBuildConfigSync(tamaguiOptions) {
|
|
|
149
177
|
registered.unregister();
|
|
150
178
|
}
|
|
151
179
|
}
|
|
152
|
-
if (!tamaguiOptions)
|
|
180
|
+
if (!tamaguiOptions) {
|
|
181
|
+
throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);
|
|
182
|
+
}
|
|
153
183
|
return {
|
|
154
184
|
config: "tamagui.config.ts",
|
|
155
185
|
components: ["tamagui", "@tamagui/core"],
|
|
@@ -159,7 +189,9 @@ function loadTamaguiBuildConfigSync(tamaguiOptions) {
|
|
|
159
189
|
function loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {
|
|
160
190
|
const key = JSON.stringify(propsIn);
|
|
161
191
|
if (last[key] && !hasBundledConfigChanged()) {
|
|
162
|
-
if (!lastVersion[key] || lastVersion[key] === cacheKey)
|
|
192
|
+
if (!lastVersion[key] || lastVersion[key] === cacheKey) {
|
|
193
|
+
return last[key];
|
|
194
|
+
}
|
|
163
195
|
}
|
|
164
196
|
lastVersion[key] = cacheKey || "";
|
|
165
197
|
const props = getFilledOptions(propsIn);
|
|
@@ -175,7 +207,9 @@ function loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {
|
|
|
175
207
|
if (propsIn.config) {
|
|
176
208
|
const configPath = getTamaguiConfigPathFromOptionsConfig(propsIn.config, propsIn.root);
|
|
177
209
|
const exp = nodeRequire(configPath);
|
|
178
|
-
if (!exp)
|
|
210
|
+
if (!exp) {
|
|
211
|
+
throw new Error(`The Tamagui config module did not export a value`);
|
|
212
|
+
}
|
|
179
213
|
tamaguiConfig = exp["default"] || exp["config"] || exp;
|
|
180
214
|
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
181
215
|
const confPath = nodeRequire.resolve(configPath);
|
|
@@ -189,8 +223,12 @@ function loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {
|
|
|
189
223
|
}
|
|
190
224
|
}
|
|
191
225
|
const components = loadComponentsSync(props, forceExports);
|
|
192
|
-
if (!components)
|
|
193
|
-
|
|
226
|
+
if (!components) {
|
|
227
|
+
throw new Error(`No components loaded`);
|
|
228
|
+
}
|
|
229
|
+
if (process.env.DEBUG === "tamagui") {
|
|
230
|
+
console.info(`components`, components);
|
|
231
|
+
}
|
|
194
232
|
const info = {
|
|
195
233
|
components,
|
|
196
234
|
tamaguiConfig,
|
|
@@ -198,7 +236,9 @@ function loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {
|
|
|
198
236
|
};
|
|
199
237
|
if (tamaguiConfig) {
|
|
200
238
|
const { outputCSS } = props;
|
|
201
|
-
if (outputCSS)
|
|
239
|
+
if (outputCSS) {
|
|
240
|
+
writeTamaguiCSS(outputCSS, tamaguiConfig);
|
|
241
|
+
}
|
|
202
242
|
regenerateConfigSync(props, info);
|
|
203
243
|
}
|
|
204
244
|
last[key] = {
|
|
@@ -229,7 +269,7 @@ async function getOptions({ root = process.cwd(), tsconfigPath = "tsconfig.json"
|
|
|
229
269
|
debug,
|
|
230
270
|
tsconfigPath,
|
|
231
271
|
tamaguiOptions: {
|
|
232
|
-
platform: "web",
|
|
272
|
+
platform: process.env.TAMAGUI_TARGET || "web",
|
|
233
273
|
components: ["tamagui"],
|
|
234
274
|
...tamaguiOptions,
|
|
235
275
|
config: tamaguiOptions?.config ?? await getDefaultTamaguiConfigPath(root, tamaguiOptions?.config)
|
|
@@ -247,16 +287,23 @@ function resolveWebOrNativeSpecificEntry(entry, platform) {
|
|
|
247
287
|
const resolved = nodeRequire.resolve(entry, { paths: [workspaceRoot] });
|
|
248
288
|
const ext = extname(resolved);
|
|
249
289
|
const fileName = basename(resolved).replace(ext, "");
|
|
250
|
-
const
|
|
290
|
+
const target = platform || process.env.TAMAGUI_TARGET || "web";
|
|
291
|
+
const specificExt = target === "web" ? "web" : "native";
|
|
251
292
|
const specificFile = join(dirname(resolved), fileName + "." + specificExt + ext);
|
|
252
|
-
if (fsExtra.existsSync(specificFile))
|
|
293
|
+
if (fsExtra.existsSync(specificFile)) {
|
|
294
|
+
return specificFile;
|
|
295
|
+
}
|
|
253
296
|
return entry;
|
|
254
297
|
}
|
|
255
298
|
const defaultPaths = ["tamagui.config.ts", join("src", "tamagui.config.ts")];
|
|
256
299
|
let hasWarnedOnce = false;
|
|
257
300
|
async function getDefaultTamaguiConfigPath(root, configPath) {
|
|
258
301
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map((p) => join(root, p)))];
|
|
259
|
-
for (const path of searchPaths)
|
|
302
|
+
for (const path of searchPaths) {
|
|
303
|
+
if (await fsExtra.pathExists(path)) {
|
|
304
|
+
return path;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
260
307
|
if (!hasWarnedOnce) {
|
|
261
308
|
hasWarnedOnce = true;
|
|
262
309
|
console.warn(`Warning: couldn't find tamagui.config.ts in the following paths given configuration "${configPath}":
|
|
@@ -285,18 +332,22 @@ async function esbuildWatchFiles(entry, onChanged) {
|
|
|
285
332
|
plugins: [{
|
|
286
333
|
name: `on-rebuild`,
|
|
287
334
|
setup({ onEnd, onResolve }) {
|
|
288
|
-
|
|
335
|
+
let filter = /^[^./]|^\.[^./]|^\.\.[^/]/;
|
|
336
|
+
onResolve({ filter }, (args) => ({
|
|
289
337
|
path: args.path,
|
|
290
338
|
external: true
|
|
291
339
|
}));
|
|
292
340
|
onEnd(() => {
|
|
293
|
-
if (!hasRunOnce)
|
|
294
|
-
|
|
341
|
+
if (!hasRunOnce) {
|
|
342
|
+
hasRunOnce = true;
|
|
343
|
+
} else {
|
|
344
|
+
onChanged();
|
|
345
|
+
}
|
|
295
346
|
});
|
|
296
347
|
}
|
|
297
348
|
}]
|
|
298
349
|
});
|
|
299
|
-
context.watch();
|
|
350
|
+
void context.watch();
|
|
300
351
|
return () => {
|
|
301
352
|
context.dispose();
|
|
302
353
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTamagui.js","names":[],"sources":["esm/extractor/loadTamagui.js"],"sourcesContent":["import { basename, dirname, extname, join, relative, resolve } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport { Color, colorLog } from \"@tamagui/cli-color\";\nimport esbuild from \"esbuild\";\nimport fsExtra from \"fs-extra\";\nimport { requireTamaguiCore } from \"../helpers/requireTamaguiCore\";\nimport { getNameToPaths, registerRequire, setRequireResult } from \"../registerRequire\";\nimport { getBundledConfig, getComponentStaticConfigByName, getLoadedConfig, hasBundledConfigChanged, loadComponentsSync, setLoadedConfig, writeTamaguiCSS } from \"./bundleConfig\";\nimport { getTamaguiConfigPathFromOptionsConfig } from \"./getTamaguiConfigPathFromOptionsConfig\";\nimport { generateTamaguiThemes, regenerateConfig, regenerateConfigSync } from \"./regenerateConfig\";\n\nconst nodeRequire = createRequire(typeof __filename === \"string\" ? __filename : import.meta.url);\nconst getFilledOptions = (propsIn) => ({\n\tplatform: \"web\",\n\tconfig: \"tamagui.config.ts\",\n\tcomponents: [\"tamagui\"],\n\t...propsIn\n});\nlet isLoadingPromise;\nasync function loadTamagui(propsIn, rebuild = false) {\n\tif (isLoadingPromise) return await isLoadingPromise;\n\tisLoadingPromise = (async () => {\n\t\tconst props = getFilledOptions(propsIn);\n\t\tconst bundleInfo = await getBundledConfig(props, rebuild);\n\t\tif (!bundleInfo) throw new Error(`[tamagui] The config and component bundle completed without a project result`);\n\t\tawait generateThemesAndLog(props, rebuild);\n\t\tconst maybeTamaguiConfig = bundleInfo.tamaguiConfig;\n\t\tif (maybeTamaguiConfig && !maybeTamaguiConfig.parsed) {\n\t\t\tconst { createTamagui } = requireTamaguiCore(props.platform || \"web\");\n\t\t\tbundleInfo.tamaguiConfig = createTamagui(bundleInfo.tamaguiConfig);\n\t\t}\n\t\tif (!hasBundledConfigChanged()) return bundleInfo;\n\t\tawait regenerateConfig(props, bundleInfo);\n\t\treturn bundleInfo;\n\t})();\n\ttry {\n\t\treturn await isLoadingPromise;\n\t} finally {\n\t\tisLoadingPromise = null;\n\t}\n}\nasync function loadTamaguiFromModules(propsIn, evaluated) {\n\tconst props = getFilledOptions(propsIn);\n\tawait generateThemesAndLog(props);\n\tconst configModule = evaluated.config;\n\tlet tamaguiConfig = configModule.default || configModule.config || configModule;\n\tif (\"config\" in tamaguiConfig && tamaguiConfig.config && !(\"tokens\" in tamaguiConfig)) tamaguiConfig = tamaguiConfig.config;\n\tif (!tamaguiConfig) throw new Error(`The Vite module runner did not return a valid Tamagui config`);\n\tconst hostCore = requireTamaguiCore(props.platform || \"web\");\n\tif (!tamaguiConfig.parsed) tamaguiConfig = hostCore.createTamagui(tamaguiConfig);\n\telse hostCore.installTamaguiConfig(tamaguiConfig);\n\tsetLoadedConfig(tamaguiConfig);\n\tconst projectInfo = {\n\t\tcomponents: evaluated.components.map(({ moduleName, module }) => {\n\t\t\tsetRequireResult(moduleName, module);\n\t\t\treturn {\n\t\t\t\tmoduleName,\n\t\t\t\tnameToInfo: getComponentStaticConfigByName(moduleName, module.default ?? module)\n\t\t\t};\n\t\t}),\n\t\tnameToPaths: {},\n\t\ttamaguiConfig,\n\t\tstampSources: evaluated.stampSources\n\t};\n\tif (props.outputCSS) await writeTamaguiCSS(props.outputCSS, projectInfo.tamaguiConfig);\n\treturn projectInfo;\n}\nlet waiting = false;\nconst generateThemesAndLog = async (options, force = false) => {\n\tif (waiting) return;\n\tif (!options.themeBuilder) return;\n\ttry {\n\t\twaiting = true;\n\t\tawait new Promise((res) => setTimeout(res, 30));\n\t\tif (await generateTamaguiThemes(options, force)) {\n\t\t\tcolorLog(Color.FgYellow, ` \\u27A1 [tamagui] generated themes: ${relative(options.root || process.cwd(), options.themeBuilder.output)}`);\n\t\t\tif (options.outputCSS) {\n\t\t\t\tconst loadedConfig = getLoadedConfig();\n\t\t\t\tif (loadedConfig) await writeTamaguiCSS(options.outputCSS, loadedConfig);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\twaiting = false;\n\t}\n};\nconst last = {};\nconst lastVersion = {};\nconst buildConfigDependencies = /* @__PURE__ */ new WeakMap();\nfunction getTamaguiBuildConfigDependencies(options) {\n\treturn buildConfigDependencies.get(options) ?? [];\n}\nasync function loadTamaguiBuildConfigAsync(tamaguiOptions) {\n\tconst buildFilePath = tamaguiOptions?.buildFile ?? \"./tamagui.build.ts\";\n\tconst root = tamaguiOptions?.root || process.cwd();\n\tconst absolutePath = resolve(root, buildFilePath);\n\tif (fsExtra.existsSync(absolutePath)) try {\n\t\tconst result = await esbuild.build({\n\t\t\tentryPoints: [absolutePath],\n\t\t\tabsWorkingDir: root,\n\t\t\tbundle: true,\n\t\t\tpackages: \"external\",\n\t\t\tplatform: \"node\",\n\t\t\tformat: \"cjs\",\n\t\t\ttarget: \"node18\",\n\t\t\twrite: false,\n\t\t\tmetafile: true\n\t\t});\n\t\tconst module = { exports: {} };\n\t\tconst projectRequire = createRequire(absolutePath);\n\t\tconst code = result.outputFiles[0]?.text;\n\t\tif (!code) throw new Error(`No output generated for ${buildFilePath}`);\n\t\tnew Function(\"module\", \"exports\", \"require\", \"process\", code)(module, module.exports, projectRequire, process);\n\t\tconst out = module.exports.default || module.exports;\n\t\tif (!out || typeof out !== \"object\") throw new Error(`No default export found in ${buildFilePath}: ${out}`);\n\t\tconst loadedOptions = {\n\t\t\t...tamaguiOptions,\n\t\t\t...out\n\t\t};\n\t\tconst dependencies2 = Object.keys(result.metafile.inputs).map((input) => resolve(root, input));\n\t\tbuildConfigDependencies.set(loadedOptions, dependencies2);\n\t\ttamaguiOptions = loadedOptions;\n\t} catch (err) {\n\t\tconsole.error(`[tamagui] Error loading ${buildFilePath}:`, err);\n\t\tthrow err;\n\t}\n\tif (!tamaguiOptions) throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);\n\tconst options = {\n\t\tconfig: \"tamagui.config.ts\",\n\t\tcomponents: [\"tamagui\", \"@tamagui/core\"],\n\t\t...tamaguiOptions\n\t};\n\tconst dependencies = buildConfigDependencies.get(tamaguiOptions);\n\tif (dependencies) buildConfigDependencies.set(options, dependencies);\n\treturn options;\n}\nfunction loadTamaguiBuildConfigSync(tamaguiOptions) {\n\tconst buildFilePath = tamaguiOptions?.buildFile ?? \"./tamagui.build.ts\";\n\tconst absolutePath = resolve(tamaguiOptions?.root || process.cwd(), buildFilePath);\n\tif (fsExtra.existsSync(absolutePath)) {\n\t\tconst registered = registerRequire(\"web\", { ignoredModules: tamaguiOptions?.dangerouslyIgnoreStaticEvaluationModules });\n\t\ttry {\n\t\t\tconst out = nodeRequire(absolutePath).default;\n\t\t\tif (!out) throw new Error(`No default export found in ${buildFilePath}: ${out}`);\n\t\t\ttamaguiOptions = {\n\t\t\t\t...tamaguiOptions,\n\t\t\t\t...out\n\t\t\t};\n\t\t} finally {\n\t\t\tregistered.unregister();\n\t\t}\n\t}\n\tif (!tamaguiOptions) throw new Error(`No tamagui build options found either via input props or at tamagui.build.ts`);\n\treturn {\n\t\tconfig: \"tamagui.config.ts\",\n\t\tcomponents: [\"tamagui\", \"@tamagui/core\"],\n\t\t...tamaguiOptions\n\t};\n}\nfunction loadTamaguiSync({ forceExports, cacheKey, ...propsIn }) {\n\tconst key = JSON.stringify(propsIn);\n\tif (last[key] && !hasBundledConfigChanged()) {\n\t\tif (!lastVersion[key] || lastVersion[key] === cacheKey) return last[key];\n\t}\n\tlastVersion[key] = cacheKey || \"\";\n\tconst props = getFilledOptions(propsIn);\n\tconst previousIsStatic = process.env.IS_STATIC;\n\tconst previousIsServer = process.env.TAMAGUI_IS_SERVER;\n\tconst previousDev = globalThis[\"__DEV__\"];\n\tprocess.env.IS_STATIC = \"is_static\";\n\tprocess.env.TAMAGUI_IS_SERVER = \"true\";\n\tconst { unregister } = registerRequire(props.platform || \"web\", { ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules });\n\ttry {\n\t\tglobalThis[\"__DEV__\"] = process.env.NODE_ENV === \"development\";\n\t\tlet tamaguiConfig = null;\n\t\tif (propsIn.config) {\n\t\t\tconst configPath = getTamaguiConfigPathFromOptionsConfig(propsIn.config, propsIn.root);\n\t\t\tconst exp = nodeRequire(configPath);\n\t\t\tif (!exp) throw new Error(`The Tamagui config module did not export a value`);\n\t\t\ttamaguiConfig = exp[\"default\"] || exp[\"config\"] || exp;\n\t\t\tif (!tamaguiConfig || !tamaguiConfig.parsed) {\n\t\t\t\tconst confPath = nodeRequire.resolve(configPath);\n\t\t\t\tthrow new Error(`Can't find valid config in ${confPath}:\n \n Be sure you \"export default\" or \"export const config\" the config.`);\n\t\t\t}\n\t\t\tif (tamaguiConfig) {\n\t\t\t\tconst { createTamagui } = requireTamaguiCore(props.platform || \"web\");\n\t\t\t\tcreateTamagui(tamaguiConfig);\n\t\t\t}\n\t\t}\n\t\tconst components = loadComponentsSync(props, forceExports);\n\t\tif (!components) throw new Error(`No components loaded`);\n\t\tif (process.env.DEBUG === \"tamagui\") console.info(`components`, components);\n\t\tconst info = {\n\t\t\tcomponents,\n\t\t\ttamaguiConfig,\n\t\t\tnameToPaths: getNameToPaths()\n\t\t};\n\t\tif (tamaguiConfig) {\n\t\t\tconst { outputCSS } = props;\n\t\t\tif (outputCSS) writeTamaguiCSS(outputCSS, tamaguiConfig);\n\t\t\tregenerateConfigSync(props, info);\n\t\t}\n\t\tlast[key] = {\n\t\t\t...info,\n\t\t\tcached: true\n\t\t};\n\t\treturn info;\n\t} finally {\n\t\tif (previousIsStatic === void 0) delete process.env.IS_STATIC;\n\t\telse process.env.IS_STATIC = previousIsStatic;\n\t\tif (previousIsServer === void 0) delete process.env.TAMAGUI_IS_SERVER;\n\t\telse process.env.TAMAGUI_IS_SERVER = previousIsServer;\n\t\tglobalThis[\"__DEV__\"] = previousDev;\n\t\tunregister();\n\t}\n}\nasync function getOptions({ root = process.cwd(), tsconfigPath = \"tsconfig.json\", tamaguiOptions, host, debug } = {}) {\n\tconst dotDir = join(root, \".tamagui\");\n\tlet pkgJson = {};\n\ttry {\n\t\tpkgJson = await fsExtra.readJSON(join(root, \"package.json\"));\n\t} catch (err) {}\n\treturn {\n\t\tmode: process.env.NODE_ENV === \"production\" ? \"production\" : \"development\",\n\t\troot,\n\t\thost: host || \"127.0.0.1\",\n\t\tpkgJson,\n\t\tdebug,\n\t\ttsconfigPath,\n\t\ttamaguiOptions: {\n\t\t\tplatform: \"web\",\n\t\t\tcomponents: [\"tamagui\"],\n\t\t\t...tamaguiOptions,\n\t\t\tconfig: tamaguiOptions?.config ?? await getDefaultTamaguiConfigPath(root, tamaguiOptions?.config)\n\t\t},\n\t\tpaths: {\n\t\t\troot,\n\t\t\tdotDir,\n\t\t\tconf: join(dotDir, \"tamagui.config.json\"),\n\t\t\ttypes: join(dotDir, \"types.json\")\n\t\t}\n\t};\n}\nfunction resolveWebOrNativeSpecificEntry(entry, platform) {\n\tconst workspaceRoot = resolve();\n\tconst resolved = nodeRequire.resolve(entry, { paths: [workspaceRoot] });\n\tconst ext = extname(resolved);\n\tconst fileName = basename(resolved).replace(ext, \"\");\n\tconst specificExt = (platform || \"web\") === \"web\" ? \"web\" : \"native\";\n\tconst specificFile = join(dirname(resolved), fileName + \".\" + specificExt + ext);\n\tif (fsExtra.existsSync(specificFile)) return specificFile;\n\treturn entry;\n}\nconst defaultPaths = [\"tamagui.config.ts\", join(\"src\", \"tamagui.config.ts\")];\nlet hasWarnedOnce = false;\nasync function getDefaultTamaguiConfigPath(root, configPath) {\n\tconst searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map((p) => join(root, p)))];\n\tfor (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;\n\tif (!hasWarnedOnce) {\n\t\thasWarnedOnce = true;\n\t\tconsole.warn(`Warning: couldn't find tamagui.config.ts in the following paths given configuration \"${configPath}\":\n ${searchPaths.join(`\n `)}\n `);\n\t}\n}\nasync function esbuildWatchFiles(entry, onChanged) {\n\tlet hasRunOnce = false;\n\tconst context = await esbuild.context({\n\t\tbundle: true,\n\t\tentryPoints: [entry],\n\t\tresolveExtensions: [\n\t\t\t\".ts\",\n\t\t\t\".tsx\",\n\t\t\t\".js\",\n\t\t\t\".mjs\"\n\t\t],\n\t\tlogLevel: \"silent\",\n\t\twrite: false,\n\t\talias: {\n\t\t\t\"react-native-web\": \"@tamagui/react-native-web-lite\",\n\t\t\t\"react-native\": \"@tamagui/react-native-web-lite\"\n\t\t},\n\t\tplugins: [{\n\t\t\tname: `on-rebuild`,\n\t\t\tsetup({ onEnd, onResolve }) {\n\t\t\t\tonResolve({ filter: /^[^./]|^\\.[^./]|^\\.\\.[^/]/ }, (args) => ({\n\t\t\t\t\tpath: args.path,\n\t\t\t\t\texternal: true\n\t\t\t\t}));\n\t\t\t\tonEnd(() => {\n\t\t\t\t\tif (!hasRunOnce) hasRunOnce = true;\n\t\t\t\t\telse onChanged();\n\t\t\t\t});\n\t\t\t}\n\t\t}]\n\t});\n\tcontext.watch();\n\treturn () => {\n\t\tcontext.dispose();\n\t};\n}\n\nexport { esbuildWatchFiles, generateThemesAndLog, getOptions, getTamaguiBuildConfigDependencies, loadTamagui, loadTamaguiBuildConfigAsync, loadTamaguiBuildConfigSync, loadTamaguiFromModules, loadTamaguiSync, resolveWebOrNativeSpecificEntry };"],"mappings":";;;;;;;;;;;;AAWA,MAAM,cAAc,cAAc,OAAO,eAAe,WAAW,aAAa,YAAY,GAAG;AAC/F,MAAM,oBAAoB,aAAa;CACtC,UAAU;CACV,QAAQ;CACR,YAAY,CAAC,SAAS;CACtB,GAAG;AACJ;AACA,IAAI;AACJ,eAAe,YAAY,SAAS,UAAU,OAAO;CACpD,IAAI,kBAAkB,OAAO,MAAM;CACnC,oBAAoB,YAAY;EAC/B,MAAM,QAAQ,iBAAiB,OAAO;EACtC,MAAM,aAAa,MAAM,iBAAiB,OAAO,OAAO;EACxD,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,8EAA8E;EAC/G,MAAM,qBAAqB,OAAO,OAAO;EACzC,MAAM,qBAAqB,WAAW;EACtC,IAAI,sBAAsB,CAAC,mBAAmB,QAAQ;GACrD,MAAM,EAAE,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AAY,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC;CACxG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,QAAQ,WAAW,IAAI,GAAG,OAAO;CAC3E,IAAI,CAAC,eAAe;EACnB,gBAAgB;EAChB,QAAQ,KAAK,wFAAwF,WAAW;MAC5G,YAAY,KAAK;GACpB,EAAE;GACF;CACF;AACD;AACA,eAAe,kBAAkB,OAAO,WAAW;CAClD,IAAI,aAAa;CACjB,MAAM,UAAU,MAAM,QAAQ,QAAQ;EACrC,QAAQ;EACR,aAAa,CAAC,KAAK;EACnB,mBAAmB;GAClB;GACA;GACA;GACA;EACD;EACA,UAAU;EACV,OAAO;EACP,OAAO;GACN,oBAAoB;GACpB,gBAAgB;EACjB;EACA,SAAS,CAAC;GACT,MAAM;GACN,MAAM,EAAE,OAAO,aAAa;IAC3B,UAAU,EAAE,QAAQ,4BAA4B,IAAI,UAAU;KAC7D,MAAM,KAAK;KACX,UAAU;IACX,EAAE;IACF,YAAY;KACX,IAAI,CAAC,YAAY,aAAa;UACzB,UAAU;IAChB,CAAC;GACF;EACD,CAAC;CACF,CAAC;CACD,QAAQ,MAAM;CACd,aAAa;EACZ,QAAQ,QAAQ;CACjB;AACD"}
|
|
1
|
+
{"version":3,"file":"loadTamagui.js","names":[],"sources":["esm/extractor/loadTamagui.js"],"sourcesContent":["import { basename, dirname, extname, join, relative, resolve } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport { Color, colorLog } from \"@tamagui/cli-color\";\nimport esbuild from \"esbuild\";\nimport fsExtra from \"fs-extra\";\nimport { requireTamaguiCore } from \"../helpers/requireTamaguiCore\";\nimport { getNameToPaths, registerRequire, setRequireResult } from \"../registerRequire\";\nimport {\n getComponentStaticConfigByName,\n getBundledConfig,\n getLoadedConfig,\n hasBundledConfigChanged,\n loadComponentsSync,\n setLoadedConfig,\n writeTamaguiCSS\n} from \"./bundleConfig\";\nimport { getTamaguiConfigPathFromOptionsConfig } from \"./getTamaguiConfigPathFromOptionsConfig\";\nimport {\n generateTamaguiThemes,\n regenerateConfig,\n regenerateConfigSync\n} from \"./regenerateConfig\";\nconst nodeRequire = createRequire(\n typeof __filename === \"string\" ? __filename : import.meta.url\n);\nconst getFilledOptions = (propsIn) => ({\n // defaults\n platform: process.env.TAMAGUI_TARGET || \"web\",\n config: \"tamagui.config.ts\",\n components: [\"tamagui\"],\n ...propsIn\n});\nlet isLoadingPromise;\nasync function loadTamagui(propsIn, rebuild = false) {\n if (isLoadingPromise) return await isLoadingPromise;\n isLoadingPromise = (async () => {\n const props = getFilledOptions(propsIn);\n const bundleInfo = await getBundledConfig(props, rebuild);\n if (!bundleInfo) {\n throw new Error(\n `[tamagui] The config and component bundle completed without a project result`\n );\n }\n await generateThemesAndLog(props, rebuild);\n const maybeTamaguiConfig = bundleInfo.tamaguiConfig;\n if (maybeTamaguiConfig && !maybeTamaguiConfig.parsed) {\n const { createTamagui } = requireTamaguiCore(props.platform || \"web\");\n bundleInfo.tamaguiConfig = createTamagui(bundleInfo.tamaguiConfig);\n }\n if (!hasBundledConfigChanged()) {\n return bundleInfo;\n }\n await regenerateConfig(props, bundleInfo);\n return bundleInfo;\n })();\n try {\n return await isLoadingPromise;\n } finally {\n isLoadingPromise = null;\n }\n}\nasync function loadTamaguiFromModules(propsIn, evaluated) {\n const props = getFilledOptions(propsIn);\n await generateThemesAndLog(props);\n const configModule = evaluated.config;\n let tamaguiConfig = configModule.default || configModule.config || configModule;\n if (\"config\" in tamaguiConfig && tamaguiConfig.config && !(\"tokens\" in tamaguiConfig)) {\n tamaguiConfig = tamaguiConfig.config;\n }\n if (!tamaguiConfig) {\n throw new Error(`The Vite module runner did not return a valid Tamagui config`);\n }\n const hostCore = requireTamaguiCore(props.platform || \"web\");\n if (!tamaguiConfig.parsed) {\n tamaguiConfig = hostCore.createTamagui(tamaguiConfig);\n } else {\n hostCore.installTamaguiConfig(tamaguiConfig);\n }\n setLoadedConfig(tamaguiConfig);\n const components = evaluated.components.map(({ moduleName, module }) => {\n setRequireResult(moduleName, module);\n return {\n moduleName,\n nameToInfo: getComponentStaticConfigByName(moduleName, module.default ?? module)\n };\n });\n const projectInfo = {\n components,\n nameToPaths: {},\n tamaguiConfig,\n stampSources: evaluated.stampSources\n };\n if (props.outputCSS) {\n await writeTamaguiCSS(props.outputCSS, projectInfo.tamaguiConfig);\n }\n return projectInfo;\n}\nlet waiting = false;\nconst generateThemesAndLog = async (options, force = false) => {\n if (waiting) return;\n if (!options.themeBuilder) return;\n try {\n waiting = true;\n await new Promise((res) => setTimeout(res, 30));\n const didGenerate = await generateTamaguiThemes(options, force);\n if (didGenerate) {\n const whitespaceBefore = ` `;\n colorLog(\n Color.FgYellow,\n `${whitespaceBefore}\\u27A1 [tamagui] generated themes: ${relative(\n options.root || process.cwd(),\n options.themeBuilder.output\n )}`\n );\n if (options.outputCSS) {\n const loadedConfig = getLoadedConfig();\n if (loadedConfig) {\n await writeTamaguiCSS(options.outputCSS, loadedConfig);\n }\n }\n }\n } finally {\n waiting = false;\n }\n};\nconst last = {};\nconst lastVersion = {};\nconst buildConfigDependencies = /* @__PURE__ */ new WeakMap();\nfunction getTamaguiBuildConfigDependencies(options) {\n return buildConfigDependencies.get(options) ?? [];\n}\nasync function loadTamaguiBuildConfigAsync(tamaguiOptions) {\n const buildFilePath = tamaguiOptions?.buildFile ?? \"./tamagui.build.ts\";\n const root = tamaguiOptions?.root || process.cwd();\n const absolutePath = resolve(root, buildFilePath);\n if (fsExtra.existsSync(absolutePath)) {\n try {\n const result = await esbuild.build({\n entryPoints: [absolutePath],\n absWorkingDir: root,\n bundle: true,\n packages: \"external\",\n platform: \"node\",\n format: \"cjs\",\n target: \"node18\",\n write: false,\n metafile: true\n });\n const module = { exports: {} };\n const projectRequire = createRequire(absolutePath);\n const code = result.outputFiles[0]?.text;\n if (!code) throw new Error(`No output generated for ${buildFilePath}`);\n const fn = new Function(\"module\", \"exports\", \"require\", \"process\", code);\n fn(module, module.exports, projectRequire, process);\n const out = module.exports.default || module.exports;\n if (!out || typeof out !== \"object\") {\n throw new Error(`No default export found in ${buildFilePath}: ${out}`);\n }\n const loadedOptions = {\n ...tamaguiOptions,\n ...out\n };\n const dependencies2 = Object.keys(result.metafile.inputs).map(\n (input) => resolve(root, input)\n );\n buildConfigDependencies.set(loadedOptions, dependencies2);\n tamaguiOptions = loadedOptions;\n } catch (err) {\n console.error(`[tamagui] Error loading ${buildFilePath}:`, err);\n throw err;\n }\n }\n if (!tamaguiOptions) {\n throw new Error(\n `No tamagui build options found either via input props or at tamagui.build.ts`\n );\n }\n const options = {\n config: \"tamagui.config.ts\",\n components: [\"tamagui\", \"@tamagui/core\"],\n ...tamaguiOptions\n };\n const dependencies = buildConfigDependencies.get(tamaguiOptions);\n if (dependencies) buildConfigDependencies.set(options, dependencies);\n return options;\n}\nfunction loadTamaguiBuildConfigSync(tamaguiOptions) {\n const buildFilePath = tamaguiOptions?.buildFile ?? \"./tamagui.build.ts\";\n const root = tamaguiOptions?.root || process.cwd();\n const absolutePath = resolve(root, buildFilePath);\n if (fsExtra.existsSync(absolutePath)) {\n const registered = registerRequire(\"web\", {\n ignoredModules: tamaguiOptions?.dangerouslyIgnoreStaticEvaluationModules\n });\n try {\n const out = nodeRequire(absolutePath).default;\n if (!out) {\n throw new Error(`No default export found in ${buildFilePath}: ${out}`);\n }\n tamaguiOptions = {\n ...tamaguiOptions,\n ...out\n };\n } finally {\n registered.unregister();\n }\n }\n if (!tamaguiOptions) {\n throw new Error(\n `No tamagui build options found either via input props or at tamagui.build.ts`\n );\n }\n return {\n config: \"tamagui.config.ts\",\n components: [\"tamagui\", \"@tamagui/core\"],\n ...tamaguiOptions\n };\n}\nfunction loadTamaguiSync({\n forceExports,\n cacheKey,\n ...propsIn\n}) {\n const key = JSON.stringify(propsIn);\n if (last[key] && !hasBundledConfigChanged()) {\n if (!lastVersion[key] || lastVersion[key] === cacheKey) {\n return last[key];\n }\n }\n lastVersion[key] = cacheKey || \"\";\n const props = getFilledOptions(propsIn);\n const previousIsStatic = process.env.IS_STATIC;\n const previousIsServer = process.env.TAMAGUI_IS_SERVER;\n const previousDev = globalThis[\"__DEV__\"];\n process.env.IS_STATIC = \"is_static\";\n process.env.TAMAGUI_IS_SERVER = \"true\";\n const { unregister } = registerRequire(props.platform || \"web\", {\n ignoredModules: props.dangerouslyIgnoreStaticEvaluationModules\n });\n try {\n globalThis[\"__DEV__\"] = process.env.NODE_ENV === \"development\";\n let tamaguiConfig = null;\n if (propsIn.config) {\n const configPath = getTamaguiConfigPathFromOptionsConfig(\n propsIn.config,\n propsIn.root\n );\n const exp = nodeRequire(configPath);\n if (!exp) {\n throw new Error(`The Tamagui config module did not export a value`);\n }\n tamaguiConfig = exp[\"default\"] || exp[\"config\"] || exp;\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n const confPath = nodeRequire.resolve(configPath);\n throw new Error(`Can't find valid config in ${confPath}:\n \n Be sure you \"export default\" or \"export const config\" the config.`);\n }\n if (tamaguiConfig) {\n const { createTamagui } = requireTamaguiCore(props.platform || \"web\");\n createTamagui(tamaguiConfig);\n }\n }\n const components = loadComponentsSync(props, forceExports);\n if (!components) {\n throw new Error(`No components loaded`);\n }\n if (process.env.DEBUG === \"tamagui\") {\n console.info(`components`, components);\n }\n const info = {\n components,\n tamaguiConfig,\n nameToPaths: getNameToPaths()\n };\n if (tamaguiConfig) {\n const { outputCSS } = props;\n if (outputCSS) {\n writeTamaguiCSS(outputCSS, tamaguiConfig);\n }\n regenerateConfigSync(props, info);\n }\n last[key] = {\n ...info,\n cached: true\n };\n return info;\n } finally {\n if (previousIsStatic === void 0) delete process.env.IS_STATIC;\n else process.env.IS_STATIC = previousIsStatic;\n if (previousIsServer === void 0) delete process.env.TAMAGUI_IS_SERVER;\n else process.env.TAMAGUI_IS_SERVER = previousIsServer;\n globalThis[\"__DEV__\"] = previousDev;\n unregister();\n }\n}\nasync function getOptions({\n root = process.cwd(),\n tsconfigPath = \"tsconfig.json\",\n tamaguiOptions,\n host,\n debug\n} = {}) {\n const dotDir = join(root, \".tamagui\");\n let pkgJson = {};\n try {\n pkgJson = await fsExtra.readJSON(join(root, \"package.json\"));\n } catch (err) {\n }\n return {\n mode: process.env.NODE_ENV === \"production\" ? \"production\" : \"development\",\n root,\n host: host || \"127.0.0.1\",\n pkgJson,\n debug,\n tsconfigPath,\n tamaguiOptions: {\n platform: process.env.TAMAGUI_TARGET || \"web\",\n components: [\"tamagui\"],\n ...tamaguiOptions,\n config: tamaguiOptions?.config ?? await getDefaultTamaguiConfigPath(root, tamaguiOptions?.config)\n },\n paths: {\n root,\n dotDir,\n conf: join(dotDir, \"tamagui.config.json\"),\n types: join(dotDir, \"types.json\")\n }\n };\n}\nfunction resolveWebOrNativeSpecificEntry(entry, platform) {\n const workspaceRoot = resolve();\n const resolved = nodeRequire.resolve(entry, { paths: [workspaceRoot] });\n const ext = extname(resolved);\n const fileName = basename(resolved).replace(ext, \"\");\n const target = platform || process.env.TAMAGUI_TARGET || \"web\";\n const specificExt = target === \"web\" ? \"web\" : \"native\";\n const specificFile = join(dirname(resolved), fileName + \".\" + specificExt + ext);\n if (fsExtra.existsSync(specificFile)) {\n return specificFile;\n }\n return entry;\n}\nconst defaultPaths = [\"tamagui.config.ts\", join(\"src\", \"tamagui.config.ts\")];\nlet hasWarnedOnce = false;\nasync function getDefaultTamaguiConfigPath(root, configPath) {\n const searchPaths = [\n ...new Set(\n [configPath, ...defaultPaths].filter(Boolean).map((p) => join(root, p))\n )\n ];\n for (const path of searchPaths) {\n if (await fsExtra.pathExists(path)) {\n return path;\n }\n }\n if (!hasWarnedOnce) {\n hasWarnedOnce = true;\n console.warn(`Warning: couldn't find tamagui.config.ts in the following paths given configuration \"${configPath}\":\n ${searchPaths.join(`\n `)}\n `);\n }\n}\nasync function esbuildWatchFiles(entry, onChanged) {\n let hasRunOnce = false;\n const context = await esbuild.context({\n bundle: true,\n entryPoints: [entry],\n resolveExtensions: [\".ts\", \".tsx\", \".js\", \".mjs\"],\n logLevel: \"silent\",\n write: false,\n alias: {\n \"react-native-web\": \"@tamagui/react-native-web-lite\",\n \"react-native\": \"@tamagui/react-native-web-lite\"\n },\n plugins: [\n // to log what its watching:\n // {\n // name: 'test',\n // setup({ onResolve }) {\n // onResolve({ filter: /.*/ }, (args) => {\n // console.log('wtf', args.path)\n // })\n // },\n // },\n {\n name: `on-rebuild`,\n setup({ onEnd, onResolve }) {\n let filter = /^[^./]|^\\.[^./]|^\\.\\.[^/]/;\n onResolve({ filter }, (args) => ({ path: args.path, external: true }));\n onEnd(() => {\n if (!hasRunOnce) {\n hasRunOnce = true;\n } else {\n onChanged();\n }\n });\n }\n }\n ]\n });\n void context.watch();\n return () => {\n context.dispose();\n };\n}\nexport {\n esbuildWatchFiles,\n generateThemesAndLog,\n getOptions,\n getTamaguiBuildConfigDependencies,\n loadTamagui,\n loadTamaguiBuildConfigAsync,\n loadTamaguiBuildConfigSync,\n loadTamaguiFromModules,\n loadTamaguiSync,\n resolveWebOrNativeSpecificEntry\n};\n//# sourceMappingURL=loadTamagui.js.map\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,cAAc,cAClB,OAAO,eAAe,WAAW,aAAa,YAAY,GAC5D;AACA,MAAM,oBAAoB,aAAa;CAErC,UAAU,QAAQ,IAAI,kBAAkB;CACxC,QAAQ;CACR,YAAY,CAAC,SAAS;CACtB,GAAG;AACL;AACA,IAAI;AACJ,eAAe,YAAY,SAAS,UAAU,OAAO;CACnD,IAAI,kBAAkB,OAAO,MAAM;CACnC,oBAAoB,YAAY;EAC9B,MAAM,QAAQ,iBAAiB,OAAO;EACtC,MAAM,aAAa,MAAM,iBAAiB,OAAO,OAAO;EACxD,IAAI,CAAC,YAAY;GACf,MAAM,IAAI,MACR,8EACF;EACF;EACA,MAAM,qBAAqB,OAAO,OAAO;EACzC,MAAM,qBAAqB,WAAW;EACtC,IAAI,sBAAsB,CAAC,mBAAmB,QAAQ;G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