veryfront 0.0.86 → 0.0.89
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/esm/_dnt.shims.d.ts +14 -14
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/deno.d.ts +0 -1
- package/esm/deno.js +8 -9
- package/esm/proxy/main.d.ts +2 -0
- package/esm/proxy/main.d.ts.map +1 -0
- package/esm/proxy/main.js +400 -0
- package/esm/src/cli/commands/init/config-generator.js +1 -1
- package/esm/src/cli/index/arg-parser.d.ts.map +1 -1
- package/esm/src/cli/index/arg-parser.js +1 -0
- package/esm/src/cli/index/command-router.d.ts.map +1 -1
- package/esm/src/cli/index/command-router.js +54 -39
- package/esm/src/cli/index/types.d.ts +4 -0
- package/esm/src/cli/index/types.d.ts.map +1 -1
- package/esm/src/cli/mcp/advanced-tools.d.ts +2 -2
- package/esm/src/cli/templates/manifest.d.ts +448 -448
- package/esm/src/cli/templates/manifest.js +480 -480
- package/esm/src/config/loader.d.ts.map +1 -1
- package/esm/src/config/loader.js +5 -4
- package/esm/src/html/utils.js +2 -2
- package/esm/src/modules/import-map/default-import-map.d.ts +1 -11
- package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
- package/esm/src/modules/import-map/default-import-map.js +3 -20
- package/esm/src/modules/import-map/loader.d.ts.map +1 -1
- package/esm/src/modules/import-map/loader.js +7 -22
- package/esm/src/modules/import-map/resolver.d.ts.map +1 -1
- package/esm/src/modules/import-map/resolver.js +12 -8
- package/esm/src/modules/react-loader/component-loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/component-loader.js +2 -0
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts +1 -6
- package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/ssr-module-loader/loader.js +40 -32
- package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts +2 -0
- package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts.map +1 -1
- package/esm/src/modules/react-loader/types.d.ts +2 -0
- package/esm/src/modules/react-loader/types.d.ts.map +1 -1
- package/esm/src/modules/react-loader/unified-loader.d.ts.map +1 -1
- package/esm/src/modules/react-loader/unified-loader.js +7 -4
- package/esm/src/modules/server/module-batch-handler.d.ts +2 -0
- package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
- package/esm/src/modules/server/module-batch-handler.js +3 -1
- package/esm/src/modules/server/module-server.d.ts +2 -0
- package/esm/src/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +4 -2
- package/esm/src/modules/server/ssr-import-rewriter.d.ts.map +1 -1
- package/esm/src/modules/server/ssr-import-rewriter.js +9 -17
- package/esm/src/platform/compat/path-helper.d.ts +7 -7
- package/esm/src/platform/compat/path-helper.d.ts.map +1 -1
- package/esm/src/react/compat/ssr-adapter/string-renderer.js +1 -1
- package/esm/src/react/components/Head.d.ts.map +1 -1
- package/esm/src/react/components/Head.js +6 -2
- package/esm/src/react/components/ai/agent-card.d.ts +1 -1
- package/esm/src/react/components/ai/agent-card.d.ts.map +1 -1
- package/esm/src/react/components/ai/chat/composition/api.d.ts +5 -4
- package/esm/src/react/components/ai/chat/composition/api.d.ts.map +1 -1
- package/esm/src/react/components/ai/chat/index.d.ts +7 -2
- package/esm/src/react/components/ai/chat/index.d.ts.map +1 -1
- package/esm/src/react/components/ai/message.d.ts +2 -2
- package/esm/src/react/components/ai/message.d.ts.map +1 -1
- package/esm/src/react/primitives/agent-primitives.d.ts +3 -3
- package/esm/src/react/primitives/agent-primitives.d.ts.map +1 -1
- package/esm/src/react/primitives/chat-container.d.ts +1 -1
- package/esm/src/react/primitives/chat-container.d.ts.map +1 -1
- package/esm/src/react/primitives/input-box.d.ts +3 -3
- package/esm/src/react/primitives/input-box.d.ts.map +1 -1
- package/esm/src/react/primitives/input-box.js +6 -2
- package/esm/src/react/primitives/message-list.d.ts +4 -4
- package/esm/src/react/primitives/message-list.d.ts.map +1 -1
- package/esm/src/react/primitives/tool-primitives.d.ts +3 -3
- package/esm/src/react/primitives/tool-primitives.d.ts.map +1 -1
- package/esm/src/rendering/component-handling.d.ts +2 -0
- package/esm/src/rendering/component-handling.d.ts.map +1 -1
- package/esm/src/rendering/component-handling.js +4 -2
- package/esm/src/rendering/layouts/layout-applicator.d.ts.map +1 -1
- package/esm/src/rendering/layouts/layout-applicator.js +2 -0
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts +3 -0
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/index.js +74 -19
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +2 -0
- package/esm/src/rendering/rsc/server-renderer/tree-processor.d.ts.map +1 -1
- package/esm/src/rendering/rsc/server-renderer/tree-processor.js +3 -1
- package/esm/src/rendering/ssr-globals/context.d.ts +6 -1
- package/esm/src/rendering/ssr-globals/context.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-bundler.d.ts +15 -4
- package/esm/src/transforms/esm/http-bundler.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-bundler.js +105 -12
- package/esm/src/transforms/esm/http-cache.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-cache.js +26 -27
- package/esm/src/transforms/esm/import-rewriter.d.ts.map +1 -1
- package/esm/src/transforms/esm/import-rewriter.js +3 -3
- package/esm/src/transforms/esm/package-registry.d.ts +15 -13
- package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
- package/esm/src/transforms/esm/package-registry.js +45 -32
- package/esm/src/transforms/esm/react-imports.d.ts.map +1 -1
- package/esm/src/transforms/esm/react-imports.js +3 -7
- package/esm/src/transforms/esm/types.d.ts +2 -0
- package/esm/src/transforms/esm/types.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts +14 -0
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +67 -0
- package/esm/src/transforms/mdx/esm-module-loader/loader.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/loader.js +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +4 -0
- package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/context.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/context.js +7 -15
- package/esm/src/transforms/pipeline/stages/finalize.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/finalize.js +1 -1
- package/esm/src/utils/constants/cdn.d.ts.map +1 -1
- package/esm/src/utils/constants/cdn.js +22 -11
- package/esm/src/utils/hash-utils.d.ts +2 -0
- package/esm/src/utils/hash-utils.d.ts.map +1 -1
- package/esm/src/utils/hash-utils.js +4 -0
- package/package.json +1 -1
- package/src/deno.js +8 -9
- package/src/proxy/main.ts +471 -0
- package/src/src/cli/commands/init/config-generator.ts +1 -1
- package/src/src/cli/index/arg-parser.ts +1 -0
- package/src/src/cli/index/command-router.ts +57 -40
- package/src/src/cli/index/types.ts +5 -0
- package/src/src/cli/templates/manifest.js +480 -480
- package/src/src/config/loader.ts +5 -4
- package/src/src/html/utils.ts +2 -2
- package/src/src/modules/import-map/default-import-map.ts +3 -25
- package/src/src/modules/import-map/loader.ts +7 -23
- package/src/src/modules/import-map/resolver.ts +13 -8
- package/src/src/modules/react-loader/component-loader.ts +2 -0
- package/src/src/modules/react-loader/ssr-module-loader/loader.ts +51 -37
- package/src/src/modules/react-loader/ssr-module-loader/types.ts +2 -0
- package/src/src/modules/react-loader/types.ts +2 -0
- package/src/src/modules/react-loader/unified-loader.ts +7 -4
- package/src/src/modules/server/module-batch-handler.ts +7 -0
- package/src/src/modules/server/module-server.ts +6 -1
- package/src/src/modules/server/ssr-import-rewriter.ts +9 -17
- package/src/src/react/compat/ssr-adapter/stream-renderer.ts +1 -1
- package/src/src/react/compat/ssr-adapter/string-renderer.ts +2 -2
- package/src/src/react/components/Head.tsx +6 -2
- package/src/src/react/primitives/input-box.tsx +4 -2
- package/src/src/rendering/component-handling.ts +6 -0
- package/src/src/rendering/layouts/layout-applicator.ts +4 -5
- package/src/src/rendering/orchestrator/module-loader/index.ts +91 -20
- package/src/src/rendering/orchestrator/pipeline.ts +2 -0
- package/src/src/rendering/orchestrator/ssr-orchestrator.ts +1 -1
- package/src/src/rendering/rsc/server-renderer/tree-processor.ts +13 -3
- package/src/src/transforms/esm/http-bundler.ts +101 -11
- package/src/src/transforms/esm/http-cache.ts +27 -28
- package/src/src/transforms/esm/import-rewriter.ts +5 -3
- package/src/src/transforms/esm/package-registry.ts +46 -32
- package/src/src/transforms/esm/react-imports.ts +3 -7
- package/src/src/transforms/esm/types.ts +2 -0
- package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +84 -0
- package/src/src/transforms/mdx/esm-module-loader/loader.ts +1 -0
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +2 -1
- package/src/src/transforms/mdx/esm-module-loader/types.ts +4 -0
- package/src/src/transforms/pipeline/context.ts +7 -18
- package/src/src/transforms/pipeline/stages/finalize.ts +6 -1
- package/src/src/transforms/plugins/babel-node-positions.ts +2 -2
- package/src/src/utils/constants/cdn.ts +21 -12
- package/src/src/utils/hash-utils.ts +5 -0
|
@@ -7,15 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { parallelMap, rendererLogger as logger } from "../../../utils/index.js";
|
|
9
9
|
import { getLocalAdapter } from "../../../platform/adapters/registry.js";
|
|
10
|
-
import {
|
|
11
|
-
import { findLocalLibFile, findSourceFile } from "../file-resolver/index.js";
|
|
10
|
+
import { findSourceFile } from "../file-resolver/index.js";
|
|
12
11
|
import { transformToESM } from "../../../transforms/esm-transform.js";
|
|
13
12
|
import { getProjectTmpDir } from "../../../modules/react-loader/index.js";
|
|
14
13
|
import { generateCacheKey as generateTransformCacheKey, getOrComputeTransform, initializeTransformCache, setCachedTransformAsync, } from "../../../transforms/esm/transform-cache.js";
|
|
15
|
-
import { hashString } from "../../../cache/hash.js";
|
|
16
14
|
import { TRANSFORM_DISTRIBUTED_TTL_SEC } from "../../../utils/constants/cache.js";
|
|
17
15
|
import { ensureHttpBundlesExist } from "../../../transforms/esm/http-cache.js";
|
|
18
|
-
import { getHttpBundleCacheDir } from "../../../utils/cache-dir.js";
|
|
16
|
+
import { getHttpBundleCacheDir, getMdxEsmCacheDir } from "../../../utils/cache-dir.js";
|
|
17
|
+
import { join } from "../../../platform/compat/path/index.js";
|
|
18
|
+
import { hashCodeHex } from "../../../utils/hash-utils.js";
|
|
19
|
+
import { TRANSFORM_CACHE_VERSION } from "../../../transforms/esm/package-registry.js";
|
|
20
|
+
import { getModulePathCache, lookupMdxEsmCache, saveModulePathCache, } from "../../../transforms/mdx/esm-module-loader/cache/index.js";
|
|
19
21
|
// Re-export utilities
|
|
20
22
|
export { createEsmCache, createModuleCache, generateHash } from "./cache.js";
|
|
21
23
|
export { fetchEsmModule, rewriteEsmPaths } from "./esm-rewriter.js";
|
|
@@ -62,16 +64,12 @@ async function ensureDir(adapter, dir) {
|
|
|
62
64
|
createdDirs.add(dir);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
async function resolveAliasImport(imp, projectDir, adapter,
|
|
67
|
+
async function resolveAliasImport(imp, projectDir, adapter, _localAdapter) {
|
|
66
68
|
const relativePath = imp.path.substring(2); // Remove @/ prefix
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let depFilePath = await findSourceFile(relativePath, projectDir, adapter);
|
|
72
|
-
if (!depFilePath) {
|
|
73
|
-
depFilePath = await findSourceFile(`components/${relativePath}`, projectDir, adapter);
|
|
74
|
-
}
|
|
69
|
+
// @/ alias always resolves to project directory
|
|
70
|
+
// Try exact path first, then components/ subdirectory
|
|
71
|
+
const depFilePath = await findSourceFile(relativePath, projectDir, adapter) ??
|
|
72
|
+
await findSourceFile(`components/${relativePath}`, projectDir, adapter);
|
|
75
73
|
return { ...imp, relativePath, depFilePath, isLocalLib: false };
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
@@ -85,11 +83,23 @@ async function resolveAliasImport(imp, projectDir, adapter, localAdapter) {
|
|
|
85
83
|
* @returns Path to the transformed module file
|
|
86
84
|
*/
|
|
87
85
|
export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, config, useLocalAdapter = false) {
|
|
88
|
-
const { moduleCache, projectDir, projectId, adapter, mode } = config;
|
|
86
|
+
const { moduleCache, projectDir, projectId, contentSourceId, adapter, mode } = config;
|
|
89
87
|
const cacheKey = getModuleCacheKey(filePath, projectId, projectDir);
|
|
90
88
|
const cachedPath = moduleCache.get(cacheKey);
|
|
91
89
|
if (cachedPath)
|
|
92
90
|
return cachedPath;
|
|
91
|
+
// Check MDX-ESM cache to share modules with SSR loader (prevents duplicate React contexts)
|
|
92
|
+
if (projectId && contentSourceId) {
|
|
93
|
+
const baseCacheDir = getMdxEsmCacheDir();
|
|
94
|
+
const projectKey = encodeURIComponent(projectId);
|
|
95
|
+
const sourceKey = encodeURIComponent(contentSourceId);
|
|
96
|
+
const mdxCacheDir = join(baseCacheDir, projectKey, sourceKey);
|
|
97
|
+
const mdxCachedPath = await lookupMdxEsmCache(filePath, mdxCacheDir, projectDir);
|
|
98
|
+
if (mdxCachedPath) {
|
|
99
|
+
moduleCache.set(cacheKey, mdxCachedPath);
|
|
100
|
+
return mdxCachedPath;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
93
103
|
const readAdapter = useLocalAdapter ? localAdapter : adapter;
|
|
94
104
|
let fileContent = decodeFileContent(await readAdapter.fs.readFile(filePath));
|
|
95
105
|
const aliasImports = [...fileContent.matchAll(/from\s+["'](@\/[^"']+)["']/g)].map((m) => ({ full: m[0], path: m[1] }));
|
|
@@ -124,7 +134,7 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
124
134
|
projectDir,
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
|
-
const contentHash =
|
|
137
|
+
const contentHash = hashCodeHex(fileContent);
|
|
128
138
|
const effectiveProjectId = projectId ?? projectDir;
|
|
129
139
|
const scopedPath = `${effectiveProjectId}:${filePath}`;
|
|
130
140
|
const transformCacheKey = generateTransformCacheKey(scopedPath, contentHash, true); // ssr=true
|
|
@@ -137,6 +147,7 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
137
147
|
projectId: effectiveProjectId,
|
|
138
148
|
dev: mode === "development",
|
|
139
149
|
ssr: true,
|
|
150
|
+
reactVersion: config.reactVersion,
|
|
140
151
|
});
|
|
141
152
|
}, TRANSFORM_CACHE_TTL_SECONDS);
|
|
142
153
|
// Proactively ensure HTTP bundles exist before writing the module.
|
|
@@ -155,6 +166,7 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
155
166
|
projectId: effectiveProjectId,
|
|
156
167
|
dev: mode === "development",
|
|
157
168
|
ssr: true,
|
|
169
|
+
reactVersion: config.reactVersion,
|
|
158
170
|
});
|
|
159
171
|
setCachedTransformAsync(transformCacheKey, transformedCode, contentHash, TRANSFORM_CACHE_TTL_SECONDS).catch((error) => {
|
|
160
172
|
logger.debug("[ModuleLoader] Failed to update transform cache after re-transform", {
|
|
@@ -164,9 +176,16 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
164
176
|
});
|
|
165
177
|
}
|
|
166
178
|
}
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
179
|
+
// Use TRANSFORMED hash for filename (matches SSR loader behavior)
|
|
180
|
+
const transformedHash = hashCodeHex(transformedCode).slice(0, 8);
|
|
181
|
+
const relativePath = filePath.startsWith(projectDir)
|
|
182
|
+
? filePath.slice(projectDir.length).replace(/^\/+/, "")
|
|
183
|
+
: filePath.replace(/^\/+/, "");
|
|
184
|
+
const jsPath = relativePath.replace(/\.(tsx?|jsx|mdx)$/, `.${transformedHash}.js`);
|
|
185
|
+
const tempFilePath = join(tmpDir, jsPath);
|
|
186
|
+
// Ensure directory exists (might be nested like lib/ or components/)
|
|
187
|
+
const tempDir = tempFilePath.substring(0, tempFilePath.lastIndexOf("/"));
|
|
188
|
+
await ensureDir(localAdapter, tempDir);
|
|
170
189
|
try {
|
|
171
190
|
await localAdapter.fs.writeFile(tempFilePath, transformedCode);
|
|
172
191
|
}
|
|
@@ -178,9 +197,45 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
178
197
|
});
|
|
179
198
|
throw error;
|
|
180
199
|
}
|
|
200
|
+
// Register in MDX-ESM cache index so other loaders can find this module
|
|
201
|
+
if (contentSourceId) {
|
|
202
|
+
const normalizedPath = `_vf_modules/${relativePath.replace(/\.(tsx?|jsx|mdx)$/, ".js")}`;
|
|
203
|
+
const mdxCacheKey = `v${TRANSFORM_CACHE_VERSION}:${normalizedPath}`;
|
|
204
|
+
const cache = await getModulePathCache(tmpDir);
|
|
205
|
+
cache.set(mdxCacheKey, tempFilePath);
|
|
206
|
+
// Persist to disk so MDX loader can find it
|
|
207
|
+
saveModulePathCache(tmpDir).catch((err) => {
|
|
208
|
+
logger.debug("[ModuleLoader] Failed to save module cache", { error: String(err) });
|
|
209
|
+
});
|
|
210
|
+
logger.debug("[ModuleLoader] Registered module in MDX-ESM cache", {
|
|
211
|
+
file: filePath.slice(-40),
|
|
212
|
+
mdxCacheKey,
|
|
213
|
+
tempFilePath: tempFilePath.slice(-60),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
181
216
|
moduleCache.set(cacheKey, tempFilePath);
|
|
182
217
|
return tempFilePath;
|
|
183
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the cache directory for module transforms.
|
|
221
|
+
* Uses MDX-ESM cache when contentSourceId is available, otherwise falls back to project tmp dir.
|
|
222
|
+
* This ensures modules are shared between orchestrator and MDX loader to prevent duplicate contexts.
|
|
223
|
+
*/
|
|
224
|
+
async function getModuleCacheDir(config) {
|
|
225
|
+
const { projectId, contentSourceId, projectDir } = config;
|
|
226
|
+
if (projectId && contentSourceId) {
|
|
227
|
+
const baseCacheDir = getMdxEsmCacheDir();
|
|
228
|
+
const projectKey = encodeURIComponent(projectId);
|
|
229
|
+
const sourceKey = encodeURIComponent(contentSourceId);
|
|
230
|
+
const cacheDir = join(baseCacheDir, projectKey, sourceKey);
|
|
231
|
+
// Ensure directory exists
|
|
232
|
+
const { createFileSystem } = await import("../../../platform/compat/fs.js");
|
|
233
|
+
await createFileSystem().mkdir(cacheDir, { recursive: true });
|
|
234
|
+
return cacheDir;
|
|
235
|
+
}
|
|
236
|
+
// Fallback for cases without contentSourceId
|
|
237
|
+
return getProjectTmpDir(projectId ?? projectDir);
|
|
238
|
+
}
|
|
184
239
|
/**
|
|
185
240
|
* Load a module by path, transforming it and its dependencies.
|
|
186
241
|
*
|
|
@@ -189,7 +244,7 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
|
|
|
189
244
|
* @returns The loaded module
|
|
190
245
|
*/
|
|
191
246
|
export async function loadModule(filePath, config) {
|
|
192
|
-
const tmpDir = await
|
|
247
|
+
const tmpDir = await getModuleCacheDir(config);
|
|
193
248
|
const localAdapter = await getLocalAdapter();
|
|
194
249
|
const tempFilePath = await transformModuleWithDeps(filePath, tmpDir, localAdapter, config);
|
|
195
250
|
const moduleUrl = `file://${tempFilePath}?t=${Date.now()}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAuFhF,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,MAAM,EAAE,oBAAoB;IAaxC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;YACW,qBAAqB;IA2BnC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAMzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAuFhF,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,MAAM,EAAE,oBAAoB;IAaxC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;OAEG;YACW,qBAAqB;IA2BnC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAMzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAgS9E,+EAA+E;IACzE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoNxF"}
|
|
@@ -167,6 +167,7 @@ export class RenderPipeline {
|
|
|
167
167
|
}
|
|
168
168
|
setupSSRGlobals();
|
|
169
169
|
this.moduleLoaderConfig.projectId = projectId;
|
|
170
|
+
this.moduleLoaderConfig.contentSourceId = options?.contentSourceId;
|
|
170
171
|
if (this.config.mode === "development") {
|
|
171
172
|
clearSSRModuleCacheForProject(projectId);
|
|
172
173
|
}
|
|
@@ -321,6 +322,7 @@ export class RenderPipeline {
|
|
|
321
322
|
setupSSRGlobals();
|
|
322
323
|
const projectId = options?.projectId ?? this.config.projectDir;
|
|
323
324
|
this.moduleLoaderConfig.projectId = projectId;
|
|
325
|
+
this.moduleLoaderConfig.contentSourceId = options?.contentSourceId;
|
|
324
326
|
if (this.config.mode === "development") {
|
|
325
327
|
clearSSRModuleCacheForProject(projectId);
|
|
326
328
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-processor.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/rsc/server-renderer/tree-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUhE,wDAAwD;AACxD,wBAAsB,UAAU,CAC9B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7F,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAuClB;AAED,6DAA6D;AAC7D,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"tree-processor.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/rsc/server-renderer/tree-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUhE,wDAAwD;AACxD,wBAAsB,UAAU,CAC9B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7F,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAuClB;AAED,6DAA6D;AAC7D,wBAAsB,cAAc,CAClC,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAuClB;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,EAAE,CAAC,CAYpB"}
|
|
@@ -42,7 +42,9 @@ export async function renderTree(Component, props, clientManifest, clientRefs) {
|
|
|
42
42
|
}
|
|
43
43
|
/** Processes a React element into RSC node representation */
|
|
44
44
|
export async function processElement(element, clientManifest, clientRefs) {
|
|
45
|
-
const { type
|
|
45
|
+
const { type } = element;
|
|
46
|
+
// Cast props for React 19 compatibility (props is unknown in R19 types)
|
|
47
|
+
const props = element.props;
|
|
46
48
|
if (type === React.Fragment) {
|
|
47
49
|
const children = await renderChildren(props.children, clientManifest, clientRefs);
|
|
48
50
|
return { type: "fragment", children };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SSR Context State
|
|
3
|
+
* @module rendering/ssr-globals/context
|
|
4
|
+
*/
|
|
5
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
6
|
+
export declare const originalFetch: typeof dntShim.fetch;
|
|
2
7
|
export declare function isSSRGlobalsActive(): boolean;
|
|
3
8
|
export declare function markSSRGlobalsInitialized(): void;
|
|
4
9
|
export declare function getSSRServerPort(): number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/ssr-globals/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/ssr-globals/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAQlD,eAAO,MAAM,aAAa,sBAA8B,CAAC;AAEzD,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE/D;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
|
@@ -13,12 +13,23 @@ export declare function getReactAliases(): Record<string, string>;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function createHTTPPlugin(): Plugin;
|
|
15
15
|
/**
|
|
16
|
-
* Ensure esm.sh URLs have
|
|
17
|
-
* This makes them import React as
|
|
16
|
+
* Ensure esm.sh URLs have external=react,react-dom for SSR.
|
|
17
|
+
* This makes them import React as bare specifiers, which the import map resolves.
|
|
18
18
|
*
|
|
19
19
|
* Uses two esm.sh features:
|
|
20
|
-
* - `external=react` - Don't bundle React, let import map resolve
|
|
20
|
+
* - `external=react,react-dom` - Don't bundle React/ReactDOM, let import map resolve them
|
|
21
21
|
* - `deps=react@X,react-dom@X` - Pin dependency versions to prevent mismatches
|
|
22
|
+
*
|
|
23
|
+
* Logic for external handling:
|
|
24
|
+
* 1. If no `external=` param → add `external=react,react-dom`
|
|
25
|
+
* 2. If `external=X` exists but no `react` → append `,react,react-dom`
|
|
26
|
+
* 3. If has `react` but no `react-dom` → append `,react-dom`
|
|
27
|
+
* 4. If has both `react` AND `react-dom` → leave alone
|
|
28
|
+
*
|
|
29
|
+
* @param code - Source code to process
|
|
30
|
+
* @param _cacheDir - Unused (kept for API compatibility)
|
|
31
|
+
* @param hash - Hash for logging
|
|
32
|
+
* @param reactVersion - React version for deps param (defaults to REACT_VERSION)
|
|
22
33
|
*/
|
|
23
|
-
export declare function bundleHttpImports(code: string, _cacheDir: string, hash: string): string | Promise<string>;
|
|
34
|
+
export declare function bundleHttpImports(code: string, _cacheDir: string, hash: string, reactVersion?: string): string | Promise<string>;
|
|
24
35
|
//# sourceMappingURL=http-bundler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-bundler.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-bundler.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAiB,MAAM,uBAAuB,CAAC;AA6BpE,qCAAqC;AACrC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,yDAAyD;AACzD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,wDAAwD;AACxD,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAyFzC;AAED
|
|
1
|
+
{"version":3,"file":"http-bundler.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-bundler.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAiB,MAAM,uBAAuB,CAAC;AA6BpE,qCAAqC;AACrC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,yDAAyD;AACzD,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,wDAAwD;AACxD,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAyFzC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqH1B"}
|
|
@@ -134,40 +134,133 @@ export function createHTTPPlugin() {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* Ensure esm.sh URLs have
|
|
138
|
-
* This makes them import React as
|
|
137
|
+
* Ensure esm.sh URLs have external=react,react-dom for SSR.
|
|
138
|
+
* This makes them import React as bare specifiers, which the import map resolves.
|
|
139
139
|
*
|
|
140
140
|
* Uses two esm.sh features:
|
|
141
|
-
* - `external=react` - Don't bundle React, let import map resolve
|
|
141
|
+
* - `external=react,react-dom` - Don't bundle React/ReactDOM, let import map resolve them
|
|
142
142
|
* - `deps=react@X,react-dom@X` - Pin dependency versions to prevent mismatches
|
|
143
|
+
*
|
|
144
|
+
* Logic for external handling:
|
|
145
|
+
* 1. If no `external=` param → add `external=react,react-dom`
|
|
146
|
+
* 2. If `external=X` exists but no `react` → append `,react,react-dom`
|
|
147
|
+
* 3. If has `react` but no `react-dom` → append `,react-dom`
|
|
148
|
+
* 4. If has both `react` AND `react-dom` → leave alone
|
|
149
|
+
*
|
|
150
|
+
* @param code - Source code to process
|
|
151
|
+
* @param _cacheDir - Unused (kept for API compatibility)
|
|
152
|
+
* @param hash - Hash for logging
|
|
153
|
+
* @param reactVersion - React version for deps param (defaults to REACT_VERSION)
|
|
143
154
|
*/
|
|
144
|
-
export function bundleHttpImports(code, _cacheDir, hash) {
|
|
155
|
+
export function bundleHttpImports(code, _cacheDir, hash, reactVersion) {
|
|
145
156
|
const has = hasHttpImports(code);
|
|
146
157
|
logger.debug(`${LOG_PREFIX} Check: hasHttp=${has}, hash=${hash.slice(0, 8)}`);
|
|
147
158
|
if (!has)
|
|
148
159
|
return code;
|
|
160
|
+
const version = reactVersion ?? REACT_VERSION;
|
|
149
161
|
return replaceSpecifiers(code, (specifier) => {
|
|
162
|
+
// Handle relative esm.sh paths like "/react-dom?target=es2022" or "/hoist-non-react-statics@..."
|
|
163
|
+
// These are returned by esm.sh stub modules and need to be converted to full URLs
|
|
164
|
+
if (specifier.startsWith("/") && !specifier.startsWith("//")) {
|
|
165
|
+
const fullUrl = `https://esm.sh${specifier}`;
|
|
166
|
+
// Recursively process as full URL (will add external params if needed)
|
|
167
|
+
const isReactPackage = /^\/react(-dom)?(@|\/|\?|$)/.test(specifier);
|
|
168
|
+
if (isReactPackage) {
|
|
169
|
+
// React packages - just ensure target and return full URL
|
|
170
|
+
if (!specifier.includes("target=")) {
|
|
171
|
+
const joiner = specifier.includes("?") ? "&" : "?";
|
|
172
|
+
return `${fullUrl}${joiner}target=es2022`;
|
|
173
|
+
}
|
|
174
|
+
return fullUrl;
|
|
175
|
+
}
|
|
176
|
+
// Non-React packages - add external params
|
|
177
|
+
const params = [];
|
|
178
|
+
if (!specifier.includes("target="))
|
|
179
|
+
params.push("target=es2022");
|
|
180
|
+
if (!specifier.includes("external="))
|
|
181
|
+
params.push("external=react,react-dom");
|
|
182
|
+
if (!specifier.includes("deps="))
|
|
183
|
+
params.push(`deps=react@${version},react-dom@${version}`);
|
|
184
|
+
if (params.length === 0)
|
|
185
|
+
return fullUrl;
|
|
186
|
+
const joiner = specifier.includes("?") ? "&" : "?";
|
|
187
|
+
return `${fullUrl}${joiner}${params.join("&")}`;
|
|
188
|
+
}
|
|
150
189
|
const isEsmSh = specifier.startsWith("https://esm.sh/") ||
|
|
151
190
|
specifier.startsWith("http://esm.sh/");
|
|
152
191
|
const isVfEsm = specifier.startsWith("https://esm.veryfront.com/");
|
|
153
192
|
if (!isEsmSh && !isVfEsm)
|
|
154
193
|
return null;
|
|
194
|
+
// Don't modify React/ReactDOM package URLs themselves
|
|
155
195
|
const isReactPackage = /\/react(-dom)?(@|\/|$)/.test(specifier);
|
|
196
|
+
if (isReactPackage) {
|
|
197
|
+
// Just ensure target is set for React packages
|
|
198
|
+
if (!specifier.includes("target=")) {
|
|
199
|
+
const joiner = specifier.includes("?") ? "&" : "?";
|
|
200
|
+
return `${specifier}${joiner}target=es2022`;
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
// For non-React packages: ensure external=react,react-dom and deps
|
|
156
205
|
const params = [];
|
|
157
206
|
if (!specifier.includes("target=")) {
|
|
158
207
|
params.push("target=es2022");
|
|
159
208
|
}
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
209
|
+
// Handle external param - ensure both react AND react-dom are externalized
|
|
210
|
+
const hasExternal = specifier.includes("external=");
|
|
211
|
+
const hasReactExternal = specifier.includes("external=react") ||
|
|
212
|
+
/external=[^&]*\breact\b/.test(specifier);
|
|
213
|
+
const hasReactDomExternal = /external=[^&]*react-dom/.test(specifier);
|
|
214
|
+
if (!hasExternal) {
|
|
215
|
+
// No external param - add both
|
|
216
|
+
params.push("external=react,react-dom");
|
|
217
|
+
}
|
|
218
|
+
else if (!hasReactExternal) {
|
|
219
|
+
// Has external but no react - append react,react-dom
|
|
220
|
+
// This requires modifying existing param, so we'll use URL parsing
|
|
221
|
+
try {
|
|
222
|
+
const url = new URL(specifier);
|
|
223
|
+
const existing = url.searchParams.get("external") || "";
|
|
224
|
+
url.searchParams.set("external", `${existing},react,react-dom`);
|
|
225
|
+
// Return full modified URL and skip other param additions
|
|
226
|
+
if (!specifier.includes("target=")) {
|
|
227
|
+
url.searchParams.set("target", "es2022");
|
|
228
|
+
}
|
|
229
|
+
if (!specifier.includes("deps=")) {
|
|
230
|
+
url.searchParams.set("deps", `react@${version},react-dom@${version}`);
|
|
231
|
+
}
|
|
232
|
+
logger.debug(`${LOG_PREFIX} ${specifier} -> ${url.toString()}`);
|
|
233
|
+
return url.toString();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// Fallback: just add as new param (may create duplicate)
|
|
237
|
+
params.push("external=react,react-dom");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (!hasReactDomExternal) {
|
|
241
|
+
// Has react but not react-dom - append react-dom
|
|
242
|
+
try {
|
|
243
|
+
const url = new URL(specifier);
|
|
244
|
+
const existing = url.searchParams.get("external") || "";
|
|
245
|
+
url.searchParams.set("external", `${existing},react-dom`);
|
|
246
|
+
if (!specifier.includes("target=")) {
|
|
247
|
+
url.searchParams.set("target", "es2022");
|
|
248
|
+
}
|
|
249
|
+
if (!specifier.includes("deps=")) {
|
|
250
|
+
url.searchParams.set("deps", `react@${version},react-dom@${version}`);
|
|
251
|
+
}
|
|
252
|
+
logger.debug(`${LOG_PREFIX} ${specifier} -> ${url.toString()}`);
|
|
253
|
+
return url.toString();
|
|
166
254
|
}
|
|
167
|
-
|
|
168
|
-
|
|
255
|
+
catch {
|
|
256
|
+
// Fallback
|
|
257
|
+
params.push("external=react-dom");
|
|
169
258
|
}
|
|
170
259
|
}
|
|
260
|
+
// else: has both react and react-dom - no external changes needed
|
|
261
|
+
if (!specifier.includes("deps=")) {
|
|
262
|
+
params.push(`deps=react@${version},react-dom@${version}`);
|
|
263
|
+
}
|
|
171
264
|
if (params.length === 0)
|
|
172
265
|
return null;
|
|
173
266
|
const joiner = specifier.includes("?") ? "&" : "?";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-cache.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAezE,KAAK,YAAY,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAoVF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOvF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8D9F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAClD,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAiInB"}
|
|
@@ -10,14 +10,14 @@ import * as dntShim from "../../../_dnt.shims.js";
|
|
|
10
10
|
import { createFileSystem, exists } from "../../platform/compat/fs.js";
|
|
11
11
|
import { isAbsolute, join } from "../../platform/compat/path/index.js";
|
|
12
12
|
import { cwd } from "../../platform/compat/process.js";
|
|
13
|
+
import { isDeno } from "../../platform/compat/runtime.js";
|
|
13
14
|
import { rendererLogger as logger } from "../../utils/index.js";
|
|
14
15
|
import { simpleHash } from "../../utils/hash-utils.js";
|
|
15
16
|
import { LRUCache } from "../../utils/lru-wrapper.js";
|
|
16
17
|
import { withSpan } from "../../observability/tracing/otlp-setup.js";
|
|
17
18
|
import { SpanNames } from "../../observability/tracing/span-names.js";
|
|
18
19
|
import { resolveImport } from "../../modules/import-map/resolver.js";
|
|
19
|
-
import {
|
|
20
|
-
import { getDenoNpmReactMap, getReactImportMap, REACT_VERSION } from "./package-registry.js";
|
|
20
|
+
import { getReactImportMap, REACT_VERSION } from "./package-registry.js";
|
|
21
21
|
import { parseImports, replaceSpecifiers } from "./lexer.js";
|
|
22
22
|
import { CacheBackends, createDistributedCacheAccessor } from "../../cache/backend.js";
|
|
23
23
|
import { HTTP_MODULE_CACHE_MAX_ENTRIES, HTTP_MODULE_DISTRIBUTED_TTL_SEC, } from "../../utils/constants/cache.js";
|
|
@@ -39,13 +39,24 @@ function isHttpUrl(specifier) {
|
|
|
39
39
|
/**
|
|
40
40
|
* Check if a URL is for React core packages.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* React instance.
|
|
42
|
+
* React core modules (react, react-dom) must NOT be cached/bundled.
|
|
43
|
+
* Instead, all packages use external=react and import from the same esm.sh URL.
|
|
44
|
+
* This prevents multiple React instances which causes "useContext is null" errors.
|
|
46
45
|
*/
|
|
47
|
-
function isReactCoreUrl(
|
|
48
|
-
|
|
46
|
+
function isReactCoreUrl(url) {
|
|
47
|
+
try {
|
|
48
|
+
const parsed = new URL(url);
|
|
49
|
+
if (!parsed.hostname.includes("esm.sh"))
|
|
50
|
+
return false;
|
|
51
|
+
// Extract package name from esm.sh pathname
|
|
52
|
+
// Formats: /react@version, /v150/react@version, /stable/react@version
|
|
53
|
+
const pathname = parsed.pathname.replace(/^\/(v\d+|stable)\//, "/");
|
|
54
|
+
const match = pathname.match(/^\/(react|react-dom)(@[\d.]+)?(?:\/|$|\?)/);
|
|
55
|
+
return match !== null;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
49
60
|
}
|
|
50
61
|
function isExternalScheme(specifier) {
|
|
51
62
|
return specifier.startsWith("node:") ||
|
|
@@ -101,25 +112,8 @@ function toEsmShUrlFromNpm(specifier) {
|
|
|
101
112
|
return `https://esm.sh/${specifier.slice(4)}`;
|
|
102
113
|
}
|
|
103
114
|
function resolveBareSpecifier(specifier, importMap, reactVersion = REACT_VERSION) {
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
// See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
|
|
107
|
-
if (isDeno) {
|
|
108
|
-
const denoReactMap = getDenoNpmReactMap(reactVersion);
|
|
109
|
-
const denoMatch = denoReactMap[specifier];
|
|
110
|
-
if (denoMatch)
|
|
111
|
-
return denoMatch;
|
|
112
|
-
// For unknown react/* or react-dom/* subpaths, construct npm: specifiers
|
|
113
|
-
if (specifier.startsWith("react/") && !specifier.startsWith("react-dom")) {
|
|
114
|
-
const subpath = specifier.slice("react/".length);
|
|
115
|
-
return `npm:react@${reactVersion}/${subpath}`;
|
|
116
|
-
}
|
|
117
|
-
if (specifier.startsWith("react-dom/")) {
|
|
118
|
-
const subpath = specifier.slice("react-dom/".length);
|
|
119
|
-
return `npm:react-dom@${reactVersion}/${subpath}`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// For non-Deno runtimes: Use esm.sh URLs with consistent versioning.
|
|
115
|
+
// Use esm.sh URLs for React - NO npm: specifiers per plan requirements.
|
|
116
|
+
// All packages use external=react to share the same React instance.
|
|
123
117
|
const reactMap = getReactImportMap(reactVersion);
|
|
124
118
|
const reactMapped = reactMap[specifier];
|
|
125
119
|
if (reactMapped)
|
|
@@ -272,6 +266,11 @@ async function resolveSpecifier(specifier, baseUrl, options) {
|
|
|
272
266
|
if (!baseUrl || !isHttpUrl(baseUrl))
|
|
273
267
|
return null;
|
|
274
268
|
const resolved = new URL(specifier, baseUrl).toString();
|
|
269
|
+
// For React core URLs: return the full esm.sh URL (not cached, to prevent multiple instances)
|
|
270
|
+
// This transforms relative paths like "/react-dom?..." to "https://esm.sh/react-dom?..."
|
|
271
|
+
if (isReactCoreUrl(resolved)) {
|
|
272
|
+
return normalizeHttpUrl(resolved);
|
|
273
|
+
}
|
|
275
274
|
const cached = await cacheHttpModule(resolved, options);
|
|
276
275
|
return cached ? `file://${cached}` : null;
|
|
277
276
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/import-rewriter.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB1F;
|
|
1
|
+
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/import-rewriter.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB1F;AAoDD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB3F;AAWD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAgEjB"}
|
|
@@ -40,9 +40,9 @@ function normalizeVersionedSpecifier(specifier) {
|
|
|
40
40
|
}
|
|
41
41
|
const REACT_IMPORT_MAP = {
|
|
42
42
|
react: `https://esm.sh/react@${REACT_DEFAULT_VERSION}?target=es2022`,
|
|
43
|
-
"react-dom": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}?target=es2022`,
|
|
44
|
-
"react-dom/client": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/client?target=es2022`,
|
|
45
|
-
"react-dom/server": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/server?target=es2022`,
|
|
43
|
+
"react-dom": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}?external=react&target=es2022`,
|
|
44
|
+
"react-dom/client": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/client?external=react&target=es2022`,
|
|
45
|
+
"react-dom/server": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/server?external=react&target=es2022`,
|
|
46
46
|
"react/jsx-runtime": `https://esm.sh/react@${REACT_DEFAULT_VERSION}/jsx-runtime?target=es2022`,
|
|
47
47
|
"react/jsx-dev-runtime": `https://esm.sh/react@${REACT_DEFAULT_VERSION}/jsx-dev-runtime?target=es2022`,
|
|
48
48
|
};
|
|
@@ -8,13 +8,20 @@
|
|
|
8
8
|
export declare const DEFAULT_REACT_VERSION = "19.1.1";
|
|
9
9
|
export declare const TAILWIND_VERSION = "4.1.8";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Validate React version format (semver: X.Y.Z).
|
|
12
|
+
* Returns true if valid, false otherwise.
|
|
13
13
|
*/
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function isValidReactVersion(version: string): boolean;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* Returns
|
|
16
|
+
* Validate and normalize React version.
|
|
17
|
+
* Returns the version if valid, or DEFAULT_REACT_VERSION if invalid.
|
|
18
|
+
* Logs a warning if the version is invalid.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeReactVersion(version: string | undefined): string;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Global React version is no longer supported.
|
|
23
|
+
* Use config.react.version passed through TransformOptions instead.
|
|
24
|
+
* This function now always returns DEFAULT_REACT_VERSION.
|
|
18
25
|
*/
|
|
19
26
|
export declare function getReactVersion(): string;
|
|
20
27
|
/** @deprecated Use DEFAULT_REACT_VERSION or getReactVersion() */
|
|
@@ -66,14 +73,9 @@ export declare function getReactUrls(version?: string): Record<string, string>;
|
|
|
66
73
|
*/
|
|
67
74
|
export declare function getReactImportMap(version?: string): Record<string, string>;
|
|
68
75
|
/**
|
|
69
|
-
* Get React
|
|
70
|
-
* Uses
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* Benefits over esm.sh:
|
|
74
|
-
* - Automatic semantic version deduplication (like Node's node_modules)
|
|
75
|
-
* - No manual external= flags or shared-*.ts wrapper files needed
|
|
76
|
-
* - Native support in Deno 2+
|
|
76
|
+
* Get React esm.sh URLs for Deno SSR.
|
|
77
|
+
* Uses esm.sh for both SSR and browser to ensure identical React instances.
|
|
78
|
+
* All sub-packages use external=react to share the same React instance.
|
|
77
79
|
*
|
|
78
80
|
* @param version - React version to use (defaults to REACT_VERSION)
|
|
79
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-registry.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/package-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,gBAAgB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"package-registry.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/package-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAOzE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,iEAAiE;AACjE,eAAO,MAAM,aAAa,WAAwB,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAa1C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAI9F;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO1E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU3E"}
|