@tamagui/static 3.0.0-beta.1212.1 → 3.0.0-beta.1215.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/extractor/loadTamagui.cjs +27 -20
- package/dist/esm/extractor/loadTamagui.mjs +27 -20
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -1
- package/package.json +18 -18
- package/src/extractor/loadTamagui.ts +53 -24
- package/types/extractor/loadTamagui.d.ts +13 -1
- package/types/extractor/loadTamagui.d.ts.map +1 -1
|
@@ -148,30 +148,37 @@ const buildConfigDependencies = /* @__PURE__ */ new WeakMap();
|
|
|
148
148
|
function getTamaguiBuildConfigDependencies(options) {
|
|
149
149
|
return buildConfigDependencies.get(options) ?? [];
|
|
150
150
|
}
|
|
151
|
-
async
|
|
151
|
+
const esbuildBuildConfigLoader = async (absolutePath, root) => {
|
|
152
|
+
const result = await import_esbuild.default.build({
|
|
153
|
+
entryPoints: [absolutePath],
|
|
154
|
+
absWorkingDir: root,
|
|
155
|
+
bundle: true,
|
|
156
|
+
packages: "external",
|
|
157
|
+
platform: "node",
|
|
158
|
+
format: "cjs",
|
|
159
|
+
target: "node18",
|
|
160
|
+
write: false,
|
|
161
|
+
metafile: true
|
|
162
|
+
});
|
|
163
|
+
const code = result.outputFiles[0]?.text;
|
|
164
|
+
if (!code) throw new Error(`No output generated for ${absolutePath}`);
|
|
165
|
+
const module2 = { exports: {} };
|
|
166
|
+
const projectRequire = (0, import_node_module.createRequire)(absolutePath);
|
|
167
|
+
const fn = new Function("module", "exports", "require", "process", code);
|
|
168
|
+
fn(module2, module2.exports, projectRequire, process);
|
|
169
|
+
return {
|
|
170
|
+
exports: module2.exports,
|
|
171
|
+
dependencies: Object.keys(result.metafile.inputs)
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
async function loadTamaguiBuildConfigAsync(tamaguiOptions, loadBuildConfigModule = esbuildBuildConfigLoader) {
|
|
152
175
|
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
153
176
|
const root = tamaguiOptions?.root || process.cwd();
|
|
154
177
|
const absolutePath = (0, import_node_path.resolve)(root, buildFilePath);
|
|
155
178
|
if (import_fs_extra.default.existsSync(absolutePath)) {
|
|
156
179
|
try {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
absWorkingDir: root,
|
|
160
|
-
bundle: true,
|
|
161
|
-
packages: "external",
|
|
162
|
-
platform: "node",
|
|
163
|
-
format: "cjs",
|
|
164
|
-
target: "node18",
|
|
165
|
-
write: false,
|
|
166
|
-
metafile: true
|
|
167
|
-
});
|
|
168
|
-
const module2 = { exports: {} };
|
|
169
|
-
const projectRequire = (0, import_node_module.createRequire)(absolutePath);
|
|
170
|
-
const code = result.outputFiles[0]?.text;
|
|
171
|
-
if (!code) throw new Error(`No output generated for ${buildFilePath}`);
|
|
172
|
-
const fn = new Function("module", "exports", "require", "process", code);
|
|
173
|
-
fn(module2, module2.exports, projectRequire, process);
|
|
174
|
-
const out = module2.exports.default || module2.exports;
|
|
180
|
+
const evaluated = await loadBuildConfigModule(absolutePath, root);
|
|
181
|
+
const out = evaluated.exports.default || evaluated.exports;
|
|
175
182
|
if (!out || typeof out !== "object") {
|
|
176
183
|
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
177
184
|
}
|
|
@@ -179,7 +186,7 @@ async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
|
179
186
|
...tamaguiOptions,
|
|
180
187
|
...out
|
|
181
188
|
};
|
|
182
|
-
const dependencies2 =
|
|
189
|
+
const dependencies2 = evaluated.dependencies.map((file) => (0, import_node_path.resolve)(root, file));
|
|
183
190
|
buildConfigDependencies.set(loadedOptions, dependencies2);
|
|
184
191
|
tamaguiOptions = loadedOptions;
|
|
185
192
|
} catch (err) {
|
|
@@ -108,30 +108,37 @@ const buildConfigDependencies = /* @__PURE__ */ new WeakMap();
|
|
|
108
108
|
function getTamaguiBuildConfigDependencies(options) {
|
|
109
109
|
return buildConfigDependencies.get(options) ?? [];
|
|
110
110
|
}
|
|
111
|
-
async
|
|
111
|
+
const esbuildBuildConfigLoader = async (absolutePath, root) => {
|
|
112
|
+
const result = await esbuild.build({
|
|
113
|
+
entryPoints: [absolutePath],
|
|
114
|
+
absWorkingDir: root,
|
|
115
|
+
bundle: true,
|
|
116
|
+
packages: "external",
|
|
117
|
+
platform: "node",
|
|
118
|
+
format: "cjs",
|
|
119
|
+
target: "node18",
|
|
120
|
+
write: false,
|
|
121
|
+
metafile: true
|
|
122
|
+
});
|
|
123
|
+
const code = result.outputFiles[0]?.text;
|
|
124
|
+
if (!code) throw new Error(`No output generated for ${absolutePath}`);
|
|
125
|
+
const module = { exports: {} };
|
|
126
|
+
const projectRequire = createRequire(absolutePath);
|
|
127
|
+
const fn = new Function("module", "exports", "require", "process", code);
|
|
128
|
+
fn(module, module.exports, projectRequire, process);
|
|
129
|
+
return {
|
|
130
|
+
exports: module.exports,
|
|
131
|
+
dependencies: Object.keys(result.metafile.inputs)
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
async function loadTamaguiBuildConfigAsync(tamaguiOptions, loadBuildConfigModule = esbuildBuildConfigLoader) {
|
|
112
135
|
const buildFilePath = tamaguiOptions?.buildFile ?? "./tamagui.build.ts";
|
|
113
136
|
const root = tamaguiOptions?.root || process.cwd();
|
|
114
137
|
const absolutePath = resolve(root, buildFilePath);
|
|
115
138
|
if (fsExtra.existsSync(absolutePath)) {
|
|
116
139
|
try {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
absWorkingDir: root,
|
|
120
|
-
bundle: true,
|
|
121
|
-
packages: "external",
|
|
122
|
-
platform: "node",
|
|
123
|
-
format: "cjs",
|
|
124
|
-
target: "node18",
|
|
125
|
-
write: false,
|
|
126
|
-
metafile: true
|
|
127
|
-
});
|
|
128
|
-
const module = { exports: {} };
|
|
129
|
-
const projectRequire = createRequire(absolutePath);
|
|
130
|
-
const code = result.outputFiles[0]?.text;
|
|
131
|
-
if (!code) throw new Error(`No output generated for ${buildFilePath}`);
|
|
132
|
-
const fn = new Function("module", "exports", "require", "process", code);
|
|
133
|
-
fn(module, module.exports, projectRequire, process);
|
|
134
|
-
const out = module.exports.default || module.exports;
|
|
140
|
+
const evaluated = await loadBuildConfigModule(absolutePath, root);
|
|
141
|
+
const out = evaluated.exports.default || evaluated.exports;
|
|
135
142
|
if (!out || typeof out !== "object") {
|
|
136
143
|
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
137
144
|
}
|
|
@@ -139,7 +146,7 @@ async function loadTamaguiBuildConfigAsync(tamaguiOptions) {
|
|
|
139
146
|
...tamaguiOptions,
|
|
140
147
|
...out
|
|
141
148
|
};
|
|
142
|
-
const dependencies2 =
|
|
149
|
+
const dependencies2 = evaluated.dependencies.map((file) => resolve(root, file));
|
|
143
150
|
buildConfigDependencies.set(loadedOptions, dependencies2);
|
|
144
151
|
tamaguiOptions = loadedOptions;
|
|
145
152
|
} catch (err) {
|
|
@@ -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 {\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 await regenerateConfig(props, projectInfo);\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;GACpD,MAAM,EAAE,kBAAkB,mBAAmB,MAAM,YAAY,KAAK;GACpE,WAAW,gBAAgB,cAAc,WAAW,aAAa;EACnE;EACA,IAAI,CAAC,wBAAwB,GAAG;GAC9B,OAAO;E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,OAAO;CACT;CACA,OAAO;AACT;AACA,MAAM,eAAe,CAAC,qBAAqB,KAAK,OAAO,mBAAmB,CAAC;AAC3E,IAAI,gBAAgB;AACpB,eAAe,4BAA4B,MAAM,YAAY;CAC3D,MAAM,cAAc,CAClB,GAAG,IAAI,IACL,CAAC,YAAY,GAAG,YAAY,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC,CACxE,CACF;CACA,KAAK,MAAM,QAAQ,aAAa;EAC9B,IAAI,MAAM,QAAQ,WAAW,IAAI,GAAG;GAClC,OAAO;EACT;CACF;CACA,IAAI,CAAC,eAAe;EAClB,gBAAgB;EAChB,QAAQ,KAAK,wFAAwF,WAAW;MAC9G,YAAY,KAAK;GACpB,EAAE;GACF;CACD;AACF;AACA,eAAe,kBAAkB,OAAO,WAAW;CACjD,IAAI,aAAa;CACjB,MAAM,UAAU,MAAM,QAAQ,QAAQ;EACpC,QAAQ;EACR,aAAa,CAAC,KAAK;EACnB,mBAAmB;GAAC;GAAO;GAAQ;GAAO;EAAM;EAChD,UAAU;EACV,OAAO;EACP,OAAO;GACL,oBAAoB;GACpB,gBAAgB;EAClB;EACA,SAAS,CAUP;GACE,MAAM;GACN,MAAM,EAAE,OAAO,aAAa;IAC1B,IAAI,SAAS;IACb,UAAU,EAAE,OAAO,IAAI,UAAU;KAAE,MAAM,KAAK;KAAM,UAAU;IAAK,EAAE;IACrE,YAAY;KACV,IAAI,CAAC,YAAY;MACf,aAAa;KACf,OAAO;MACL,UAAU;KACZ;IACF,CAAC;GACH;EACF,CACF;CACF,CAAC;CACD,KAAK,QAAQ,MAAM;CACnB,aAAa;EACX,QAAQ,QAAQ;CAClB;AACF"}
|
|
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 await regenerateConfig(props, projectInfo);\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}\nconst esbuildBuildConfigLoader = async (absolutePath, root) => {\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 code = result.outputFiles[0]?.text;\n if (!code) throw new Error(`No output generated for ${absolutePath}`);\n const module = { exports: {} };\n const projectRequire = createRequire(absolutePath);\n const fn = new Function(\"module\", \"exports\", \"require\", \"process\", code);\n fn(module, module.exports, projectRequire, process);\n return {\n exports: module.exports,\n dependencies: Object.keys(result.metafile.inputs)\n };\n};\nasync function loadTamaguiBuildConfigAsync(tamaguiOptions, loadBuildConfigModule = esbuildBuildConfigLoader) {\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 evaluated = await loadBuildConfigModule(absolutePath, root);\n const out = evaluated.exports.default || evaluated.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 = evaluated.dependencies.map((file) => resolve(root, file));\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,aAA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e,kBAAkB,OAAO,WAAW;CACjD,IAAI,aAAa;CACjB,MAAM,UAAU,MAAM,QAAQ,QAAQ;EACpC,QAAQ;EACR,aAAa,CAAC,KAAK;EACnB,mBAAmB;GAAC;GAAO;GAAQ;GAAO;EAAM;EAChD,UAAU;EACV,OAAO;EACP,OAAO;GACL,oBAAoB;GACpB,gBAAgB;EAClB;EACA,SAAS,CAUP;GACE,MAAM;GACN,MAAM,EAAE,OAAO,aAAa;IAC1B,IAAI,SAAS;IACb,UAAU,EAAE,OAAO,IAAI,UAAU;KAAE,MAAM,KAAK;KAAM,UAAU;IAAK,EAAE;IACrE,YAAY;KACV,IAAI,CAAC,YAAY;MACf,aAAa;KACf,OAAO;MACL,UAAU;KACZ;IACF,CAAC;GACH;EACF,CACF;CACF,CAAC;CACD,KAAK,QAAQ,MAAM;CACnB,aAAa;EACX,QAAQ,QAAQ;CAClB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1215.1",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"clean:build": "tamagui-build clean:build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tamagui/animation-helpers": "3.0.0-beta.
|
|
49
|
-
"@tamagui/cli-color": "3.0.0-beta.
|
|
50
|
-
"@tamagui/compiler-core": "3.0.0-beta.
|
|
51
|
-
"@tamagui/config-default": "3.0.0-beta.
|
|
52
|
-
"@tamagui/core": "3.0.0-beta.
|
|
53
|
-
"@tamagui/dom": "3.0.0-beta.
|
|
54
|
-
"@tamagui/fake-react-native": "3.0.0-beta.
|
|
55
|
-
"@tamagui/generate-themes": "3.0.0-beta.
|
|
56
|
-
"@tamagui/helpers": "3.0.0-beta.
|
|
57
|
-
"@tamagui/helpers-node": "3.0.0-beta.
|
|
58
|
-
"@tamagui/react-native-web-internals": "3.0.0-beta.
|
|
59
|
-
"@tamagui/react-native-web-lite": "3.0.0-beta.
|
|
60
|
-
"@tamagui/shorthands": "3.0.0-beta.
|
|
61
|
-
"@tamagui/style-grammar": "3.0.0-beta.
|
|
62
|
-
"@tamagui/types": "3.0.0-beta.
|
|
63
|
-
"@tamagui/web": "3.0.0-beta.
|
|
48
|
+
"@tamagui/animation-helpers": "3.0.0-beta.1215.1",
|
|
49
|
+
"@tamagui/cli-color": "3.0.0-beta.1215.1",
|
|
50
|
+
"@tamagui/compiler-core": "3.0.0-beta.1215.1",
|
|
51
|
+
"@tamagui/config-default": "3.0.0-beta.1215.1",
|
|
52
|
+
"@tamagui/core": "3.0.0-beta.1215.1",
|
|
53
|
+
"@tamagui/dom": "3.0.0-beta.1215.1",
|
|
54
|
+
"@tamagui/fake-react-native": "3.0.0-beta.1215.1",
|
|
55
|
+
"@tamagui/generate-themes": "3.0.0-beta.1215.1",
|
|
56
|
+
"@tamagui/helpers": "3.0.0-beta.1215.1",
|
|
57
|
+
"@tamagui/helpers-node": "3.0.0-beta.1215.1",
|
|
58
|
+
"@tamagui/react-native-web-internals": "3.0.0-beta.1215.1",
|
|
59
|
+
"@tamagui/react-native-web-lite": "3.0.0-beta.1215.1",
|
|
60
|
+
"@tamagui/shorthands": "3.0.0-beta.1215.1",
|
|
61
|
+
"@tamagui/style-grammar": "3.0.0-beta.1215.1",
|
|
62
|
+
"@tamagui/types": "3.0.0-beta.1215.1",
|
|
63
|
+
"@tamagui/web": "3.0.0-beta.1215.1",
|
|
64
64
|
"browserslist": "^4.28.1",
|
|
65
65
|
"check-dependency-version-consistency": "^4.1.0",
|
|
66
66
|
"esbuild": "0.28.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"react-native-web": "~0.21.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@tamagui/build": "3.0.0-beta.
|
|
75
|
+
"@tamagui/build": "3.0.0-beta.1215.1",
|
|
76
76
|
"@types/find-root": "^1.1.2",
|
|
77
77
|
"@types/node": "^22.1.0",
|
|
78
78
|
"@types/webpack": "^4.41.26",
|
|
@@ -208,11 +208,59 @@ export function getTamaguiBuildConfigDependencies(
|
|
|
208
208
|
return buildConfigDependencies.get(options) ?? []
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
export type EvaluatedBuildConfigModule = {
|
|
212
|
+
/** the module's exports, default included */
|
|
213
|
+
exports: Record<string, unknown>
|
|
214
|
+
/** every file the evaluation read, absolute or relative to the project root */
|
|
215
|
+
dependencies: string[]
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Evaluate tamagui.build.ts. A host with its own module runner passes one of
|
|
220
|
+
* these instead, so the build file goes through the same resolution as the rest
|
|
221
|
+
* of the app and no second toolchain has to be running.
|
|
222
|
+
*/
|
|
223
|
+
export type BuildConfigLoader = (
|
|
224
|
+
absolutePath: string,
|
|
225
|
+
root: string
|
|
226
|
+
) => Promise<EvaluatedBuildConfigModule>
|
|
227
|
+
|
|
228
|
+
// the fallback for hosts with no module runner of their own: bundle the build
|
|
229
|
+
// file and its relative imports into one CJS module and run it. packages stay
|
|
230
|
+
// external so they resolve through node exactly as they would at require time.
|
|
231
|
+
const esbuildBuildConfigLoader: BuildConfigLoader = async (absolutePath, root) => {
|
|
232
|
+
const result = await esbuild.build({
|
|
233
|
+
entryPoints: [absolutePath],
|
|
234
|
+
absWorkingDir: root,
|
|
235
|
+
bundle: true,
|
|
236
|
+
packages: 'external',
|
|
237
|
+
platform: 'node',
|
|
238
|
+
format: 'cjs',
|
|
239
|
+
target: 'node18',
|
|
240
|
+
write: false,
|
|
241
|
+
metafile: true,
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
const code = result.outputFiles[0]?.text
|
|
245
|
+
if (!code) throw new Error(`No output generated for ${absolutePath}`)
|
|
246
|
+
|
|
247
|
+
const module = { exports: {} as Record<string, unknown> }
|
|
248
|
+
const projectRequire = createRequire(absolutePath)
|
|
249
|
+
const fn = new Function('module', 'exports', 'require', 'process', code)
|
|
250
|
+
fn(module, module.exports, projectRequire, process)
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
exports: module.exports,
|
|
254
|
+
dependencies: Object.keys(result.metafile.inputs),
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
211
258
|
/**
|
|
212
259
|
* Load tamagui.build.ts and its relative imports as one Node module.
|
|
213
260
|
*/
|
|
214
261
|
export async function loadTamaguiBuildConfigAsync(
|
|
215
|
-
tamaguiOptions: Partial<TamaguiOptions> | undefined
|
|
262
|
+
tamaguiOptions: Partial<TamaguiOptions> | undefined,
|
|
263
|
+
loadBuildConfigModule: BuildConfigLoader = esbuildBuildConfigLoader
|
|
216
264
|
): Promise<TamaguiOptions> {
|
|
217
265
|
const buildFilePath = tamaguiOptions?.buildFile ?? './tamagui.build.ts'
|
|
218
266
|
const root = tamaguiOptions?.root || process.cwd()
|
|
@@ -220,26 +268,9 @@ export async function loadTamaguiBuildConfigAsync(
|
|
|
220
268
|
|
|
221
269
|
if (fsExtra.existsSync(absolutePath)) {
|
|
222
270
|
try {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
bundle: true,
|
|
227
|
-
packages: 'external',
|
|
228
|
-
platform: 'node',
|
|
229
|
-
format: 'cjs',
|
|
230
|
-
target: 'node18',
|
|
231
|
-
write: false,
|
|
232
|
-
metafile: true,
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
const module = { exports: {} as any }
|
|
236
|
-
const projectRequire = createRequire(absolutePath)
|
|
237
|
-
const code = result.outputFiles[0]?.text
|
|
238
|
-
if (!code) throw new Error(`No output generated for ${buildFilePath}`)
|
|
239
|
-
const fn = new Function('module', 'exports', 'require', 'process', code)
|
|
240
|
-
fn(module, module.exports, projectRequire, process)
|
|
241
|
-
|
|
242
|
-
const out = module.exports.default || module.exports
|
|
271
|
+
const evaluated = await loadBuildConfigModule(absolutePath, root)
|
|
272
|
+
|
|
273
|
+
const out = evaluated.exports.default || evaluated.exports
|
|
243
274
|
if (!out || typeof out !== 'object') {
|
|
244
275
|
throw new Error(`No default export found in ${buildFilePath}: ${out}`)
|
|
245
276
|
}
|
|
@@ -248,9 +279,7 @@ export async function loadTamaguiBuildConfigAsync(
|
|
|
248
279
|
...tamaguiOptions,
|
|
249
280
|
...out,
|
|
250
281
|
} as TamaguiOptions
|
|
251
|
-
const dependencies =
|
|
252
|
-
resolve(root, input)
|
|
253
|
-
)
|
|
282
|
+
const dependencies = evaluated.dependencies.map((file) => resolve(root, file))
|
|
254
283
|
buildConfigDependencies.set(loadedOptions, dependencies)
|
|
255
284
|
tamaguiOptions = loadedOptions
|
|
256
285
|
} catch (err) {
|
|
@@ -26,10 +26,22 @@ export type EvaluatedTamaguiProject = {
|
|
|
26
26
|
export declare function loadTamaguiFromModules(propsIn: Partial<TamaguiOptions>, evaluated: EvaluatedTamaguiProject): Promise<TamaguiProjectInfo>;
|
|
27
27
|
export declare const generateThemesAndLog: (options: TamaguiOptions, force?: boolean) => Promise<void>;
|
|
28
28
|
export declare function getTamaguiBuildConfigDependencies(options: TamaguiOptions): readonly string[];
|
|
29
|
+
export type EvaluatedBuildConfigModule = {
|
|
30
|
+
/** the module's exports, default included */
|
|
31
|
+
exports: Record<string, unknown>;
|
|
32
|
+
/** every file the evaluation read, absolute or relative to the project root */
|
|
33
|
+
dependencies: string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Evaluate tamagui.build.ts. A host with its own module runner passes one of
|
|
37
|
+
* these instead, so the build file goes through the same resolution as the rest
|
|
38
|
+
* of the app and no second toolchain has to be running.
|
|
39
|
+
*/
|
|
40
|
+
export type BuildConfigLoader = (absolutePath: string, root: string) => Promise<EvaluatedBuildConfigModule>;
|
|
29
41
|
/**
|
|
30
42
|
* Load tamagui.build.ts and its relative imports as one Node module.
|
|
31
43
|
*/
|
|
32
|
-
export declare function loadTamaguiBuildConfigAsync(tamaguiOptions: Partial<TamaguiOptions> | undefined): Promise<TamaguiOptions>;
|
|
44
|
+
export declare function loadTamaguiBuildConfigAsync(tamaguiOptions: Partial<TamaguiOptions> | undefined, loadBuildConfigModule?: BuildConfigLoader): Promise<TamaguiOptions>;
|
|
33
45
|
/**
|
|
34
46
|
* @deprecated Use loadTamaguiBuildConfigAsync instead to avoid EPIPE errors
|
|
35
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTamagui.d.ts","sourceRoot":"","sources":["../../src/extractor/loadTamagui.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAOxF,OAAO,EACL,KAAK,kBAAkB,EAQxB,MAAM,gBAAgB,CAAA;AAsBvB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,EAChC,OAAO,UAAQ,GACd,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAqCpC;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,UAAU,EAAE,sBAAsB,EAAE,CAAA;IACpC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,CAAA;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,EAChC,SAAS,EAAE,uBAAuB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAKD,eA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