@tamagui/static 2.0.0-rc.3 → 2.0.0-rc.30
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/checkDeps.cjs +164 -31
- package/dist/exports.cjs +3 -0
- package/dist/extractor/bundle.cjs +72 -35
- package/dist/extractor/bundleConfig.cjs +219 -35
- package/dist/extractor/createExtractor.cjs +170 -28
- package/dist/extractor/detectModuleFormat.cjs +49 -0
- package/dist/extractor/esbuildTsconfigPaths.cjs +3 -1
- package/dist/extractor/extractToClassNames.cjs +7 -5
- package/dist/extractor/extractToNative.cjs +7 -8
- package/dist/extractor/loadTamagui.cjs +1 -1
- package/dist/getPragmaOptions.cjs +7 -3
- package/dist/index.js +26 -16
- package/dist/registerRequire.cjs +23 -14
- package/package.json +26 -22
- package/src/checkDeps.ts +305 -68
- package/src/exports.ts +1 -0
- package/src/extractor/bundle.ts +140 -37
- package/src/extractor/bundleConfig.ts +435 -61
- package/src/extractor/createExtractor.ts +261 -41
- package/src/extractor/detectModuleFormat.ts +42 -0
- package/src/extractor/esbuildTsconfigPaths.ts +6 -1
- package/src/extractor/extractToClassNames.ts +15 -9
- package/src/extractor/extractToNative.ts +32 -25
- package/src/extractor/loadTamagui.ts +2 -2
- package/src/getPragmaOptions.ts +6 -1
- package/src/registerRequire.ts +40 -8
- package/types/checkDeps.d.ts.map +1 -1
- package/types/exports.d.ts +1 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +83 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +15 -2
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/detectModuleFormat.d.ts +5 -0
- package/types/extractor/detectModuleFormat.d.ts.map +1 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts +8 -0
- package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts.map +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/dist/check-dep-versions.js +0 -389
- package/dist/check-dep-versions.js.map +0 -6
- package/dist/checkDeps.js +0 -60
- package/dist/checkDeps.js.map +0 -6
- package/dist/constants.js +0 -34
- package/dist/constants.js.map +0 -6
- package/dist/exports.js +0 -34
- package/dist/exports.js.map +0 -6
- package/dist/extractor/accessSafe.js +0 -47
- package/dist/extractor/accessSafe.js.map +0 -6
- package/dist/extractor/babelParse.js +0 -59
- package/dist/extractor/babelParse.js.map +0 -6
- package/dist/extractor/buildClassName.js +0 -72
- package/dist/extractor/buildClassName.js.map +0 -6
- package/dist/extractor/bundle.js +0 -135
- package/dist/extractor/bundle.js.map +0 -6
- package/dist/extractor/bundleConfig.js +0 -352
- package/dist/extractor/bundleConfig.js.map +0 -6
- package/dist/extractor/concatClassName.js +0 -69
- package/dist/extractor/concatClassName.js.map +0 -6
- package/dist/extractor/createEvaluator.js +0 -66
- package/dist/extractor/createEvaluator.js.map +0 -6
- package/dist/extractor/createExtractor.js +0 -1215
- package/dist/extractor/createExtractor.js.map +0 -6
- package/dist/extractor/createLogger.js +0 -32
- package/dist/extractor/createLogger.js.map +0 -6
- package/dist/extractor/ensureImportingConcat.js +0 -50
- package/dist/extractor/ensureImportingConcat.js.map +0 -6
- package/dist/extractor/errors.js +0 -22
- package/dist/extractor/errors.js.map +0 -6
- package/dist/extractor/esbuildAliasPlugin.js +0 -36
- package/dist/extractor/esbuildAliasPlugin.js.map +0 -6
- package/dist/extractor/esbuildTsconfigPaths.js +0 -79
- package/dist/extractor/esbuildTsconfigPaths.js.map +0 -6
- package/dist/extractor/evaluateAstNode.js +0 -99
- package/dist/extractor/evaluateAstNode.js.map +0 -6
- package/dist/extractor/extractHelpers.js +0 -108
- package/dist/extractor/extractHelpers.js.map +0 -6
- package/dist/extractor/extractMediaStyle.js +0 -123
- package/dist/extractor/extractMediaStyle.js.map +0 -6
- package/dist/extractor/extractToClassNames.js +0 -351
- package/dist/extractor/extractToClassNames.js.map +0 -6
- package/dist/extractor/extractToNative.js +0 -286
- package/dist/extractor/extractToNative.js.map +0 -6
- package/dist/extractor/findTopmostFunction.js +0 -32
- package/dist/extractor/findTopmostFunction.js.map +0 -6
- package/dist/extractor/generatedUid.js +0 -42
- package/dist/extractor/generatedUid.js.map +0 -6
- package/dist/extractor/getPrefixLogs.js +0 -24
- package/dist/extractor/getPrefixLogs.js.map +0 -6
- package/dist/extractor/getPropValueFromAttributes.js +0 -65
- package/dist/extractor/getPropValueFromAttributes.js.map +0 -6
- package/dist/extractor/getSourceModule.js +0 -62
- package/dist/extractor/getSourceModule.js.map +0 -6
- package/dist/extractor/getStaticBindingsForScope.js +0 -145
- package/dist/extractor/getStaticBindingsForScope.js.map +0 -6
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js +0 -32
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.js.map +0 -6
- package/dist/extractor/hoistClassNames.js +0 -63
- package/dist/extractor/hoistClassNames.js.map +0 -6
- package/dist/extractor/literalToAst.js +0 -90
- package/dist/extractor/literalToAst.js.map +0 -6
- package/dist/extractor/loadFile.js +0 -14
- package/dist/extractor/loadFile.js.map +0 -6
- package/dist/extractor/loadTamagui.js +0 -306
- package/dist/extractor/loadTamagui.js.map +0 -6
- package/dist/extractor/logLines.js +0 -30
- package/dist/extractor/logLines.js.map +0 -6
- package/dist/extractor/normalizeTernaries.js +0 -61
- package/dist/extractor/normalizeTernaries.js.map +0 -6
- package/dist/extractor/propsToFontFamilyCache.js +0 -33
- package/dist/extractor/propsToFontFamilyCache.js.map +0 -6
- package/dist/extractor/regenerateConfig.js +0 -123
- package/dist/extractor/regenerateConfig.js.map +0 -6
- package/dist/extractor/removeUnusedHooks.js +0 -72
- package/dist/extractor/removeUnusedHooks.js.map +0 -6
- package/dist/extractor/timer.js +0 -38
- package/dist/extractor/timer.js.map +0 -6
- package/dist/extractor/validHTMLAttributes.js +0 -72
- package/dist/extractor/validHTMLAttributes.js.map +0 -6
- package/dist/extractor/watchTamaguiConfig.js +0 -57
- package/dist/extractor/watchTamaguiConfig.js.map +0 -6
- package/dist/getPragmaOptions.js +0 -46
- package/dist/getPragmaOptions.js.map +0 -6
- package/dist/helpers/memoize.js +0 -33
- package/dist/helpers/memoize.js.map +0 -6
- package/dist/helpers/requireTamaguiCore.js +0 -30
- package/dist/helpers/requireTamaguiCore.js.map +0 -6
- package/dist/registerRequire.js +0 -100
- package/dist/registerRequire.js.map +0 -6
- package/dist/server.js +0 -58
- package/dist/server.js.map +0 -6
- package/dist/setup.js +0 -1
- package/dist/setup.js.map +0 -6
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -6
- package/dist/worker.js +0 -72
- package/dist/worker.js.map +0 -6
|
@@ -33,19 +33,24 @@ var bundleConfig_exports = {};
|
|
|
33
33
|
__export(bundleConfig_exports, {
|
|
34
34
|
bundleConfig: () => bundleConfig,
|
|
35
35
|
esbuildOptions: () => esbuildOptions,
|
|
36
|
+
esbuildOptionsWithPlugins: () => esbuildOptionsWithPlugins,
|
|
36
37
|
getBundledConfig: () => getBundledConfig,
|
|
37
38
|
getLoadedConfig: () => getLoadedConfig,
|
|
38
39
|
hasBundledConfigChanged: () => hasBundledConfigChanged,
|
|
39
40
|
loadComponents: () => loadComponents,
|
|
40
41
|
loadComponentsInner: () => loadComponentsInner,
|
|
42
|
+
loadComponentsInnerSync: () => loadComponentsInnerSync,
|
|
43
|
+
loadComponentsSync: () => loadComponentsSync,
|
|
41
44
|
writeTamaguiCSS: () => writeTamaguiCSS
|
|
42
45
|
});
|
|
43
46
|
module.exports = __toCommonJS(bundleConfig_exports);
|
|
44
47
|
var import_generator = __toESM(require("@babel/generator")),
|
|
45
48
|
import_traverse = __toESM(require("@babel/traverse")),
|
|
46
49
|
t = __toESM(require("@babel/types")),
|
|
50
|
+
import_node_crypto = require("node:crypto"),
|
|
47
51
|
import_node_fs = require("node:fs"),
|
|
48
52
|
import_node_path = require("node:path"),
|
|
53
|
+
import_node_url = require("node:url"),
|
|
49
54
|
import_cli_color = require("@tamagui/cli-color"),
|
|
50
55
|
import_esbuild = __toESM(require("esbuild")),
|
|
51
56
|
FS = __toESM(require("fs-extra")),
|
|
@@ -54,19 +59,79 @@ var import_generator = __toESM(require("@babel/generator")),
|
|
|
54
59
|
import_babelParse = require("./babelParse.cjs"),
|
|
55
60
|
import_bundle = require("./bundle.cjs"),
|
|
56
61
|
import_getTamaguiConfigPathFromOptionsConfig = require("./getTamaguiConfigPathFromOptionsConfig.cjs"),
|
|
57
|
-
import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs")
|
|
62
|
+
import_requireTamaguiCore = require("../helpers/requireTamaguiCore.cjs"),
|
|
63
|
+
import_detectModuleFormat = require("./detectModuleFormat.cjs");
|
|
64
|
+
const activeTempFiles = /* @__PURE__ */new Set();
|
|
65
|
+
function getDynamicEvalOutfile(name, format, contents) {
|
|
66
|
+
const ext = format === "esm" ? "mjs" : "cjs",
|
|
67
|
+
hash = (0, import_node_crypto.createHash)("sha1").update(name).update("\0").update(format).update("\0").update(contents).digest("hex").slice(0, 10);
|
|
68
|
+
return (0, import_node_path.join)(process.cwd(), ".tamagui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
|
|
69
|
+
}
|
|
70
|
+
function getEsbuildStdinLoader(filePath) {
|
|
71
|
+
return filePath.endsWith(".tsx") ? "tsx" : filePath.endsWith(".ts") ? "ts" : filePath.endsWith(".jsx") ? "jsx" : "js";
|
|
72
|
+
}
|
|
73
|
+
function resolvePackageEntry(packageName, format) {
|
|
74
|
+
if (format === "cjs") return require.resolve(packageName);
|
|
75
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`),
|
|
76
|
+
packageJson = JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf-8")),
|
|
77
|
+
packageRoot = (0, import_node_path.dirname)(packageJsonPath),
|
|
78
|
+
exportEntry = packageJson.exports?.["."],
|
|
79
|
+
esmEntry = exportEntry?.import || exportEntry?.module || exportEntry?.browser || packageJson.module;
|
|
80
|
+
return typeof esmEntry == "string" ? (0, import_node_path.join)(packageRoot, esmEntry) : require.resolve(packageName);
|
|
81
|
+
}
|
|
82
|
+
function cleanupTempFiles() {
|
|
83
|
+
for (const f of activeTempFiles) try {
|
|
84
|
+
(0, import_node_fs.unlinkSync)(f);
|
|
85
|
+
} catch {}
|
|
86
|
+
activeTempFiles.clear();
|
|
87
|
+
}
|
|
88
|
+
process.on("exit", cleanupTempFiles);
|
|
89
|
+
process.on("SIGINT", () => {
|
|
90
|
+
cleanupTempFiles(), process.exit();
|
|
91
|
+
});
|
|
92
|
+
process.on("SIGTERM", () => {
|
|
93
|
+
cleanupTempFiles(), process.exit();
|
|
94
|
+
});
|
|
58
95
|
const external = ["@tamagui/core", "@tamagui/web", "react", "react-dom", "react-native-svg"],
|
|
59
96
|
esbuildExtraOptions = {
|
|
60
97
|
define: {
|
|
61
98
|
__DEV__: `${process.env.NODE_ENV === "development"}`
|
|
62
99
|
}
|
|
63
100
|
},
|
|
64
|
-
|
|
65
|
-
|
|
101
|
+
handleEsmFeaturesPlugin = {
|
|
102
|
+
name: "handle-esm-features",
|
|
103
|
+
setup(build) {
|
|
104
|
+
const isCjs = build.initialOptions.format === "cjs" || !build.initialOptions.format;
|
|
105
|
+
build.onLoad({
|
|
106
|
+
filter: /\.(ts|tsx|js|jsx|mjs)$/
|
|
107
|
+
}, args => {
|
|
108
|
+
if (!isCjs || args.path.includes("node_modules") && !args.path.includes("@tamagui")) return null;
|
|
109
|
+
let contents = (0, import_node_fs.readFileSync)(args.path, "utf8"),
|
|
110
|
+
modified = !1;
|
|
111
|
+
return contents.includes("import.meta.env") && (contents = contents.replace(/import\.meta\.env/g, "process.env"), modified = !0), contents.includes("import.meta.url") && (contents = contents.replace(/import\.meta\.url/g, '""'), modified = !0), contents.includes("import.meta.main") && (contents = contents.replace(/import\.meta\.main/g, "false"), modified = !0), /^\s*(?:const|let|var|export)\s+[^=]*=\s*await\b/m.test(contents) || /^await\s/m.test(contents) ? (process.env.DEBUG?.startsWith("tamagui") && console.info(`[tamagui] stubbing file with top-level await: ${args.path}`), {
|
|
112
|
+
contents: `// stubbed - contains top-level await
|
|
113
|
+
module.exports = {}`,
|
|
114
|
+
loader: "js"
|
|
115
|
+
}) : modified ? {
|
|
116
|
+
contents,
|
|
117
|
+
loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
|
|
118
|
+
} : null;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
esbuildTransformOptions = {
|
|
123
|
+
target: "es2022",
|
|
66
124
|
format: "cjs",
|
|
67
125
|
jsx: "automatic",
|
|
68
126
|
platform: "node",
|
|
69
127
|
...esbuildExtraOptions
|
|
128
|
+
},
|
|
129
|
+
esbuildOptions = {
|
|
130
|
+
...esbuildTransformOptions
|
|
131
|
+
},
|
|
132
|
+
esbuildOptionsWithPlugins = {
|
|
133
|
+
...esbuildTransformOptions,
|
|
134
|
+
plugins: [handleEsmFeaturesPlugin]
|
|
70
135
|
};
|
|
71
136
|
let currentBundle = null,
|
|
72
137
|
isBundling = !1,
|
|
@@ -95,10 +160,30 @@ async function bundleConfig(props) {
|
|
|
95
160
|
isBundling = !0;
|
|
96
161
|
const configEntry = props.config ? (0, import_getTamaguiConfigPathFromOptionsConfig.getTamaguiConfigPathFromOptionsConfig)(props.config) : "",
|
|
97
162
|
tmpDir = (0, import_node_path.join)(process.cwd(), ".tamagui"),
|
|
98
|
-
|
|
163
|
+
configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs",
|
|
164
|
+
configOutPath = (0, import_node_path.join)(tmpDir, `tamagui.config${configFormat === "esm" ? ".mjs" : ".cjs"}`),
|
|
99
165
|
baseComponents = (props.components || []).filter(x => x !== "@tamagui/core"),
|
|
100
|
-
|
|
101
|
-
|
|
166
|
+
componentFormats = baseComponents.map(mod => {
|
|
167
|
+
try {
|
|
168
|
+
const pkgJson = require.resolve(mod + "/package.json");
|
|
169
|
+
return JSON.parse((0, import_node_fs.readFileSync)(pkgJson, "utf-8")).type === "module" ? "esm" : "cjs";
|
|
170
|
+
} catch {
|
|
171
|
+
return "cjs";
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
componentOutPaths = baseComponents.map((componentModule, i) => {
|
|
175
|
+
const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
|
|
176
|
+
return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
|
|
177
|
+
});
|
|
178
|
+
process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("tamagui") && console.info("Building config entry", configEntry);
|
|
179
|
+
let shouldBuild = !props.disableInitialBuild;
|
|
180
|
+
if (shouldBuild && props.config) {
|
|
181
|
+
const allOutFiles = [configOutPath, ...componentOutPaths];
|
|
182
|
+
try {
|
|
183
|
+
(await Promise.all(allOutFiles.map(f => FS.stat(f).catch(() => null)))).every(s => s !== null && Date.now() - s.mtimeMs < 3e3) && (shouldBuild = !1);
|
|
184
|
+
} catch {}
|
|
185
|
+
}
|
|
186
|
+
if (shouldBuild) {
|
|
102
187
|
try {
|
|
103
188
|
await FS.ensureDir(tmpDir);
|
|
104
189
|
} catch {}
|
|
@@ -107,14 +192,16 @@ async function bundleConfig(props) {
|
|
|
107
192
|
entryPoints: [configEntry],
|
|
108
193
|
external,
|
|
109
194
|
outfile: configOutPath,
|
|
110
|
-
target: "
|
|
195
|
+
target: "node24",
|
|
196
|
+
format: configFormat,
|
|
111
197
|
...esbuildExtraOptions
|
|
112
198
|
}, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => (0, import_bundle.esbundleTamaguiConfig)({
|
|
113
199
|
entryPoints: [componentModule],
|
|
114
200
|
resolvePlatformSpecificEntries: !0,
|
|
115
201
|
external,
|
|
116
202
|
outfile: componentOutPaths[i],
|
|
117
|
-
target: "
|
|
203
|
+
target: "node24",
|
|
204
|
+
format: componentFormats[i],
|
|
118
205
|
...esbuildExtraOptions
|
|
119
206
|
}, props.platform || "web"))]), !hasLoggedBuild && !props._skipBuildLog && (hasLoggedBuild = !0, (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
|
|
120
207
|
\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, `
|
|
@@ -123,18 +210,19 @@ async function bundleConfig(props) {
|
|
|
123
210
|
`)}
|
|
124
211
|
`));
|
|
125
212
|
}
|
|
213
|
+
if (hasBundledOnce) {
|
|
214
|
+
try {
|
|
215
|
+
delete require.cache[require.resolve(configOutPath)];
|
|
216
|
+
} catch {}
|
|
217
|
+
for (const p of componentOutPaths) try {
|
|
218
|
+
delete require.cache[require.resolve(p)];
|
|
219
|
+
} catch {}
|
|
220
|
+
} else hasBundledOnce = !0;
|
|
126
221
|
let out;
|
|
127
|
-
|
|
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;
|
|
132
|
-
out = require(configOutPath);
|
|
133
|
-
} finally {
|
|
134
|
-
unregister();
|
|
135
|
-
}
|
|
222
|
+
configFormat === "esm" ? out = await import((0, import_node_url.pathToFileURL)(configOutPath).href) : out = require(configOutPath);
|
|
136
223
|
let config = out.default || out || out.config;
|
|
137
224
|
if (config && config.config && !config.tokens && (config = config.config), !config) throw new Error(`No config: ${config}`);
|
|
225
|
+
if (config._isProxyWorm) throw new Error("Got a proxied config - likely a module loading error. Set DEBUG=tamagui for details.");
|
|
138
226
|
if (loadedConfig = config, !config.parsed) {
|
|
139
227
|
const {
|
|
140
228
|
createTamagui
|
|
@@ -142,7 +230,7 @@ async function bundleConfig(props) {
|
|
|
142
230
|
config = createTamagui(config);
|
|
143
231
|
}
|
|
144
232
|
props.outputCSS && (await writeTamaguiCSS(props.outputCSS, config));
|
|
145
|
-
let components = loadComponents({
|
|
233
|
+
let components = await loadComponents({
|
|
146
234
|
...props,
|
|
147
235
|
components: componentOutPaths
|
|
148
236
|
});
|
|
@@ -173,13 +261,18 @@ async function writeTamaguiCSS(outputCSS, config) {
|
|
|
173
261
|
console.info("Error writing themes", err);
|
|
174
262
|
}
|
|
175
263
|
}
|
|
176
|
-
function loadComponents(props, forceExports = !1) {
|
|
177
|
-
const coreComponents =
|
|
178
|
-
otherComponents = loadComponentsInner(props, forceExports);
|
|
264
|
+
async function loadComponents(props, forceExports = !1) {
|
|
265
|
+
const coreComponents = getCoreComponentsSync(props),
|
|
266
|
+
otherComponents = await loadComponentsInner(props, forceExports);
|
|
179
267
|
return [...coreComponents, ...(otherComponents || [])];
|
|
180
268
|
}
|
|
181
|
-
function
|
|
182
|
-
const
|
|
269
|
+
function loadComponentsSync(props, forceExports = !1) {
|
|
270
|
+
const coreComponents = getCoreComponentsSync(props),
|
|
271
|
+
otherComponents = loadComponentsInnerSync(props, forceExports);
|
|
272
|
+
return [...coreComponents, ...(otherComponents || [])];
|
|
273
|
+
}
|
|
274
|
+
function getCoreComponentsSync(props) {
|
|
275
|
+
const loaded = loadComponentsInnerSync({
|
|
183
276
|
...props,
|
|
184
277
|
components: ["@tamagui/core"]
|
|
185
278
|
});
|
|
@@ -189,9 +282,95 @@ function getCoreComponents(props) {
|
|
|
189
282
|
moduleName: "@tamagui/core"
|
|
190
283
|
}];
|
|
191
284
|
}
|
|
192
|
-
function loadComponentsInner(props, forceExports = !1) {
|
|
285
|
+
async function loadComponentsInner(props, forceExports = !1) {
|
|
193
286
|
const componentsModules = props.components || [],
|
|
194
|
-
key = componentsModules.join("");
|
|
287
|
+
key = componentsModules.join("\0");
|
|
288
|
+
if (!forceExports && cacheComponents[key]) return cacheComponents[key];
|
|
289
|
+
const {
|
|
290
|
+
unregister
|
|
291
|
+
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
292
|
+
proxyWormImports: forceExports
|
|
293
|
+
});
|
|
294
|
+
try {
|
|
295
|
+
const results = [];
|
|
296
|
+
for (const name of componentsModules) {
|
|
297
|
+
const isLocal = !!(0, import_node_path.extname)(name),
|
|
298
|
+
isDynamic = isLocal && forceExports,
|
|
299
|
+
format = isLocal ? (0, import_detectModuleFormat.detectModuleFormat)(name) : "cjs",
|
|
300
|
+
fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
|
|
301
|
+
let loadModule = name,
|
|
302
|
+
writtenContents = fileContents,
|
|
303
|
+
didBabel = !1;
|
|
304
|
+
const attemptLoad = async ({
|
|
305
|
+
forceExports: forceExports2 = !1
|
|
306
|
+
} = {}) => {
|
|
307
|
+
isDynamic && (writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents, loadModule = getDynamicEvalOutfile(name, format, writtenContents), FS.ensureDirSync((0, import_node_path.dirname)(loadModule)), activeTempFiles.add(loadModule), await import_esbuild.default.build({
|
|
308
|
+
...esbuildOptionsWithPlugins,
|
|
309
|
+
format,
|
|
310
|
+
outfile: loadModule,
|
|
311
|
+
stdin: {
|
|
312
|
+
contents: writtenContents,
|
|
313
|
+
resolveDir: (0, import_node_path.dirname)(name),
|
|
314
|
+
sourcefile: name,
|
|
315
|
+
loader: getEsbuildStdinLoader(name)
|
|
316
|
+
},
|
|
317
|
+
alias: {
|
|
318
|
+
"react-native": resolvePackageEntry("@tamagui/react-native-web-lite", format),
|
|
319
|
+
"@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", format),
|
|
320
|
+
"@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", format)
|
|
321
|
+
},
|
|
322
|
+
bundle: !0,
|
|
323
|
+
packages: "external",
|
|
324
|
+
allowOverwrite: !0,
|
|
325
|
+
sourcemap: !1,
|
|
326
|
+
loader: import_bundle.esbuildLoaderConfig
|
|
327
|
+
})), process.env.DEBUG === "tamagui" && console.info("loadModule", loadModule, format);
|
|
328
|
+
let moduleResult;
|
|
329
|
+
format === "esm" ? moduleResult = await import((0, import_node_url.pathToFileURL)(loadModule).href) : moduleResult = require(loadModule), forceExports2 || (0, import_registerRequire.setRequireResult)(name, moduleResult);
|
|
330
|
+
const nameToInfo = getComponentStaticConfigByName(name, interopDefaultExport(moduleResult));
|
|
331
|
+
return {
|
|
332
|
+
moduleName: name,
|
|
333
|
+
nameToInfo
|
|
334
|
+
};
|
|
335
|
+
},
|
|
336
|
+
dispose = () => {
|
|
337
|
+
isDynamic && (FS.removeSync(loadModule), activeTempFiles.delete(loadModule));
|
|
338
|
+
};
|
|
339
|
+
let loaded;
|
|
340
|
+
try {
|
|
341
|
+
loaded = await attemptLoad({
|
|
342
|
+
forceExports: !0
|
|
343
|
+
}), didBabel = !0;
|
|
344
|
+
} catch (err) {
|
|
345
|
+
console.info("babel err", err, writtenContents), writtenContents = fileContents, process.env.DEBUG?.startsWith("tamagui") && console.info("Error parsing babel likely", err);
|
|
346
|
+
try {
|
|
347
|
+
loaded = await attemptLoad({
|
|
348
|
+
forceExports: !1
|
|
349
|
+
});
|
|
350
|
+
} catch (err2) {
|
|
351
|
+
process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.info(`
|
|
352
|
+
Tamagui attempted but failed to dynamically optimize components in:
|
|
353
|
+
${name}
|
|
354
|
+
`), console.info(err2), console.info(`At: ${loadModule}`, `
|
|
355
|
+
didBabel: ${didBabel}`, `
|
|
356
|
+
In:`, writtenContents, `
|
|
357
|
+
isDynamic: `, isDynamic)), loaded = [];
|
|
358
|
+
}
|
|
359
|
+
} finally {
|
|
360
|
+
dispose();
|
|
361
|
+
}
|
|
362
|
+
Array.isArray(loaded) ? results.push(...loaded) : loaded && results.push(loaded);
|
|
363
|
+
}
|
|
364
|
+
return cacheComponents[key] = results, results;
|
|
365
|
+
} catch (err) {
|
|
366
|
+
return console.info("Tamagui error bundling components", err.message, err.stack), null;
|
|
367
|
+
} finally {
|
|
368
|
+
unregister();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function loadComponentsInnerSync(props, forceExports = !1) {
|
|
372
|
+
const componentsModules = props.components || [],
|
|
373
|
+
key = componentsModules.join("\0");
|
|
195
374
|
if (!forceExports && cacheComponents[key]) return cacheComponents[key];
|
|
196
375
|
const {
|
|
197
376
|
unregister
|
|
@@ -201,24 +380,30 @@ function loadComponentsInner(props, forceExports = !1) {
|
|
|
201
380
|
try {
|
|
202
381
|
const info = componentsModules.flatMap(name => {
|
|
203
382
|
const isDynamic = !!(0, import_node_path.extname)(name) && forceExports,
|
|
204
|
-
fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : ""
|
|
205
|
-
|
|
206
|
-
|
|
383
|
+
fileContents = isDynamic ? (0, import_node_fs.readFileSync)(name, "utf-8") : "";
|
|
384
|
+
let loadModule = name,
|
|
385
|
+
writtenContents = fileContents,
|
|
207
386
|
didBabel = !1;
|
|
208
387
|
function attemptLoad({
|
|
209
388
|
forceExports: forceExports2 = !1
|
|
210
389
|
} = {}) {
|
|
211
|
-
isDynamic && (writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents, FS.
|
|
390
|
+
isDynamic && (writtenContents = forceExports2 ? transformAddExports((0, import_babelParse.babelParse)(esbuildit(fileContents, "modern"), name)) : fileContents, loadModule = getDynamicEvalOutfile(name, "cjs", writtenContents), FS.ensureDirSync((0, import_node_path.dirname)(loadModule)), activeTempFiles.add(loadModule), import_esbuild.default.buildSync({
|
|
212
391
|
...esbuildOptions,
|
|
213
|
-
entryPoints: [loadModule],
|
|
214
392
|
outfile: loadModule,
|
|
393
|
+
stdin: {
|
|
394
|
+
contents: writtenContents,
|
|
395
|
+
resolveDir: (0, import_node_path.dirname)(name),
|
|
396
|
+
sourcefile: name,
|
|
397
|
+
loader: getEsbuildStdinLoader(name)
|
|
398
|
+
},
|
|
215
399
|
alias: {
|
|
216
|
-
"react-native":
|
|
400
|
+
"react-native": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
|
|
401
|
+
"@tamagui/react-native-web-lite": resolvePackageEntry("@tamagui/react-native-web-lite", "esm"),
|
|
402
|
+
"@tamagui/react-native-web-internals": resolvePackageEntry("@tamagui/react-native-web-internals", "esm")
|
|
217
403
|
},
|
|
218
404
|
bundle: !0,
|
|
219
405
|
packages: "external",
|
|
220
406
|
allowOverwrite: !0,
|
|
221
|
-
// logLevel: 'silent',
|
|
222
407
|
sourcemap: !1,
|
|
223
408
|
loader: import_bundle.esbuildLoaderConfig
|
|
224
409
|
})), process.env.DEBUG === "tamagui" && console.info("loadModule", loadModule, require.resolve(loadModule));
|
|
@@ -231,7 +416,7 @@ function loadComponentsInner(props, forceExports = !1) {
|
|
|
231
416
|
};
|
|
232
417
|
}
|
|
233
418
|
const dispose = () => {
|
|
234
|
-
isDynamic && FS.removeSync(loadModule);
|
|
419
|
+
isDynamic && (FS.removeSync(loadModule), activeTempFiles.delete(loadModule));
|
|
235
420
|
};
|
|
236
421
|
try {
|
|
237
422
|
const res = attemptLoad({
|
|
@@ -249,7 +434,6 @@ function loadComponentsInner(props, forceExports = !1) {
|
|
|
249
434
|
});
|
|
250
435
|
} catch (err) {
|
|
251
436
|
return process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && (console.info(`
|
|
252
|
-
|
|
253
437
|
Tamagui attempted but failed to dynamically optimize components in:
|
|
254
438
|
${name}
|
|
255
439
|
`), console.info(err), console.info(`At: ${loadModule}`, `
|
|
@@ -268,7 +452,7 @@ isDynamic: `, isDynamic)), [];
|
|
|
268
452
|
}
|
|
269
453
|
}
|
|
270
454
|
const esbuildit = (src, target) => import_esbuild.default.transformSync(src, {
|
|
271
|
-
...
|
|
455
|
+
...esbuildTransformOptions,
|
|
272
456
|
...(target === "modern" && {
|
|
273
457
|
target: "es2022",
|
|
274
458
|
jsx: "automatic",
|