@tamagui/static 2.7.7 → 3.0.0-beta.643.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/check-dep-versions.cjs +355 -0
- package/dist/cjs/checkDeps.cjs +302 -0
- package/dist/cjs/compiler.cjs +286 -0
- package/dist/cjs/compilerHost.cjs +1695 -0
- package/dist/cjs/constants.cjs +33 -0
- package/dist/cjs/domStructuralPass.cjs +112 -0
- package/dist/cjs/exports.cjs +42 -0
- package/dist/cjs/extractor/addLocalExports.cjs +64 -0
- package/dist/cjs/extractor/bundle.cjs +203 -0
- package/dist/cjs/extractor/bundleConfig.cjs +747 -0
- package/dist/cjs/extractor/concatClassName.cjs +117 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +54 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +47 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +92 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +38 -0
- package/dist/cjs/extractor/loadTamagui.cjs +344 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +161 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +64 -0
- package/dist/cjs/getPragmaOptions.cjs +67 -0
- package/dist/cjs/helpers/memoize.cjs +42 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +40 -0
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/registerRequire.cjs +220 -0
- package/dist/cjs/server.cjs +66 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +86 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/zero/artifact.cjs +145 -0
- package/dist/cjs/zero/graph.cjs +209 -0
- package/dist/cjs/zero/identity.cjs +61 -0
- package/dist/cjs/zero/index.cjs +26 -0
- package/dist/cjs/zero/islands.cjs +232 -0
- package/dist/cjs/zero/options.cjs +163 -0
- package/dist/cjs/zero/ownership.cjs +79 -0
- package/dist/cjs/zero/theme.cjs +328 -0
- package/dist/cjs/zero/transform.cjs +203 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +255 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +1675 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +92 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +26 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +173 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +706 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +96 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +18 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +306 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +15 -0
- package/dist/esm/zero/islands.mjs +197 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +303 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +177 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +33 -43
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +425 -0
- package/src/compilerHost.ts +3125 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +170 -0
- package/src/exports.ts +3 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +20 -35
- package/src/extractor/bundleConfig.ts +334 -187
- package/src/extractor/concatClassName.ts +13 -20
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +5 -4
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +8 -0
- package/src/zero/islands.ts +262 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +478 -0
- package/src/zero/transform.ts +320 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +117 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +25 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +3 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +19 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +9 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +83 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/errors.d.ts +0 -3
- package/types/extractor/errors.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Bryan Mishkin",
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import FastGlob from 'fast-glob'
|
|
7
7
|
import { load } from 'js-yaml'
|
|
8
8
|
import { existsSync, readFileSync } from 'node:fs'
|
|
9
9
|
import { join, relative } from 'node:path'
|
|
@@ -399,7 +399,7 @@ function expandWorkspaces(
|
|
|
399
399
|
}
|
|
400
400
|
// Use cwd instead of passing join()'d paths to globby for Windows support: https://github.com/micromatch/micromatch/blob/34f44b4f57eacbdbcc74f64252e0845cf44bbdbd/README.md?plain=1#L822
|
|
401
401
|
// Ignore any node_modules that may be present due to the use of nohoist.
|
|
402
|
-
return globSync(workspace, {
|
|
402
|
+
return FastGlob.globSync(workspace, {
|
|
403
403
|
onlyDirectories: true,
|
|
404
404
|
cwd: root,
|
|
405
405
|
ignore: ['**/node_modules'],
|
package/src/checkDeps.ts
CHANGED
|
@@ -359,7 +359,7 @@ export async function checkDeps(root: string) {
|
|
|
359
359
|
|
|
360
360
|
if (issues.length === 0) {
|
|
361
361
|
console.info(`Tamagui dependencies look good ✅`)
|
|
362
|
-
|
|
362
|
+
return
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
for (let i = 0; i < issues.length; i++) {
|
|
@@ -367,5 +367,6 @@ export async function checkDeps(root: string) {
|
|
|
367
367
|
console.error(issues[i])
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
// the caller owns the exit; `tamagui check` still has the style half to run
|
|
371
|
+
process.exitCode = 1
|
|
371
372
|
}
|
package/src/compiler.ts
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompilerSession,
|
|
3
|
+
LOWERED_MODULE_PLAN_VERSION,
|
|
4
|
+
ModulePlanCache,
|
|
5
|
+
PLAN_CACHE_SCHEMA_VERSION,
|
|
6
|
+
contentHash,
|
|
7
|
+
defaultPlanCacheRoot,
|
|
8
|
+
resolvedModuleId,
|
|
9
|
+
stableStringify,
|
|
10
|
+
yukuFactory,
|
|
11
|
+
type AppliedLoweredModule,
|
|
12
|
+
type CompilerTarget,
|
|
13
|
+
type HostModuleInput,
|
|
14
|
+
type LoweredModulePlan,
|
|
15
|
+
type ResolvedModuleId,
|
|
16
|
+
} from '@tamagui/compiler-core'
|
|
17
|
+
import type { TamaguiOptions } from '@tamagui/types'
|
|
18
|
+
import { readFileSync } from 'node:fs'
|
|
19
|
+
import { createRequire } from 'node:module'
|
|
20
|
+
import path from 'node:path'
|
|
21
|
+
|
|
22
|
+
import { createTamaguiCompilerHost } from './compilerHost'
|
|
23
|
+
import { domStructuralPass } from './domStructuralPass'
|
|
24
|
+
import type { TamaguiProjectInfo } from './extractor/bundleConfig'
|
|
25
|
+
import { loadTamagui } from './extractor/loadTamagui'
|
|
26
|
+
import { resolveZeroRuntimeSync } from './zero/options'
|
|
27
|
+
|
|
28
|
+
export interface CompilerProjectComponentModule {
|
|
29
|
+
moduleName: string
|
|
30
|
+
id: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CompilerProject {
|
|
34
|
+
projectInfo: TamaguiProjectInfo
|
|
35
|
+
componentModules: CompilerProjectComponentModule[]
|
|
36
|
+
generation: string
|
|
37
|
+
/** Keep elements with dynamic style props fully on the runtime path. */
|
|
38
|
+
disablePartialExtraction?: boolean
|
|
39
|
+
/** emit native theme-token mappings for the native style engine */
|
|
40
|
+
experimentalNativeFastPath?: boolean
|
|
41
|
+
/** Zero-runtime mode, which makes the host's diagnostics mode-aware. */
|
|
42
|
+
zeroRuntime?: boolean
|
|
43
|
+
/**
|
|
44
|
+
* Content identity of everything a lowering plan depends on that is not a
|
|
45
|
+
* module: the compiler build, the evaluated config and component registry,
|
|
46
|
+
* the platform, and the modes. Null when the project could not name the files
|
|
47
|
+
* that determine it, in which case nothing is cached to disk.
|
|
48
|
+
*/
|
|
49
|
+
cacheStamp: string | null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface LoadCompilerProjectInput {
|
|
53
|
+
root: string
|
|
54
|
+
target: CompilerTarget
|
|
55
|
+
options: Partial<TamaguiOptions>
|
|
56
|
+
generation:
|
|
57
|
+
| string
|
|
58
|
+
| ((
|
|
59
|
+
projectInfo: TamaguiProjectInfo,
|
|
60
|
+
componentModules: CompilerProjectComponentModule[],
|
|
61
|
+
options: TamaguiOptions
|
|
62
|
+
) => string)
|
|
63
|
+
rebuild?: boolean
|
|
64
|
+
/**
|
|
65
|
+
* `name@version` for the host integration package, folded into the cache
|
|
66
|
+
* stamp so a plugin upgrade cannot reuse plans built by the previous one.
|
|
67
|
+
*/
|
|
68
|
+
hostVersions?: readonly string[]
|
|
69
|
+
missingProjectMessage?: string
|
|
70
|
+
load?: (options: TamaguiOptions, rebuild: boolean) => Promise<TamaguiProjectInfo | null>
|
|
71
|
+
resolveComponents?: (
|
|
72
|
+
moduleNames: readonly string[],
|
|
73
|
+
projectInfo: TamaguiProjectInfo,
|
|
74
|
+
options: TamaguiOptions
|
|
75
|
+
) => Promise<CompilerProjectComponentModule[]>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* normalize and load the compiler-owned project contract. module resolution and
|
|
80
|
+
* evaluation stay with the adapter through the two callbacks.
|
|
81
|
+
*/
|
|
82
|
+
export async function loadCompilerProject({
|
|
83
|
+
root,
|
|
84
|
+
target,
|
|
85
|
+
options: optionsIn,
|
|
86
|
+
generation,
|
|
87
|
+
rebuild = false,
|
|
88
|
+
hostVersions = [],
|
|
89
|
+
missingProjectMessage = 'Unable to load the Tamagui compiler project',
|
|
90
|
+
load = loadTamagui,
|
|
91
|
+
resolveComponents,
|
|
92
|
+
}: LoadCompilerProjectInput): Promise<CompilerProject> {
|
|
93
|
+
const components = [
|
|
94
|
+
...new Set(['@tamagui/core', ...(optionsIn.components || ['tamagui'])]),
|
|
95
|
+
]
|
|
96
|
+
const options = {
|
|
97
|
+
...optionsIn,
|
|
98
|
+
root,
|
|
99
|
+
platform: target,
|
|
100
|
+
components,
|
|
101
|
+
} as TamaguiOptions
|
|
102
|
+
const zeroRuntime = resolveZeroRuntimeSync(options, root).mode
|
|
103
|
+
if (zeroRuntime === 'enforce') options.outputCSS = undefined
|
|
104
|
+
|
|
105
|
+
const projectInfo = await load(options, rebuild)
|
|
106
|
+
if (!projectInfo?.tamaguiConfig || !projectInfo.components) {
|
|
107
|
+
throw new Error(missingProjectMessage)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const componentModules = resolveComponents
|
|
111
|
+
? await resolveComponents(components, projectInfo, options)
|
|
112
|
+
: []
|
|
113
|
+
|
|
114
|
+
const disablePartialExtraction = !!options.disablePartialExtraction
|
|
115
|
+
const experimentalNativeFastPath =
|
|
116
|
+
target === 'native' && options.experimental?.nativeFastPath === true
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
projectInfo,
|
|
120
|
+
componentModules,
|
|
121
|
+
generation:
|
|
122
|
+
typeof generation === 'function'
|
|
123
|
+
? generation(projectInfo, componentModules, options)
|
|
124
|
+
: generation,
|
|
125
|
+
disablePartialExtraction,
|
|
126
|
+
experimentalNativeFastPath,
|
|
127
|
+
zeroRuntime: zeroRuntime !== 'off',
|
|
128
|
+
cacheStamp: compilerProjectStamp({
|
|
129
|
+
stampSources: projectInfo.stampSources ?? [],
|
|
130
|
+
hostVersions,
|
|
131
|
+
target,
|
|
132
|
+
componentModules,
|
|
133
|
+
disablePartialExtraction,
|
|
134
|
+
experimentalNativeFastPath,
|
|
135
|
+
zeroRuntime: zeroRuntime !== 'off',
|
|
136
|
+
development: process.env.NODE_ENV === 'development',
|
|
137
|
+
}),
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const requireFromCompiler = createRequire(
|
|
142
|
+
typeof __filename === 'string' ? __filename : import.meta.url
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
// upgrading the compiler must invalidate cached plans even when nothing about
|
|
146
|
+
// the project changed
|
|
147
|
+
const compilerPackageVersions = ['@tamagui/compiler-core', '@tamagui/static'].map(
|
|
148
|
+
(name) =>
|
|
149
|
+
`${name}@${(requireFromCompiler(`${name}/package.json`) as { version: string }).version}`
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The non-module half of every plan cache key. Null when the project named no
|
|
154
|
+
* stamp sources: a stamp that cannot see a config change is worse than no
|
|
155
|
+
* cache, so that project simply does not cache.
|
|
156
|
+
*/
|
|
157
|
+
export function compilerProjectStamp(input: {
|
|
158
|
+
stampSources: readonly string[]
|
|
159
|
+
hostVersions: readonly string[]
|
|
160
|
+
target: CompilerTarget
|
|
161
|
+
componentModules: readonly CompilerProjectComponentModule[]
|
|
162
|
+
disablePartialExtraction: boolean
|
|
163
|
+
experimentalNativeFastPath: boolean
|
|
164
|
+
zeroRuntime: boolean
|
|
165
|
+
/**
|
|
166
|
+
* `process.env.NODE_ENV === 'development'` in the process that builds plans.
|
|
167
|
+
* The host emits debug-receipt edits into `plan.edits` only in development
|
|
168
|
+
* (compilerHost.ts's developmentDebugInstrumentation), so a development plan
|
|
169
|
+
* is not a plan a production build may reuse. This is the ONLY ambient input
|
|
170
|
+
* to a plan, and it lives in the stamp so every host inherits it rather than
|
|
171
|
+
* each one remembering to add it to its own key.
|
|
172
|
+
*/
|
|
173
|
+
development: boolean
|
|
174
|
+
}): string | null {
|
|
175
|
+
if (!input.stampSources.length) return null
|
|
176
|
+
const sources: [string, string][] = []
|
|
177
|
+
for (const file of [...new Set(input.stampSources)].sort()) {
|
|
178
|
+
try {
|
|
179
|
+
sources.push([file, contentHash(readFileSync(file))])
|
|
180
|
+
} catch {
|
|
181
|
+
// a source the project named but that is not readable makes the stamp
|
|
182
|
+
// incomplete, and an incomplete stamp is what ships stale styles
|
|
183
|
+
return null
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return contentHash(
|
|
187
|
+
stableStringify({
|
|
188
|
+
schema: PLAN_CACHE_SCHEMA_VERSION,
|
|
189
|
+
plan: LOWERED_MODULE_PLAN_VERSION,
|
|
190
|
+
packages: [...compilerPackageVersions, ...input.hostVersions].sort(),
|
|
191
|
+
target: input.target,
|
|
192
|
+
development: input.development,
|
|
193
|
+
componentModules: input.componentModules.map(({ moduleName, id }) => [
|
|
194
|
+
moduleName,
|
|
195
|
+
cleanId(id),
|
|
196
|
+
]),
|
|
197
|
+
disablePartialExtraction: input.disablePartialExtraction,
|
|
198
|
+
experimentalNativeFastPath: input.experimentalNativeFastPath,
|
|
199
|
+
zeroRuntime: input.zeroRuntime,
|
|
200
|
+
sources,
|
|
201
|
+
})
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface CompilerResolution {
|
|
206
|
+
id: string
|
|
207
|
+
external?: boolean
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface CompilerInput {
|
|
211
|
+
id: string
|
|
212
|
+
source: string
|
|
213
|
+
root: string
|
|
214
|
+
target: CompilerTarget
|
|
215
|
+
project: CompilerProject
|
|
216
|
+
resolve(specifier: string, importer: string): Promise<CompilerResolution | null>
|
|
217
|
+
load(id: string): Promise<string | null>
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export type CompilerUpdateInput = Omit<CompilerInput, 'target'>
|
|
221
|
+
|
|
222
|
+
export interface CompilerResult {
|
|
223
|
+
plan: LoweredModulePlan
|
|
224
|
+
output: AppliedLoweredModule
|
|
225
|
+
invalidatedIds: ResolvedModuleId[]
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function cleanId(id: string): string {
|
|
229
|
+
return id.split(/[?#]/, 1)[0]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function externalId(specifier: string): ResolvedModuleId {
|
|
233
|
+
return resolvedModuleId(`external://${encodeURIComponent(specifier)}`)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function sourceCanBeLinked(root: string, id: string): boolean {
|
|
237
|
+
const clean = cleanId(id)
|
|
238
|
+
const normalized = clean.replace(/\\/g, '/')
|
|
239
|
+
if (!path.isAbsolute(clean) || normalized.includes('/node_modules/')) return false
|
|
240
|
+
const relative = path.relative(root, clean)
|
|
241
|
+
return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`))
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Long-lived host-resolved graph frontend. The adapter supplies every identity and
|
|
246
|
+
* load result; compiler-core never guesses package, alias, or workspace resolution.
|
|
247
|
+
*/
|
|
248
|
+
export class CompilerFrontend {
|
|
249
|
+
private readonly session = new CompilerSession()
|
|
250
|
+
private queue: Promise<unknown> = Promise.resolve()
|
|
251
|
+
private readonly planCaches = new Map<string, ModulePlanCache>()
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* One cache per project root and platform. Absent when the project produced
|
|
255
|
+
* no content stamp, in which case plans are never persisted rather than
|
|
256
|
+
* persisted under an identity that cannot see a config change.
|
|
257
|
+
*/
|
|
258
|
+
private planCacheFor(
|
|
259
|
+
input: CompilerInput
|
|
260
|
+
): { store: ModulePlanCache; stamp: string } | undefined {
|
|
261
|
+
const stamp = input.project.cacheStamp
|
|
262
|
+
if (!stamp) return undefined
|
|
263
|
+
const root = defaultPlanCacheRoot(input.root, input.target)
|
|
264
|
+
let store = this.planCaches.get(root)
|
|
265
|
+
if (!store) {
|
|
266
|
+
store = new ModulePlanCache(root)
|
|
267
|
+
this.planCaches.set(root, store)
|
|
268
|
+
}
|
|
269
|
+
return { store, stamp }
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Hits, misses and writes across every plan cache this frontend has used. */
|
|
273
|
+
get planCacheStats(): { hits: number; misses: number; writes: number } {
|
|
274
|
+
const total = { hits: 0, misses: 0, writes: 0 }
|
|
275
|
+
for (const store of this.planCaches.values()) {
|
|
276
|
+
total.hits += store.stats.hits
|
|
277
|
+
total.misses += store.stats.misses
|
|
278
|
+
total.writes += store.stats.writes
|
|
279
|
+
}
|
|
280
|
+
return total
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
compile(input: CompilerInput): Promise<CompilerResult> {
|
|
284
|
+
const operation = this.queue.then(() => this.compileNow(input))
|
|
285
|
+
this.queue = operation.catch(() => undefined)
|
|
286
|
+
return operation
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
update(input: CompilerUpdateInput): Promise<ResolvedModuleId[]> {
|
|
290
|
+
const operation = this.queue.then(async () => {
|
|
291
|
+
const { modules } = await this.buildTree(input)
|
|
292
|
+
const invalidated = new Set<ResolvedModuleId>()
|
|
293
|
+
for (const module of modules.values()) {
|
|
294
|
+
for (const id of await this.session.update(module)) invalidated.add(id)
|
|
295
|
+
}
|
|
296
|
+
return [...invalidated].sort()
|
|
297
|
+
})
|
|
298
|
+
this.queue = operation.catch(() => undefined)
|
|
299
|
+
return operation
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
has(id: string): boolean {
|
|
303
|
+
return this.session.has(resolvedModuleId(cleanId(id)))
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
dependentsOf(id: string): ResolvedModuleId[] {
|
|
307
|
+
return this.session.dependentsOf(resolvedModuleId(cleanId(id)))
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
remove(id: string) {
|
|
311
|
+
const operation = this.queue.then(() =>
|
|
312
|
+
this.session.remove(resolvedModuleId(cleanId(id)))
|
|
313
|
+
)
|
|
314
|
+
this.queue = operation.catch(() => undefined)
|
|
315
|
+
return operation
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
parseCount(id: string): number {
|
|
319
|
+
return this.session.parseCount(resolvedModuleId(cleanId(id)))
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private async compileNow(input: CompilerInput): Promise<CompilerResult> {
|
|
323
|
+
const { rootModule, modules } = await this.buildTree(input)
|
|
324
|
+
const invalidated = new Set<ResolvedModuleId>()
|
|
325
|
+
for (const module of modules.values()) {
|
|
326
|
+
for (const id of await this.session.update(module)) invalidated.add(id)
|
|
327
|
+
}
|
|
328
|
+
const projectInfo = input.project.projectInfo
|
|
329
|
+
if (!projectInfo.tamaguiConfig || !projectInfo.components) {
|
|
330
|
+
throw new Error('The compiler requires evaluated Tamagui config and components')
|
|
331
|
+
}
|
|
332
|
+
const host = createTamaguiCompilerHost({
|
|
333
|
+
target: input.target,
|
|
334
|
+
tamaguiConfig: projectInfo.tamaguiConfig,
|
|
335
|
+
components: projectInfo.components,
|
|
336
|
+
componentModules: input.project.componentModules.map((component) => ({
|
|
337
|
+
moduleName: component.moduleName,
|
|
338
|
+
resolvedId: cleanId(component.id),
|
|
339
|
+
})),
|
|
340
|
+
disablePartialExtraction: input.project.disablePartialExtraction,
|
|
341
|
+
experimentalNativeFastPath: input.project.experimentalNativeFastPath,
|
|
342
|
+
zeroRuntime: input.project.zeroRuntime,
|
|
343
|
+
})
|
|
344
|
+
const result = await this.session.compile({
|
|
345
|
+
module: rootModule,
|
|
346
|
+
adapter: {
|
|
347
|
+
target: input.target,
|
|
348
|
+
projectGeneration: input.project.generation,
|
|
349
|
+
host,
|
|
350
|
+
planCache: this.planCacheFor(input),
|
|
351
|
+
async load(id) {
|
|
352
|
+
return modules.get(id) ?? null
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
structuralPass: domStructuralPass,
|
|
356
|
+
})
|
|
357
|
+
for (const id of result.invalidatedIds) invalidated.add(id)
|
|
358
|
+
return {
|
|
359
|
+
plan: result.plan,
|
|
360
|
+
output: result.output,
|
|
361
|
+
invalidatedIds: [...invalidated].sort(),
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
private async buildTree(input: CompilerUpdateInput): Promise<{
|
|
366
|
+
rootModule: HostModuleInput
|
|
367
|
+
modules: Map<ResolvedModuleId, HostModuleInput>
|
|
368
|
+
}> {
|
|
369
|
+
const componentBySpecifier = new Map(
|
|
370
|
+
input.project.componentModules.map((component) => [
|
|
371
|
+
component.moduleName,
|
|
372
|
+
resolvedModuleId(cleanId(component.id)),
|
|
373
|
+
])
|
|
374
|
+
)
|
|
375
|
+
const modules = new Map<ResolvedModuleId, HostModuleInput>()
|
|
376
|
+
const loading = new Set<ResolvedModuleId>()
|
|
377
|
+
|
|
378
|
+
const loadModule = async (
|
|
379
|
+
rawId: string,
|
|
380
|
+
source: string
|
|
381
|
+
): Promise<HostModuleInput> => {
|
|
382
|
+
const id = resolvedModuleId(cleanId(rawId))
|
|
383
|
+
const existing = modules.get(id)
|
|
384
|
+
if (existing) return existing
|
|
385
|
+
if (loading.has(id)) {
|
|
386
|
+
return { id, source, imports: [] }
|
|
387
|
+
}
|
|
388
|
+
loading.add(id)
|
|
389
|
+
|
|
390
|
+
const imports: HostModuleInput['imports'][number][] = []
|
|
391
|
+
for (const specifier of yukuFactory.scanImports(id, source)) {
|
|
392
|
+
const configuredComponent = componentBySpecifier.get(specifier)
|
|
393
|
+
if (configuredComponent) {
|
|
394
|
+
imports.push({ specifier, resolvedId: configuredComponent, external: true })
|
|
395
|
+
continue
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const resolution = await input.resolve(specifier, id)
|
|
399
|
+
if (!resolution) continue
|
|
400
|
+
const canLink =
|
|
401
|
+
!resolution.external && sourceCanBeLinked(input.root, resolution.id)
|
|
402
|
+
const resolvedId = canLink
|
|
403
|
+
? resolvedModuleId(cleanId(resolution.id))
|
|
404
|
+
: path.isAbsolute(cleanId(resolution.id))
|
|
405
|
+
? resolvedModuleId(cleanId(resolution.id))
|
|
406
|
+
: externalId(specifier)
|
|
407
|
+
imports.push({ specifier, resolvedId, external: !canLink })
|
|
408
|
+
if (canLink && !modules.has(resolvedId) && !loading.has(resolvedId)) {
|
|
409
|
+
const dependencySource = await input.load(resolution.id)
|
|
410
|
+
if (dependencySource !== null) {
|
|
411
|
+
await loadModule(resolution.id, dependencySource)
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const module = { id, source, imports }
|
|
417
|
+
modules.set(id, module)
|
|
418
|
+
loading.delete(id)
|
|
419
|
+
return module
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const rootModule = await loadModule(input.id, input.source)
|
|
423
|
+
return { rootModule, modules }
|
|
424
|
+
}
|
|
425
|
+
}
|