@tamagui/metro-plugin 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/README.md +12 -0
- package/dist/cjs/babel.cjs +77 -0
- package/dist/cjs/compilerCache.cjs +237 -0
- package/dist/cjs/diagnostics.cjs +41 -0
- package/dist/cjs/frontend.cjs +870 -0
- package/dist/cjs/index.cjs +102 -0
- package/dist/cjs/lowering.cjs +109 -0
- package/dist/cjs/metroResolver.cjs +197 -0
- package/dist/cjs/transformOptions.cjs +35 -0
- package/dist/cjs/transformer.cjs +142 -0
- package/dist/cjs/zeroRuntime.cjs +140 -0
- package/dist/cjs/zeroSerializer.cjs +150 -0
- package/dist/esm/babel.mjs +52 -0
- package/dist/esm/babel.mjs.map +1 -0
- package/dist/esm/compilerCache.mjs +212 -0
- package/dist/esm/compilerCache.mjs.map +1 -0
- package/dist/esm/diagnostics.mjs +18 -0
- package/dist/esm/diagnostics.mjs.map +1 -0
- package/dist/esm/frontend.mjs +839 -0
- package/dist/esm/frontend.mjs.map +1 -0
- package/dist/esm/index.mjs +64 -22
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/lowering.mjs +89 -0
- package/dist/esm/lowering.mjs.map +1 -0
- package/dist/esm/metroResolver.mjs +173 -0
- package/dist/esm/metroResolver.mjs.map +1 -0
- package/dist/esm/transformOptions.mjs +14 -0
- package/dist/esm/transformOptions.mjs.map +1 -0
- package/dist/esm/transformer.mjs +119 -0
- package/dist/esm/transformer.mjs.map +1 -0
- package/dist/esm/zeroRuntime.mjs +105 -0
- package/dist/esm/zeroRuntime.mjs.map +1 -0
- package/dist/esm/zeroSerializer.mjs +123 -0
- package/dist/esm/zeroSerializer.mjs.map +1 -0
- package/package.json +33 -5
- package/src/babel.ts +87 -0
- package/src/compilerCache.ts +346 -0
- package/src/diagnostics.ts +47 -0
- package/src/frontend.ts +1178 -0
- package/src/index.ts +117 -14
- package/src/lowering.ts +136 -0
- package/src/metroResolver.ts +209 -0
- package/src/transformOptions.ts +36 -0
- package/src/transformer.ts +210 -0
- package/src/zeroRuntime.ts +212 -0
- package/src/zeroSerializer.ts +175 -0
- package/types/babel.d.ts +28 -0
- package/types/babel.d.ts.map +11 -0
- package/types/compilerCache.d.ts +63 -0
- package/types/compilerCache.d.ts.map +11 -0
- package/types/diagnostics.d.ts +16 -0
- package/types/diagnostics.d.ts.map +11 -0
- package/types/frontend.d.ts +73 -0
- package/types/frontend.d.ts.map +11 -0
- package/types/index.d.ts +49 -32
- package/types/index.d.ts.map +11 -1
- package/types/lowering.d.ts +20 -0
- package/types/lowering.d.ts.map +11 -0
- package/types/metroResolver.d.ts +21 -0
- package/types/metroResolver.d.ts.map +11 -0
- package/types/transformOptions.d.ts +13 -0
- package/types/transformOptions.d.ts.map +11 -0
- package/types/transformer.d.ts +26 -0
- package/types/transformer.d.ts.map +11 -0
- package/types/zeroRuntime.d.ts +75 -0
- package/types/zeroRuntime.d.ts.map +11 -0
- package/types/zeroSerializer.d.ts +6 -0
- package/types/zeroSerializer.d.ts.map +11 -0
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/index.js +0 -25
- package/dist/esm/index.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { IslandThemeBridge, TamaguiOptions, ZeroCSSArtifact, ZeroRuntimeResolved, ZeroViolationSite } from "@tamagui/static";
|
|
2
|
+
/**
|
|
3
|
+
* Metro's half of the zero-runtime mode.
|
|
4
|
+
*
|
|
5
|
+
* Metro fixes a module's dependencies at resolution time and does no
|
|
6
|
+
* export-level shaking, so nothing after the transform can remove an import.
|
|
7
|
+
* The frontend already lowers every module up front and publishes plans that
|
|
8
|
+
* workers apply before Babel runs, which is the one place early enough: zero
|
|
9
|
+
* reference erasure rides those same plans.
|
|
10
|
+
*
|
|
11
|
+
* An island is a second Metro bundle request rather than a child compilation,
|
|
12
|
+
* because Metro has no sub-compilation concept. The two requests are separate
|
|
13
|
+
* processes, so the CSS coordinator hands island fragments over on disk.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ZERO_CSS_FILENAME = "tamagui-zero.css";
|
|
16
|
+
export declare const ZERO_ISLAND_DIRNAME = "tamagui-islands";
|
|
17
|
+
export interface MetroZeroController {
|
|
18
|
+
resolved: ZeroRuntimeResolved;
|
|
19
|
+
artifact: ZeroCSSArtifact;
|
|
20
|
+
cssHref: string;
|
|
21
|
+
root: string;
|
|
22
|
+
/** Directory the artifact and island bundle are published from. */
|
|
23
|
+
publicDir: string;
|
|
24
|
+
/** Island id when this Metro invocation is building an island, else null. */
|
|
25
|
+
islandBuild: string | null;
|
|
26
|
+
bridges: Map<string, IslandThemeBridge[]>;
|
|
27
|
+
violations: ZeroViolationSite[];
|
|
28
|
+
/** Modules the zero transform ran on, for the erased-export gate. */
|
|
29
|
+
transformed: Set<string>;
|
|
30
|
+
/** Erased exported declarator names, by declaring module. */
|
|
31
|
+
erasedExports: Map<string, string[]>;
|
|
32
|
+
loaderIds: Map<string, string>;
|
|
33
|
+
islandModuleIds: Map<string, string>;
|
|
34
|
+
/** False in `report` mode, where the analysis runs and nothing else changes. */
|
|
35
|
+
isEnforcing: boolean;
|
|
36
|
+
/** The evaluated config's CSS, set once the frontend has loaded the project. */
|
|
37
|
+
configCSS: string;
|
|
38
|
+
/**
|
|
39
|
+
* True when this build restored the artifact from the plan cache's CSS
|
|
40
|
+
* sidecar instead of rescanning. Recorded in the receipt so a warm rebuild
|
|
41
|
+
* that silently stopped reusing plans, or one that reused them without
|
|
42
|
+
* restoring the artifact, is visible rather than inferred from timing.
|
|
43
|
+
*/
|
|
44
|
+
plansRestoredFromCache: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const zeroModuleKey: (value: string) => string;
|
|
47
|
+
/** Where an island build leaves its CSS fragment for the zero build to collect. */
|
|
48
|
+
export declare function islandFragmentPath(outDir: string, islandId: string): string;
|
|
49
|
+
export declare function islandBundleHashPath(outDir: string, islandId: string): string;
|
|
50
|
+
export declare function createMetroZeroController(options: TamaguiOptions, root: string, islandBuild: string | null, publicDirName: string): MetroZeroController | null;
|
|
51
|
+
/**
|
|
52
|
+
* Generated shim modules for the island bundle's React handoff.
|
|
53
|
+
*
|
|
54
|
+
* Metro has no externals option, so the island build redirects `react`,
|
|
55
|
+
* `react-dom`, and `react/jsx-runtime` through these, which read the handoff
|
|
56
|
+
* the generated loader publishes. One React instance serves both graphs.
|
|
57
|
+
*/
|
|
58
|
+
export declare function writeIslandRuntimeShims(outDir: string): Record<string, string>;
|
|
59
|
+
export interface MetroZeroFinalizeInput {
|
|
60
|
+
controller: MetroZeroController;
|
|
61
|
+
/** The serialized bundle, hashed into the island's output receipt. */
|
|
62
|
+
bundleCode: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Writes the one CSS artifact for a zero build, or this island's fragment for
|
|
66
|
+
* an island build. `TAMAGUI_DID_OUTPUT_CSS` is derived only when every declared
|
|
67
|
+
* island fragment is present.
|
|
68
|
+
*/
|
|
69
|
+
export declare function finalizeMetroZero(input: MetroZeroFinalizeInput): {
|
|
70
|
+
cssPath: string;
|
|
71
|
+
hash: string;
|
|
72
|
+
islandOutputHashes: Record<string, string>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=zeroRuntime.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAKA,cACE,mBACA,gBACA,iBACA,qBACA,yBACK;;;;;;;;;;;;;;AAgBP,OAAO,cAAM,oBAAoB;AACjC,OAAO,cAAM,sBAAsB;AAEnC,iBAAiB,oBAAoB;CACnC,UAAU;CACV,UAAU;CACV;CACA;;CAEA;;CAEA;CACA,SAAS,YAAY;CACrB,YAAY;;CAEZ,aAAa;;CAEb,eAAe;CACf,WAAW;CACX,iBAAiB;;CAEjB;;CAEA;;;;;;;CAOA;;AAKF,OAAO,cAAM,gBAAiB;;AAI9B,OAAO,iBAAS,mBAAmB,gBAAgB;AAInD,OAAO,iBAAS,qBAAqB,gBAAgB;AAIrD,OAAO,iBAAS,0BACd,SAAS,gBACT,cACA,4BACA,wBACC;;;;;;;;AAqDH,OAAO,iBAAS,wBAAwB,iBAAiB;AAmBzD,iBAAiB,uBAAuB;CACtC,YAAY;;CAEZ;;;;;;;AAQF,OAAO,iBAAS,kBAAkB,OAAO,yBAAyB;CAChE;CACA;CACA,oBAAoB",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/zeroRuntime.ts"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"import { createHash } from 'node:crypto'\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\n\nimport Static from '@tamagui/static'\nimport type {\n IslandThemeBridge,\n TamaguiOptions,\n ZeroCSSArtifact,\n ZeroRuntimeResolved,\n ZeroViolationSite,\n} from '@tamagui/static'\n\n/**\n * Metro's half of the zero-runtime mode.\n *\n * Metro fixes a module's dependencies at resolution time and does no\n * export-level shaking, so nothing after the transform can remove an import.\n * The frontend already lowers every module up front and publishes plans that\n * workers apply before Babel runs, which is the one place early enough: zero\n * reference erasure rides those same plans.\n *\n * An island is a second Metro bundle request rather than a child compilation,\n * because Metro has no sub-compilation concept. The two requests are separate\n * processes, so the CSS coordinator hands island fragments over on disk.\n */\n\nexport const ZERO_CSS_FILENAME = 'tamagui-zero.css'\nexport const ZERO_ISLAND_DIRNAME = 'tamagui-islands'\n\nexport interface MetroZeroController {\n resolved: ZeroRuntimeResolved\n artifact: ZeroCSSArtifact\n cssHref: string\n root: string\n /** Directory the artifact and island bundle are published from. */\n publicDir: string\n /** Island id when this Metro invocation is building an island, else null. */\n islandBuild: string | null\n bridges: Map<string, IslandThemeBridge[]>\n violations: ZeroViolationSite[]\n /** Modules the zero transform ran on, for the erased-export gate. */\n transformed: Set<string>\n /** Erased exported declarator names, by declaring module. */\n erasedExports: Map<string, string[]>\n loaderIds: Map<string, string>\n islandModuleIds: Map<string, string>\n /** False in `report` mode, where the analysis runs and nothing else changes. */\n isEnforcing: boolean\n /** The evaluated config's CSS, set once the frontend has loaded the project. */\n configCSS: string\n /**\n * True when this build restored the artifact from the plan cache's CSS\n * sidecar instead of rescanning. Recorded in the receipt so a warm rebuild\n * that silently stopped reusing plans, or one that reused them without\n * restoring the artifact, is visible rather than inferred from timing.\n */\n plansRestoredFromCache: boolean\n}\n\nconst normalizePath = (value: string) => value.replace(/\\\\/g, '/')\n\nexport const zeroModuleKey = (value: string): string =>\n normalizePath(value).replace(/\\.(?:js|jsx|ts|tsx|mjs|cjs)$/, '')\n\n/** Where an island build leaves its CSS fragment for the zero build to collect. */\nexport function islandFragmentPath(outDir: string, islandId: string): string {\n return path.join(outDir, ZERO_ISLAND_DIRNAME, `${islandId}.css`)\n}\n\nexport function islandBundleHashPath(outDir: string, islandId: string): string {\n return path.join(outDir, ZERO_ISLAND_DIRNAME, `${islandId}.hash`)\n}\n\nexport function createMetroZeroController(\n options: TamaguiOptions,\n root: string,\n islandBuild: string | null,\n publicDirName: string\n): MetroZeroController | null {\n const resolved = Static.resolveZeroRuntimeSync(options, root)\n if (resolved.mode === 'off') return null\n Static.assertZeroIntegrationSupport('metro-web', resolved)\n\n const cssHref = `/${ZERO_CSS_FILENAME}`\n const artifact = new Static.ZeroCSSArtifact(resolved.cssPath)\n artifact.expectIslands(resolved.islands.map((island) => island.id))\n\n const configPath = path.isAbsolute(options.config || '')\n ? options.config!\n : path.resolve(root, options.config || 'tamagui.config.ts')\n\n for (const island of resolved.islands) {\n Static.writeIslandModules({\n island,\n integration: 'metro-web',\n configPath,\n scriptUrl: `/${ZERO_ISLAND_DIRNAME}/${island.id}.js`,\n cssHref,\n })\n }\n\n return {\n resolved,\n artifact,\n cssHref,\n root,\n publicDir: path.join(root, publicDirName),\n islandBuild,\n bridges: new Map(),\n violations: [],\n transformed: new Set(),\n erasedExports: new Map(),\n isEnforcing: resolved.mode === 'enforce',\n loaderIds: new Map(\n resolved.islands.map((island) => [zeroModuleKey(island.loader), island.id])\n ),\n islandModuleIds: new Map(\n resolved.islands.map((island) => [zeroModuleKey(island.module), island.id])\n ),\n configCSS: '',\n plansRestoredFromCache: false,\n }\n}\n\n/**\n * Generated shim modules for the island bundle's React handoff.\n *\n * Metro has no externals option, so the island build redirects `react`,\n * `react-dom`, and `react/jsx-runtime` through these, which read the handoff\n * the generated loader publishes. One React instance serves both graphs.\n */\nexport function writeIslandRuntimeShims(outDir: string): Record<string, string> {\n const directory = path.join(outDir, 'runtime-shim')\n mkdirSync(directory, { recursive: true })\n const shims: Record<string, string> = {}\n for (const [specifier, segments] of Object.entries(\n Static.ISLAND_EXTERNAL_GLOBAL_PATHS\n )) {\n const file = path.join(directory, `${specifier.replace(/[^a-zA-Z0-9]+/g, '_')}.js`)\n const source = `// generated by @tamagui/metro-plugin zero-runtime. do not edit.\\nmodule.exports = globalThis.${segments.join(\n '.'\n )}\\n`\n if (!existsSync(file) || readFileSync(file, 'utf8') !== source) {\n writeFileSync(file, source)\n }\n shims[specifier] = file\n }\n return shims\n}\n\nexport interface MetroZeroFinalizeInput {\n controller: MetroZeroController\n /** The serialized bundle, hashed into the island's output receipt. */\n bundleCode: string\n}\n\n/**\n * Writes the one CSS artifact for a zero build, or this island's fragment for\n * an island build. `TAMAGUI_DID_OUTPUT_CSS` is derived only when every declared\n * island fragment is present.\n */\nexport function finalizeMetroZero(input: MetroZeroFinalizeInput): {\n cssPath: string\n hash: string\n islandOutputHashes: Record<string, string>\n} {\n const { controller } = input\n const outDir = controller.resolved.outDir\n\n if (controller.islandBuild) {\n const fragment = [...controller.artifact.islandCSS(controller.islandBuild)].join('')\n const file = islandFragmentPath(outDir, controller.islandBuild)\n mkdirSync(path.dirname(file), { recursive: true })\n writeFileSync(file, fragment)\n writeFileSync(\n islandBundleHashPath(outDir, controller.islandBuild),\n createHash('sha256').update(input.bundleCode).digest('hex').slice(0, 16)\n )\n return { cssPath: file, hash: '', islandOutputHashes: {} }\n }\n\n controller.artifact.setConfigCSS(controller.configCSS)\n const islandOutputHashes: Record<string, string> = {}\n for (const island of controller.resolved.islands) {\n const fragment = islandFragmentPath(outDir, island.id)\n if (!existsSync(fragment)) {\n throw new Error(\n `[tamagui zero-runtime] island \"${island.id}\" has not been built. Build every declared island bundle before the zero entry so the one CSS artifact can be finalized.`\n )\n }\n controller.artifact.setIslandModuleCSS(\n island.id,\n island.module,\n readFileSync(fragment, 'utf8')\n )\n const hashFile = islandBundleHashPath(outDir, island.id)\n islandOutputHashes[island.id] = existsSync(hashFile)\n ? readFileSync(hashFile, 'utf8')\n : ''\n }\n\n const written = controller.artifact.write()\n if (!written.complete) {\n throw new Error(\n `[tamagui zero-runtime] cannot derive TAMAGUI_DID_OUTPUT_CSS: the generated CSS artifact is missing ${written.missing.join(\n ', '\n )}`\n )\n }\n return { cssPath: written.path, hash: written.hash, islandOutputHashes }\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type MetroZeroController } from "./zeroRuntime";
|
|
2
|
+
type MetroConfigInput = Record<string, any>;
|
|
3
|
+
export declare function applyMetroZeroRuntime(metroConfig: MetroConfigInput, zero: MetroZeroController): void;
|
|
4
|
+
export {};
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=zeroSerializer.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAQA,cAKO,2BACA;KA0BF,mBAAmB;AAExB,OAAO,iBAAS,sBACd,aAAa,kBACb,MAAM",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/zeroSerializer.ts"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"import { mkdirSync, writeFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport { gzipSync } from 'node:zlib'\n\nimport Static from '@tamagui/static'\nimport type { ZeroGraphReceipt } from '@tamagui/static'\n\nimport {\n finalizeMetroZero,\n writeIslandRuntimeShims,\n ZERO_CSS_FILENAME,\n ZERO_ISLAND_DIRNAME,\n type MetroZeroController,\n} from './zeroRuntime'\n\n/**\n * Metro's serializer-time gate and the resolver redirects the island bundle\n * needs.\n *\n * The serializer is the first point where Metro's whole module graph exists,\n * so it is where the forbidden-module check runs. It is not where erasure\n * happens: Metro fixes dependencies at resolution, so by serializer time a\n * surviving import is already a graph member. That is the point of checking\n * here rather than fixing here.\n */\n\nconst requireFromPlugin = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url\n)\n\n// version-pinned, not a feature-detection chain: this is the serializer the\n// repository's Metro ships, and it is used only when the app supplied none\nconst baseJSBundle = requireFromPlugin(\n 'metro/private/DeltaBundler/Serializers/baseJSBundle'\n).default as (entryPoint: any, preModules: any, graph: any, options: any) => any\nconst bundleToString = requireFromPlugin('metro/private/lib/bundleToString').default as (\n bundle: any\n) => { code: string; map: string }\n\ntype MetroConfigInput = Record<string, any>\n\nexport function applyMetroZeroRuntime(\n metroConfig: MetroConfigInput,\n zero: MetroZeroController\n): void {\n if (zero.islandBuild) {\n // Metro has no externals option, so React is redirected through generated\n // shim modules that read the handoff the island loader publishes\n const shims = writeIslandRuntimeShims(zero.resolved.outDir)\n const userResolveRequest = metroConfig.resolver?.resolveRequest\n metroConfig.resolver = {\n ...metroConfig.resolver,\n resolveRequest(context: any, moduleName: string, platform: string | null) {\n const shim = shims[moduleName]\n if (shim) return { type: 'sourceFile', filePath: shim }\n return userResolveRequest\n ? userResolveRequest(context, moduleName, platform)\n : context.resolveRequest(context, moduleName, platform)\n },\n }\n }\n\n const userSerializer = metroConfig.serializer?.customSerializer\n metroConfig.serializer = {\n ...metroConfig.serializer,\n async customSerializer(entryPoint: any, preModules: any, graph: any, opts: any) {\n const receipt = checkGraph(zero, entryPoint, graph)\n const output = userSerializer\n ? await userSerializer(entryPoint, preModules, graph, opts)\n : bundleToString(baseJSBundle(entryPoint, preModules, graph, opts)).code\n\n const finalized = finalizeMetroZero({\n controller: zero,\n bundleCode: typeof output === 'string' ? output : '',\n })\n\n if (!zero.islandBuild) {\n mkdirSync(zero.publicDir, { recursive: true })\n const css = zero.artifact.css()\n const published = path.join(zero.publicDir, ZERO_CSS_FILENAME)\n writeFileSync(published, css)\n // the served copy is what the page loads, so it is the one the claim\n // depends on: read it back rather than trusting the write\n const publishFailure = Static.checkGlobalCSSArtifact({\n cssPath: published,\n expectedCSS: css,\n loadedModuleIds: [published],\n importHint: '',\n })\n if (publishFailure) throw new Error(publishFailure.message)\n receipt.cssArtifact = { path: zero.cssHref, hash: finalized.hash }\n receipt.gzip = {\n [ZERO_CSS_FILENAME]: gzipSync(Buffer.from(css), { level: 9 }).length,\n bundle: gzipSync(Buffer.from(typeof output === 'string' ? output : ''), {\n level: 9,\n }).length,\n }\n const bridgeManifest = Static.canonicalizeBridgeManifest(\n Object.fromEntries(\n [...zero.bridges.entries()].sort(([left], [right]) => (left < right ? -1 : 1))\n )\n )\n const identityInputs = {\n runtimeLiteral: 'zero' as const,\n target: 'web' as const,\n configGeneration: Static.hashBridgeManifest(zero.configCSS),\n cssHash: finalized.hash,\n compilerVersion: Static.ZERO_COMPILER_VERSION,\n islandEntries: zero.resolved.islands.map((island) => island.module),\n bridgeManifestHash: Static.hashBridgeManifest(bridgeManifest),\n islandOutputHashes: finalized.islandOutputHashes,\n }\n receipt.identity = Static.hashZeroIdentity(identityInputs)\n receipt.plansRestoredFromCache = zero.plansRestoredFromCache\n Static.writeZeroGraphReceipt(zero.resolved.outDir, 'metro-zero', receipt)\n writeFileSync(\n path.join(zero.resolved.outDir, 'metro-zero.bridges.json'),\n `${JSON.stringify(\n { identity: receipt.identity, identityInputs, bridges: bridgeManifest },\n null,\n 2\n )}\\n`\n )\n if (receipt.forbidden.length) {\n throw new Error(Static.formatZeroGraphFailure(receipt))\n }\n console.info(\n ` ➡ [tamagui zero-runtime] ${receipt.moduleCount} modules, 0 forbidden, css ${receipt.gzip[ZERO_CSS_FILENAME]} gzip, islands: ${\n zero.resolved.islands.map((island) => island.id).join(', ') || 'none'\n }`\n )\n }\n\n return output\n },\n }\n}\n\nfunction checkGraph(\n zero: MetroZeroController,\n entryPoint: string,\n graph: { dependencies: Map<string, any> }\n): ZeroGraphReceipt {\n const modules: { id: string; importers: string[] }[] = []\n const importerEdges = new Map<string, string[]>()\n for (const [id, module] of graph.dependencies) {\n const importers = [...(module.inverseDependencies ?? [])] as string[]\n importerEdges.set(id, importers)\n modules.push({ id, importers })\n }\n const escape = Static.erasedExportEscape({\n integration: 'metro-web',\n transformed: zero.transformed,\n erasedExports: zero.erasedExports,\n importersOf: importerEdges,\n })\n if (escape) throw new Error(escape)\n const checked = Static.checkZeroGraph({\n entries: [entryPoint],\n modules,\n importerEdges,\n root: zero.resolved.root,\n })\n return {\n integration: 'metro-web',\n graph: zero.islandBuild ? 'island' : 'zero',\n entries: [entryPoint],\n moduleCount: modules.length,\n tamaguiModules: checked.tamaguiModules,\n forbidden: checked.forbidden,\n cssArtifact: null,\n identity: '',\n }\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
__export(index_exports, {
|
|
20
|
-
withTamagui: () => withTamagui
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(index_exports);
|
|
23
|
-
var import_static = require("@tamagui/static");
|
|
24
|
-
function withTamagui(metroConfig, optionsIn) {
|
|
25
|
-
const { cssInterop, ...tamaguiOptionsIn } = optionsIn || {};
|
|
26
|
-
if (cssInterop) {
|
|
27
|
-
console.warn(
|
|
28
|
-
"[@tamagui/metro-plugin] cssInterop option is deprecated. Use `tamagui generate` to pre-generate CSS instead."
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
const options = {
|
|
32
|
-
...tamaguiOptionsIn,
|
|
33
|
-
...(0, import_static.loadTamaguiBuildConfigSync)(tamaguiOptionsIn)
|
|
34
|
-
};
|
|
35
|
-
metroConfig.resolver = {
|
|
36
|
-
...metroConfig.resolver,
|
|
37
|
-
sourceExts: [.../* @__PURE__ */ new Set([...metroConfig.resolver?.sourceExts || [], "css"])]
|
|
38
|
-
};
|
|
39
|
-
metroConfig.transformer = {
|
|
40
|
-
...metroConfig.transformer,
|
|
41
|
-
tamagui: options
|
|
42
|
-
};
|
|
43
|
-
return metroConfig;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgE;AAwCzD,SAAS,YACd,aACA,WACkB;AAClB,QAAM,EAAE,YAAY,GAAG,iBAAiB,IAAI,aAAa,CAAC;AAE1D,MAAI,YAAY;AACd,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAU;AAAA,IACd,GAAG;AAAA,IACH,OAAG,0CAA2B,gBAAgB;AAAA,EAChD;AAGA,cAAY,WAAW;AAAA,IACrB,GAAI,YAAY;AAAA,IAChB,YAAY,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAI,YAAY,UAAU,cAAc,CAAC,GAAI,KAAK,CAAC,CAAC;AAAA,EAC/E;AAGA,cAAY,cAAc;AAAA,IACxB,GAAG,YAAY;AAAA,IACf,SAAS;AAAA,EACX;AAEA,SAAO;AACT;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { loadTamaguiBuildConfigSync } from "@tamagui/static";
|
|
2
|
-
function withTamagui(metroConfig, optionsIn) {
|
|
3
|
-
const {
|
|
4
|
-
cssInterop,
|
|
5
|
-
...tamaguiOptionsIn
|
|
6
|
-
} = optionsIn || {};
|
|
7
|
-
if (cssInterop) {
|
|
8
|
-
console.warn("[@tamagui/metro-plugin] cssInterop option is deprecated. Use `tamagui generate` to pre-generate CSS instead.");
|
|
9
|
-
}
|
|
10
|
-
const options = {
|
|
11
|
-
...tamaguiOptionsIn,
|
|
12
|
-
...loadTamaguiBuildConfigSync(tamaguiOptionsIn)
|
|
13
|
-
};
|
|
14
|
-
metroConfig.resolver = {
|
|
15
|
-
...metroConfig.resolver,
|
|
16
|
-
sourceExts: [... /* @__PURE__ */new Set([...(metroConfig.resolver?.sourceExts || []), "css"])]
|
|
17
|
-
};
|
|
18
|
-
metroConfig.transformer = {
|
|
19
|
-
...metroConfig.transformer,
|
|
20
|
-
tamagui: options
|
|
21
|
-
};
|
|
22
|
-
return metroConfig;
|
|
23
|
-
}
|
|
24
|
-
export { withTamagui };
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["loadTamaguiBuildConfigSync","withTamagui","metroConfig","optionsIn","cssInterop","tamaguiOptionsIn","console","warn","options","resolver","sourceExts","Set","transformer","tamagui"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,0BAAA,QAAuD;AAwCzD,SAASC,YACdC,WAAA,EACAC,SAAA,EACkB;EAClB,MAAM;IAAEC,UAAA;IAAY,GAAGC;EAAiB,IAAIF,SAAA,IAAa,CAAC;EAE1D,IAAIC,UAAA,EAAY;IACdE,OAAA,CAAQC,IAAA,CACN,8GACF;EACF;EAEA,MAAMC,OAAA,GAAU;IACd,GAAGH,gBAAA;IACH,GAAGL,0BAAA,CAA2BK,gBAAgB;EAChD;EAGAH,WAAA,CAAYO,QAAA,GAAW;IACrB,GAAIP,WAAA,CAAYO,QAAA;IAChBC,UAAA,EAAY,CAAC,IAAG,mBAAIC,GAAA,CAAI,CAAC,IAAIT,WAAA,CAAYO,QAAA,EAAUC,UAAA,IAAc,EAAC,GAAI,KAAK,CAAC,CAAC;EAC/E;EAGAR,WAAA,CAAYU,WAAA,GAAc;IACxB,GAAGV,WAAA,CAAYU,WAAA;IACfC,OAAA,EAASL;EACX;EAEA,OAAON,WAAA;AACT","ignoreList":[]}
|