@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
package/dist/checkDeps.cjs
CHANGED
|
@@ -28,40 +28,173 @@ var import_node_fs = require("node:fs"),
|
|
|
28
28
|
import_node_path = require("node:path"),
|
|
29
29
|
import_check_dep_versions = require("./check-dep-versions.cjs"),
|
|
30
30
|
DEPENDENCY_TYPE = /* @__PURE__ */(DEPENDENCY_TYPE2 => (DEPENDENCY_TYPE2.dependencies = "dependencies", DEPENDENCY_TYPE2.devDependencies = "devDependencies", DEPENDENCY_TYPE2.optionalDependencies = "optionalDependencies", DEPENDENCY_TYPE2.peerDependencies = "peerDependencies", DEPENDENCY_TYPE2.resolutions = "resolutions", DEPENDENCY_TYPE2))(DEPENDENCY_TYPE || {});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const normalized = normalizeVersion(dep.version);
|
|
50
|
-
versionGroups.has(normalized) || versionGroups.set(normalized, []), versionGroups.get(normalized).push(`${dep.name}@${dep.version}`);
|
|
31
|
+
const CRITICAL_PACKAGES = ["@tamagui/web", "@tamagui/core", "tamagui"];
|
|
32
|
+
function checkDuplicateInstalls(root) {
|
|
33
|
+
const nodeModules = (0, import_node_path.join)(root, "node_modules");
|
|
34
|
+
if (!(0, import_node_fs.existsSync)(nodeModules)) return "";
|
|
35
|
+
const duplicates = /* @__PURE__ */new Map();
|
|
36
|
+
for (const pkg of CRITICAL_PACKAGES) {
|
|
37
|
+
const locations = findAllInstances(nodeModules, pkg);
|
|
38
|
+
if (locations.length > 1) {
|
|
39
|
+
const realPaths = /* @__PURE__ */new Set(),
|
|
40
|
+
distinctLocations = [];
|
|
41
|
+
for (const loc of locations) try {
|
|
42
|
+
const real = (0, import_node_fs.realpathSync)(loc);
|
|
43
|
+
realPaths.has(real) || (realPaths.add(real), distinctLocations.push((0, import_node_path.relative)(root, loc)));
|
|
44
|
+
} catch {
|
|
45
|
+
distinctLocations.push((0, import_node_path.relative)(root, loc));
|
|
46
|
+
}
|
|
47
|
+
distinctLocations.length > 1 && duplicates.set(pkg, distinctLocations);
|
|
48
|
+
}
|
|
51
49
|
}
|
|
52
|
-
if (
|
|
53
|
-
const lines = ["Found
|
|
54
|
-
for (const [
|
|
55
|
-
lines.push(` ${
|
|
56
|
-
for (const
|
|
50
|
+
if (duplicates.size === 0) return "";
|
|
51
|
+
const lines = ["Found duplicate tamagui installations in node_modules:", "", "This causes multiple runtime instances, which breaks theme/config detection.", ""];
|
|
52
|
+
for (const [pkg, locations] of duplicates) {
|
|
53
|
+
lines.push(` ${pkg}:`);
|
|
54
|
+
for (const loc of locations) {
|
|
55
|
+
const pkgJsonPath = (0, import_node_path.join)(root, loc, "package.json");
|
|
56
|
+
let version = "?";
|
|
57
|
+
try {
|
|
58
|
+
version = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8")).version;
|
|
59
|
+
} catch {}
|
|
60
|
+
lines.push(` ${version} at ${loc}`);
|
|
61
|
+
}
|
|
62
|
+
lines.push("");
|
|
57
63
|
}
|
|
58
|
-
return lines.push(""), lines.push("
|
|
64
|
+
return lines.push("Fix: run your package manager's dedupe command:"), lines.push(" bun install (bun auto-dedupes)"), lines.push(" npx yarn-deduplicate && yarn install"), lines.push(" npm dedupe"), lines.push(""), lines.push("If that doesn't help, delete node_modules and lockfile, then reinstall."), lines.join(`
|
|
65
|
+
`);
|
|
66
|
+
}
|
|
67
|
+
function findAllInstances(nodeModulesDir, packageName, found = [], depth = 0) {
|
|
68
|
+
if (depth > 4 || !(0, import_node_fs.existsSync)(nodeModulesDir)) return found;
|
|
69
|
+
const pkgDir = (0, import_node_path.join)(nodeModulesDir, ...packageName.split("/"));
|
|
70
|
+
(0, import_node_fs.existsSync)((0, import_node_path.join)(pkgDir, "package.json")) && found.push(pkgDir);
|
|
71
|
+
try {
|
|
72
|
+
const entries = (0, import_node_fs.readdirSync)(nodeModulesDir);
|
|
73
|
+
for (const entry of entries) if (!entry.startsWith(".")) if (entry.startsWith("@")) {
|
|
74
|
+
const scopeDir = (0, import_node_path.join)(nodeModulesDir, entry);
|
|
75
|
+
try {
|
|
76
|
+
const scopeEntries = (0, import_node_fs.readdirSync)(scopeDir);
|
|
77
|
+
for (const scopeEntry of scopeEntries) {
|
|
78
|
+
const nested = (0, import_node_path.join)(scopeDir, scopeEntry, "node_modules");
|
|
79
|
+
(0, import_node_fs.existsSync)(nested) && findAllInstances(nested, packageName, found, depth + 1);
|
|
80
|
+
}
|
|
81
|
+
} catch {}
|
|
82
|
+
} else {
|
|
83
|
+
const nested = (0, import_node_path.join)(nodeModulesDir, entry, "node_modules");
|
|
84
|
+
(0, import_node_fs.existsSync)(nested) && findAllInstances(nested, packageName, found, depth + 1);
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
return found;
|
|
88
|
+
}
|
|
89
|
+
function checkLockfileDuplicates(root) {
|
|
90
|
+
const bunLock = (0, import_node_path.join)(root, "bun.lock"),
|
|
91
|
+
yarnLock = (0, import_node_path.join)(root, "yarn.lock"),
|
|
92
|
+
npmLock = (0, import_node_path.join)(root, "package-lock.json");
|
|
93
|
+
return (0, import_node_fs.existsSync)(bunLock) ? checkBunLockDuplicates(bunLock) : (0, import_node_fs.existsSync)(yarnLock) ? checkYarnLockDuplicates(yarnLock) : (0, import_node_fs.existsSync)(npmLock) ? checkNpmLockDuplicates(npmLock) : "";
|
|
94
|
+
}
|
|
95
|
+
function checkBunLockDuplicates(lockPath) {
|
|
96
|
+
try {
|
|
97
|
+
const content = (0, import_node_fs.readFileSync)(lockPath, "utf8"),
|
|
98
|
+
duplicates = /* @__PURE__ */new Map(),
|
|
99
|
+
criticalSet = new Set(CRITICAL_PACKAGES),
|
|
100
|
+
packagePattern = /["'](@tamagui\/[\w-]+|tamagui)@([^"'\s,]+)["']/g;
|
|
101
|
+
let match;
|
|
102
|
+
for (; (match = packagePattern.exec(content)) !== null;) {
|
|
103
|
+
const name = match[1],
|
|
104
|
+
version = match[2];
|
|
105
|
+
version.startsWith("workspace:") || criticalSet.has(name) && (duplicates.has(name) || duplicates.set(name, /* @__PURE__ */new Set()), duplicates.get(name).add(version));
|
|
106
|
+
}
|
|
107
|
+
return formatLockfileDuplicates(duplicates, "bun.lock");
|
|
108
|
+
} catch {
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function checkYarnLockDuplicates(lockPath) {
|
|
113
|
+
try {
|
|
114
|
+
const content = (0, import_node_fs.readFileSync)(lockPath, "utf8"),
|
|
115
|
+
duplicates = /* @__PURE__ */new Map(),
|
|
116
|
+
criticalSet = new Set(CRITICAL_PACKAGES),
|
|
117
|
+
entryPattern = /^"?(@tamagui\/[\w-]+|tamagui)@[^":\n]+[":]?\s*$/gm,
|
|
118
|
+
versionPattern = /^\s+version\s+"([^"]+)"/gm;
|
|
119
|
+
let entryMatch;
|
|
120
|
+
for (; (entryMatch = entryPattern.exec(content)) !== null;) {
|
|
121
|
+
const name = entryMatch[1];
|
|
122
|
+
if (!criticalSet.has(name)) continue;
|
|
123
|
+
versionPattern.lastIndex = entryMatch.index;
|
|
124
|
+
const verMatch = versionPattern.exec(content);
|
|
125
|
+
verMatch && (duplicates.has(name) || duplicates.set(name, /* @__PURE__ */new Set()), duplicates.get(name).add(verMatch[1]));
|
|
126
|
+
}
|
|
127
|
+
return formatLockfileDuplicates(duplicates, "yarn.lock");
|
|
128
|
+
} catch {
|
|
129
|
+
return "";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function checkNpmLockDuplicates(lockPath) {
|
|
133
|
+
try {
|
|
134
|
+
const lock = JSON.parse((0, import_node_fs.readFileSync)(lockPath, "utf8")),
|
|
135
|
+
duplicates = /* @__PURE__ */new Map(),
|
|
136
|
+
criticalSet = new Set(CRITICAL_PACKAGES),
|
|
137
|
+
packages = lock.packages || {};
|
|
138
|
+
for (const [path, info] of Object.entries(packages)) {
|
|
139
|
+
if (!path) continue;
|
|
140
|
+
const name = info.name || path.split("node_modules/").pop();
|
|
141
|
+
if (!name || !criticalSet.has(name)) continue;
|
|
142
|
+
const version = info.version;
|
|
143
|
+
version && (duplicates.has(name) || duplicates.set(name, /* @__PURE__ */new Set()), duplicates.get(name).add(version));
|
|
144
|
+
}
|
|
145
|
+
return formatLockfileDuplicates(duplicates, "package-lock.json");
|
|
146
|
+
} catch {
|
|
147
|
+
return "";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function formatLockfileDuplicates(duplicates, lockfileName) {
|
|
151
|
+
const multiVersion = /* @__PURE__ */new Map();
|
|
152
|
+
for (const [name, versions] of duplicates) versions.size > 1 && multiVersion.set(name, [...versions].sort());
|
|
153
|
+
if (multiVersion.size === 0) return "";
|
|
154
|
+
const lines = [`Found multiple resolved versions in ${lockfileName}:`, ""];
|
|
155
|
+
for (const [name, versions] of multiVersion) lines.push(` ${name}: ${versions.join(", ")}`);
|
|
156
|
+
return lines.push(""), lines.push("Multiple versions cause duplicate runtime instances, breaking config/theme detection."), lines.push("Fix: ensure all tamagui packages use the same version range, then dedupe."), lines.join(`
|
|
157
|
+
`);
|
|
158
|
+
}
|
|
159
|
+
function checkConfigExists(root) {
|
|
160
|
+
const configNames = ["tamagui.config.ts", "tamagui.config.tsx", "tamagui.config.js", "tamagui.config.mjs", "tamagui.config.cjs"],
|
|
161
|
+
searchDirs = [root, (0, import_node_path.join)(root, "src"), (0, import_node_path.join)(root, "app"), (0, import_node_path.join)(root, "config")];
|
|
162
|
+
for (const dir of searchDirs) for (const name of configNames) if ((0, import_node_fs.existsSync)((0, import_node_path.join)(dir, name))) return "";
|
|
163
|
+
const buildConfigNames = ["tamagui.build.ts", "tamagui.build.js", "tamagui.build.mjs", "tamagui.build.cjs"];
|
|
164
|
+
for (const name of buildConfigNames) {
|
|
165
|
+
const buildPath = (0, import_node_path.join)(root, name);
|
|
166
|
+
if ((0, import_node_fs.existsSync)(buildPath)) try {
|
|
167
|
+
const match = (0, import_node_fs.readFileSync)(buildPath, "utf8").match(/config\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
168
|
+
if (match) {
|
|
169
|
+
const configPath = (0, import_node_path.join)(root, match[1]);
|
|
170
|
+
if ((0, import_node_fs.existsSync)(configPath)) return "";
|
|
171
|
+
}
|
|
172
|
+
} catch {}
|
|
173
|
+
}
|
|
174
|
+
const pkgJsonPath = (0, import_node_path.join)(root, "package.json");
|
|
175
|
+
if ((0, import_node_fs.existsSync)(pkgJsonPath)) try {
|
|
176
|
+
const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8"));
|
|
177
|
+
if (pkg.tamagui?.config) {
|
|
178
|
+
const configPath = (0, import_node_path.join)(root, pkg.tamagui.config);
|
|
179
|
+
if ((0, import_node_fs.existsSync)(configPath)) return "";
|
|
180
|
+
}
|
|
181
|
+
} catch {}
|
|
182
|
+
if ((0, import_node_fs.existsSync)(pkgJsonPath)) try {
|
|
183
|
+
if (JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8")).workspaces) return "";
|
|
184
|
+
} catch {}
|
|
185
|
+
return ["No tamagui.config file found.", "", "Tamagui requires a config file (e.g. tamagui.config.ts) that calls createTamagui().", `Without it, components will throw "Can't find Tamagui configuration" at runtime.`, "", "See: https://tamagui.dev/docs/core/configuration"].join(`
|
|
59
186
|
`);
|
|
60
187
|
}
|
|
61
188
|
async function checkDeps(root) {
|
|
62
|
-
const
|
|
63
|
-
workspaceMismatchSummary = new import_check_dep_versions.CDVC(root).toMismatchSummary()
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
189
|
+
const issues = [],
|
|
190
|
+
workspaceMismatchSummary = new import_check_dep_versions.CDVC(root).toMismatchSummary();
|
|
191
|
+
workspaceMismatchSummary && issues.push(workspaceMismatchSummary);
|
|
192
|
+
const lockfileSummary = checkLockfileDuplicates(root);
|
|
193
|
+
lockfileSummary && issues.push(lockfileSummary);
|
|
194
|
+
const duplicatesSummary = checkDuplicateInstalls(root);
|
|
195
|
+
duplicatesSummary && issues.push(duplicatesSummary);
|
|
196
|
+
const configSummary = checkConfigExists(root);
|
|
197
|
+
configSummary && issues.push(configSummary), issues.length === 0 && (console.info("Tamagui dependencies look good \u2705"), process.exit(0));
|
|
198
|
+
for (let i = 0; i < issues.length; i++) i > 0 && console.error(""), console.error(issues[i]);
|
|
199
|
+
process.exit(1);
|
|
67
200
|
}
|
package/dist/exports.cjs
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
21
21
|
}), mod);
|
|
22
22
|
var exports_exports = {};
|
|
23
23
|
__export(exports_exports, {
|
|
24
|
+
clearFormatCache: () => import_detectModuleFormat.clearFormatCache,
|
|
24
25
|
createExtractor: () => import_createExtractor.createExtractor,
|
|
26
|
+
detectModuleFormat: () => import_detectModuleFormat.detectModuleFormat,
|
|
25
27
|
literalToAst: () => import_literalToAst.literalToAst
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(exports_exports);
|
|
@@ -38,4 +40,5 @@ __reExport(exports_exports, require("./extractor/loadTamagui.cjs"), module.expor
|
|
|
38
40
|
__reExport(exports_exports, require("./extractor/watchTamaguiConfig.cjs"), module.exports);
|
|
39
41
|
__reExport(exports_exports, require("./extractor/createLogger.cjs"), module.exports);
|
|
40
42
|
__reExport(exports_exports, require("./registerRequire.cjs"), module.exports);
|
|
43
|
+
var import_detectModuleFormat = require("./extractor/detectModuleFormat.cjs");
|
|
41
44
|
__reExport(exports_exports, require("./getPragmaOptions.cjs"), module.exports);
|
|
@@ -36,9 +36,10 @@ __export(bundle_exports, {
|
|
|
36
36
|
esbundleTamaguiConfig: () => esbundleTamaguiConfig
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(bundle_exports);
|
|
39
|
-
var
|
|
39
|
+
var import_node_fs = require("node:fs"),
|
|
40
40
|
import_esbuild = __toESM(require("esbuild")),
|
|
41
41
|
FS = __toESM(require("fs-extra")),
|
|
42
|
+
import_detectModuleFormat = require("./detectModuleFormat.cjs"),
|
|
42
43
|
import_esbuildAliasPlugin = require("./esbuildAliasPlugin.cjs"),
|
|
43
44
|
import_loadTamagui = require("./loadTamagui.cjs"),
|
|
44
45
|
import_esbuildTsconfigPaths = require("./esbuildTsconfigPaths.cjs");
|
|
@@ -74,11 +75,21 @@ function getESBuildConfig({
|
|
|
74
75
|
resolvePlatformSpecificEntries,
|
|
75
76
|
...options
|
|
76
77
|
}, platform, aliases) {
|
|
77
|
-
|
|
78
|
+
process.env.DEBUG?.startsWith("tamagui") && console.info("Building", entryPoints);
|
|
79
|
+
const resolvedEntryPoints = resolvePlatformSpecificEntries ? entryPoints.map(import_loadTamagui.resolveWebOrNativeSpecificEntry) : entryPoints,
|
|
80
|
+
detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
|
|
81
|
+
return {
|
|
78
82
|
bundle: !0,
|
|
79
|
-
entryPoints:
|
|
80
|
-
format:
|
|
81
|
-
|
|
83
|
+
entryPoints: resolvedEntryPoints,
|
|
84
|
+
format: detectedFormat,
|
|
85
|
+
// for ESM: prefer "module" field for resolution, add require() shim for bundled CJS deps
|
|
86
|
+
...(detectedFormat === "esm" ? {
|
|
87
|
+
mainFields: ["module", "main"],
|
|
88
|
+
banner: {
|
|
89
|
+
js: 'import { createRequire as __cr } from "module"; const require = __cr(import.meta.url);'
|
|
90
|
+
}
|
|
91
|
+
} : {}),
|
|
92
|
+
target: "node24",
|
|
82
93
|
jsx: "transform",
|
|
83
94
|
jsxFactory: "react",
|
|
84
95
|
allowOverwrite: !0,
|
|
@@ -92,33 +103,59 @@ function getESBuildConfig({
|
|
|
92
103
|
},
|
|
93
104
|
loader: esbuildLoaderConfig,
|
|
94
105
|
logLevel: "warning",
|
|
95
|
-
plugins: [(0, import_esbuildTsconfigPaths.TsconfigPathsPlugin)(),
|
|
106
|
+
plugins: [(0, import_esbuildTsconfigPaths.TsconfigPathsPlugin)(),
|
|
107
|
+
// handle ESM-only features that can't be used with CJS output
|
|
108
|
+
{
|
|
109
|
+
name: "handle-esm-features",
|
|
110
|
+
setup(build) {
|
|
111
|
+
const isCjs = build.initialOptions.format === "cjs" || !build.initialOptions.format;
|
|
112
|
+
build.onLoad({
|
|
113
|
+
filter: /\.(ts|tsx|js|jsx|mjs)$/
|
|
114
|
+
}, args => {
|
|
115
|
+
if (!isCjs || args.path.includes("node_modules") && !args.path.includes("@tamagui")) return null;
|
|
116
|
+
let contents = (0, import_node_fs.readFileSync)(args.path, "utf8"),
|
|
117
|
+
modified = !1;
|
|
118
|
+
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}`), {
|
|
119
|
+
contents: `// stubbed - contains top-level await
|
|
120
|
+
module.exports = {}`,
|
|
121
|
+
loader: "js"
|
|
122
|
+
}) : modified ? {
|
|
123
|
+
contents,
|
|
124
|
+
loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
|
|
125
|
+
} : null;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
96
129
|
name: "external",
|
|
97
130
|
setup(build) {
|
|
131
|
+
const proxyWormPath = require.resolve("@tamagui/proxy-worm");
|
|
98
132
|
build.onResolve({
|
|
99
|
-
filter:
|
|
100
|
-
}, args =>
|
|
101
|
-
path: platform === "native" ? "@tamagui/core/native" :
|
|
133
|
+
filter: /^@tamagui\/(core|web)$/
|
|
134
|
+
}, args => args.kind === "entry-point" ? null : {
|
|
135
|
+
path: platform === "native" ? "@tamagui/core/native" : args.path,
|
|
102
136
|
external: !0
|
|
103
|
-
})
|
|
137
|
+
}), build.onResolve({
|
|
104
138
|
filter: /react-native\/package.json$/
|
|
105
|
-
},
|
|
139
|
+
}, () => ({
|
|
106
140
|
path: "react-native/package.json",
|
|
107
141
|
external: !0
|
|
108
|
-
})), build.onResolve({
|
|
109
|
-
filter: /@tamagui\/web/
|
|
110
|
-
}, args => ({
|
|
111
|
-
path: platform === "native" ? "@tamagui/core/native" : "@tamagui/core",
|
|
112
|
-
external: !0
|
|
113
142
|
})), build.onResolve({
|
|
114
143
|
filter: /^(react-native|react-native\/.*)$/
|
|
115
|
-
},
|
|
144
|
+
}, () => ({
|
|
116
145
|
path: "@tamagui/react-native-web-lite",
|
|
117
146
|
external: !0
|
|
118
147
|
})), build.onResolve({
|
|
119
|
-
filter:
|
|
148
|
+
filter: /^react-native-reanimated(?:\/.*)?$/
|
|
149
|
+
}, () => ({
|
|
150
|
+
path: proxyWormPath
|
|
151
|
+
})), build.onResolve({
|
|
152
|
+
filter: /^react-native-worklets(?:\/.*)?$/
|
|
153
|
+
}, () => ({
|
|
154
|
+
path: proxyWormPath
|
|
155
|
+
})), build.onResolve({
|
|
156
|
+
filter: /^(framer-motion|motion)/
|
|
120
157
|
}, args => ({
|
|
121
|
-
path:
|
|
158
|
+
path: args.path,
|
|
122
159
|
external: !0
|
|
123
160
|
}));
|
|
124
161
|
}
|
|
@@ -128,21 +165,21 @@ function getESBuildConfig({
|
|
|
128
165
|
...options
|
|
129
166
|
};
|
|
130
167
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
lockStat = await FS.stat(lockFile).catch(() => {});
|
|
139
|
-
if ((lockStat ? (/* @__PURE__ */new Date()).getTime() - new Date(lockStat.mtime).getTime() : Number.POSITIVE_INFINITY) < 500) {
|
|
140
|
-
process.env.DEBUG?.startsWith("tamagui") && console.info("Waiting for existing build", props.entryPoints);
|
|
141
|
-
let tries = 5;
|
|
142
|
-
for (; tries--;) {
|
|
143
|
-
if (await FS.pathExists(props.outfile)) return;
|
|
144
|
-
await new Promise(res => setTimeout(res, 50));
|
|
145
|
-
}
|
|
168
|
+
function detectEntryFormat(entryPoint) {
|
|
169
|
+
if (entryPoint.startsWith("/") || entryPoint.startsWith(".")) return (0, import_detectModuleFormat.detectModuleFormat)(entryPoint);
|
|
170
|
+
try {
|
|
171
|
+
const pkgJsonPath = require.resolve(entryPoint + "/package.json");
|
|
172
|
+
return JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8")).type === "module" ? "esm" : "cjs";
|
|
173
|
+
} catch {
|
|
174
|
+
return "cjs";
|
|
146
175
|
}
|
|
147
|
-
|
|
176
|
+
}
|
|
177
|
+
async function esbundleTamaguiConfig(props, platform, aliases) {
|
|
178
|
+
const config = getESBuildConfig(props, platform, aliases),
|
|
179
|
+
tmpFile = props.outfile + ".tmp." + process.pid,
|
|
180
|
+
result = await import_esbuild.default.build({
|
|
181
|
+
...config,
|
|
182
|
+
outfile: tmpFile
|
|
183
|
+
});
|
|
184
|
+
return await FS.rename(tmpFile, props.outfile), result;
|
|
148
185
|
}
|