@tanstack/start-plugin-core 1.167.35 → 1.169.0
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/esm/import-protection/adapterUtils.d.ts +27 -0
- package/dist/esm/import-protection/adapterUtils.js +31 -0
- package/dist/esm/import-protection/adapterUtils.js.map +1 -0
- package/dist/esm/import-protection/analysis.d.ts +36 -0
- package/dist/esm/import-protection/analysis.js +407 -0
- package/dist/esm/import-protection/analysis.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/ast.js +1 -1
- package/dist/esm/import-protection/ast.js.map +1 -0
- package/dist/esm/import-protection/constants.d.ts +11 -0
- package/dist/esm/{import-protection-plugin → import-protection}/constants.js +7 -2
- package/dist/esm/import-protection/constants.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/defaults.js +1 -1
- package/dist/esm/import-protection/defaults.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.js +2 -2
- package/dist/esm/import-protection/extensionlessAbsoluteIdResolver.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/matchers.js +1 -1
- package/dist/esm/import-protection/matchers.js.map +1 -0
- package/dist/esm/{import-protection-plugin/rewriteDeniedImports.d.ts → import-protection/rewrite.d.ts} +0 -4
- package/dist/esm/import-protection/rewrite.js +121 -0
- package/dist/esm/import-protection/rewrite.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/sourceLocation.d.ts +32 -3
- package/dist/esm/{import-protection-plugin → import-protection}/sourceLocation.js +65 -10
- package/dist/esm/import-protection/sourceLocation.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/trace.d.ts +0 -1
- package/dist/esm/{import-protection-plugin → import-protection}/trace.js +1 -1
- package/dist/esm/import-protection/trace.js.map +1 -0
- package/dist/esm/{import-protection-plugin → import-protection}/utils.d.ts +18 -1
- package/dist/esm/{import-protection-plugin → import-protection}/utils.js +13 -20
- package/dist/esm/import-protection/utils.js.map +1 -0
- package/dist/esm/import-protection/virtualModules.d.ts +25 -0
- package/dist/esm/{import-protection-plugin → import-protection}/virtualModules.js +5 -117
- package/dist/esm/import-protection/virtualModules.js.map +1 -0
- package/dist/esm/index.d.ts +1 -5
- package/dist/esm/index.js +2 -4
- package/dist/esm/post-build.d.ts +9 -0
- package/dist/esm/post-build.js +37 -0
- package/dist/esm/post-build.js.map +1 -0
- package/dist/esm/prerender.d.ts +11 -0
- package/dist/esm/prerender.js +159 -0
- package/dist/esm/prerender.js.map +1 -0
- package/dist/esm/rsbuild/dev-server.d.ts +21 -0
- package/dist/esm/rsbuild/dev-server.js +76 -0
- package/dist/esm/rsbuild/dev-server.js.map +1 -0
- package/dist/esm/rsbuild/import-protection.d.ts +10 -0
- package/dist/esm/rsbuild/import-protection.js +775 -0
- package/dist/esm/rsbuild/import-protection.js.map +1 -0
- package/dist/esm/rsbuild/index.d.ts +4 -0
- package/dist/esm/rsbuild/index.js +3 -0
- package/dist/esm/rsbuild/normalized-client-build.d.ts +18 -0
- package/dist/esm/rsbuild/normalized-client-build.js +207 -0
- package/dist/esm/rsbuild/normalized-client-build.js.map +1 -0
- package/dist/esm/rsbuild/planning.d.ts +52 -0
- package/dist/esm/rsbuild/planning.js +108 -0
- package/dist/esm/rsbuild/planning.js.map +1 -0
- package/dist/esm/rsbuild/plugin.d.ts +4 -0
- package/dist/esm/rsbuild/plugin.js +344 -0
- package/dist/esm/rsbuild/plugin.js.map +1 -0
- package/dist/esm/rsbuild/post-build.d.ts +6 -0
- package/dist/esm/rsbuild/post-build.js +57 -0
- package/dist/esm/rsbuild/post-build.js.map +1 -0
- package/dist/esm/rsbuild/schema.d.ts +3372 -0
- package/dist/esm/rsbuild/schema.js +12 -0
- package/dist/esm/rsbuild/schema.js.map +1 -0
- package/dist/esm/rsbuild/start-compiler-host.d.ts +20 -0
- package/dist/esm/rsbuild/start-compiler-host.js +150 -0
- package/dist/esm/rsbuild/start-compiler-host.js.map +1 -0
- package/dist/esm/rsbuild/start-router-plugin.d.ts +18 -0
- package/dist/esm/rsbuild/start-router-plugin.js +63 -0
- package/dist/esm/rsbuild/start-router-plugin.js.map +1 -0
- package/dist/esm/rsbuild/swc-rsc.d.ts +14 -0
- package/dist/esm/rsbuild/swc-rsc.js +93 -0
- package/dist/esm/rsbuild/swc-rsc.js.map +1 -0
- package/dist/esm/rsbuild/types.d.ts +17 -0
- package/dist/esm/rsbuild/types.js +0 -0
- package/dist/esm/rsbuild/virtual-modules.d.ts +53 -0
- package/dist/esm/rsbuild/virtual-modules.js +287 -0
- package/dist/esm/rsbuild/virtual-modules.js.map +1 -0
- package/dist/esm/schema.d.ts +43 -43
- package/dist/esm/start-compiler/compiler.d.ts +1 -1
- package/dist/esm/start-compiler/compiler.js +80 -9
- package/dist/esm/start-compiler/compiler.js.map +1 -1
- package/dist/esm/start-compiler/handleCreateServerFn.js +9 -0
- package/dist/esm/start-compiler/handleCreateServerFn.js.map +1 -1
- package/dist/esm/start-compiler/host.js +5 -1
- package/dist/esm/start-compiler/host.js.map +1 -1
- package/dist/esm/start-compiler/types.d.ts +1 -0
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +10 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/plugin.js +41 -92
- package/dist/esm/vite/import-protection-plugin/plugin.js.map +1 -0
- package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/types.d.ts +5 -5
- package/dist/esm/vite/import-protection-plugin/virtualModules.d.ts +8 -0
- package/dist/esm/vite/import-protection-plugin/virtualModules.js +49 -0
- package/dist/esm/vite/import-protection-plugin/virtualModules.js.map +1 -0
- package/dist/esm/vite/index.d.ts +5 -0
- package/dist/esm/vite/index.js +4 -0
- package/dist/esm/vite/plugin.js +1 -1
- package/dist/esm/vite/plugin.js.map +1 -1
- package/dist/esm/vite/post-server-build.js +14 -32
- package/dist/esm/vite/post-server-build.js.map +1 -1
- package/dist/esm/vite/prerender.d.ts +2 -2
- package/dist/esm/vite/prerender.js +17 -147
- package/dist/esm/vite/prerender.js.map +1 -1
- package/dist/esm/vite/schema.d.ts +23 -23
- package/dist/esm/vite/start-compiler-plugin/hot-update.d.ts +2 -0
- package/dist/esm/vite/start-compiler-plugin/hot-update.js +16 -0
- package/dist/esm/vite/start-compiler-plugin/hot-update.js.map +1 -0
- package/dist/esm/vite/start-compiler-plugin/module-specifier.js +9 -4
- package/dist/esm/vite/start-compiler-plugin/module-specifier.js.map +1 -1
- package/dist/esm/vite/start-compiler-plugin/plugin.js +86 -13
- package/dist/esm/vite/start-compiler-plugin/plugin.js.map +1 -1
- package/package.json +32 -4
- package/src/import-protection/INTERNALS.md +266 -0
- package/src/import-protection/adapterUtils.ts +94 -0
- package/src/import-protection/analysis.ts +853 -0
- package/src/{import-protection-plugin → import-protection}/constants.ts +7 -0
- package/src/import-protection/rewrite.ts +229 -0
- package/src/{import-protection-plugin → import-protection}/sourceLocation.ts +125 -9
- package/src/{import-protection-plugin → import-protection}/trace.ts +0 -1
- package/src/{import-protection-plugin → import-protection}/utils.ts +36 -21
- package/src/{import-protection-plugin → import-protection}/virtualModules.ts +30 -177
- package/src/index.ts +1 -8
- package/src/post-build.ts +64 -0
- package/src/prerender.ts +292 -0
- package/src/rsbuild/INTERNALS-import-protection.md +169 -0
- package/src/rsbuild/dev-server.ts +129 -0
- package/src/rsbuild/import-protection.ts +1599 -0
- package/src/rsbuild/index.ts +4 -0
- package/src/rsbuild/normalized-client-build.ts +346 -0
- package/src/rsbuild/planning.ts +234 -0
- package/src/rsbuild/plugin.ts +754 -0
- package/src/rsbuild/post-build.ts +96 -0
- package/src/rsbuild/schema.ts +31 -0
- package/src/rsbuild/start-compiler-host.ts +250 -0
- package/src/rsbuild/start-router-plugin.ts +86 -0
- package/src/rsbuild/swc-rsc.ts +166 -0
- package/src/rsbuild/types.ts +20 -0
- package/src/rsbuild/virtual-modules.ts +565 -0
- package/src/start-compiler/compiler.ts +153 -19
- package/src/start-compiler/handleCreateServerFn.ts +18 -0
- package/src/start-compiler/types.ts +1 -0
- package/src/utils.ts +14 -0
- package/src/vite/import-protection-plugin/INTERNALS.md +187 -0
- package/src/{import-protection-plugin → vite/import-protection-plugin}/plugin.ts +73 -158
- package/src/{import-protection-plugin → vite/import-protection-plugin}/types.ts +5 -5
- package/src/vite/import-protection-plugin/virtualModules.ts +122 -0
- package/src/vite/index.ts +8 -0
- package/src/vite/plugin.ts +1 -1
- package/src/vite/post-server-build.ts +14 -57
- package/src/vite/prerender.ts +19 -260
- package/src/vite/start-compiler-plugin/hot-update.ts +24 -0
- package/src/vite/start-compiler-plugin/module-specifier.ts +15 -5
- package/src/vite/start-compiler-plugin/plugin.ts +193 -18
- package/dist/esm/import-protection-plugin/ast.js.map +0 -1
- package/dist/esm/import-protection-plugin/constants.d.ts +0 -6
- package/dist/esm/import-protection-plugin/constants.js.map +0 -1
- package/dist/esm/import-protection-plugin/defaults.js.map +0 -1
- package/dist/esm/import-protection-plugin/extensionlessAbsoluteIdResolver.js.map +0 -1
- package/dist/esm/import-protection-plugin/matchers.js.map +0 -1
- package/dist/esm/import-protection-plugin/plugin.js.map +0 -1
- package/dist/esm/import-protection-plugin/postCompileUsage.d.ts +0 -13
- package/dist/esm/import-protection-plugin/postCompileUsage.js +0 -63
- package/dist/esm/import-protection-plugin/postCompileUsage.js.map +0 -1
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js +0 -205
- package/dist/esm/import-protection-plugin/rewriteDeniedImports.js.map +0 -1
- package/dist/esm/import-protection-plugin/sourceLocation.js.map +0 -1
- package/dist/esm/import-protection-plugin/trace.js.map +0 -1
- package/dist/esm/import-protection-plugin/utils.js.map +0 -1
- package/dist/esm/import-protection-plugin/virtualModules.d.ts +0 -78
- package/dist/esm/import-protection-plugin/virtualModules.js.map +0 -1
- package/dist/esm/start-compiler/load-module.d.ts +0 -14
- package/dist/esm/start-compiler/load-module.js +0 -18
- package/dist/esm/start-compiler/load-module.js.map +0 -1
- package/src/import-protection-plugin/INTERNALS.md +0 -700
- package/src/import-protection-plugin/postCompileUsage.ts +0 -100
- package/src/import-protection-plugin/rewriteDeniedImports.ts +0 -379
- package/src/start-compiler/load-module.ts +0 -31
- /package/dist/esm/{import-protection-plugin → import-protection}/ast.d.ts +0 -0
- /package/dist/esm/{import-protection-plugin → import-protection}/defaults.d.ts +0 -0
- /package/dist/esm/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.d.ts +0 -0
- /package/dist/esm/{import-protection-plugin → import-protection}/matchers.d.ts +0 -0
- /package/dist/esm/{import-protection-plugin → vite/import-protection-plugin}/plugin.d.ts +0 -0
- /package/src/{import-protection-plugin → import-protection}/ast.ts +0 -0
- /package/src/{import-protection-plugin → import-protection}/defaults.ts +0 -0
- /package/src/{import-protection-plugin → import-protection}/extensionlessAbsoluteIdResolver.ts +0 -0
- /package/src/{import-protection-plugin → import-protection}/matchers.ts +0 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { generateServerFnResolverModule } from "../start-compiler/server-fn-resolver-module.js";
|
|
2
|
+
import { buildStartManifest } from "../start-manifest-plugin/manifestBuilder.js";
|
|
3
|
+
import { generateSerializationAdaptersModule } from "../serialization-adapters-module.js";
|
|
4
|
+
import { RSBUILD_ENVIRONMENT_NAMES } from "./planning.js";
|
|
5
|
+
import { VIRTUAL_MODULES } from "@tanstack/start-server-core";
|
|
6
|
+
//#region src/rsbuild/virtual-modules.ts
|
|
7
|
+
var RSC_RUNTIME_VIRTUAL_ID = "virtual:tanstack-rsc-runtime";
|
|
8
|
+
var RSC_HMR_VIRTUAL_ID = "virtual:tanstack-rsc-hmr";
|
|
9
|
+
var RSC_BROWSER_DECODE_VIRTUAL_ID = "virtual:tanstack-rsc-browser-decode";
|
|
10
|
+
var RSC_SSR_DECODE_VIRTUAL_ID = "virtual:tanstack-rsc-ssr-decode";
|
|
11
|
+
var START_MANIFEST_PLACEHOLDER = "__TSS_START_MANIFEST_PLACEHOLDER__";
|
|
12
|
+
var DEV_START_MANIFEST_GLOBAL = "__TSS_DEV_START_MANIFEST__";
|
|
13
|
+
/**
|
|
14
|
+
* VirtualModulesPlugin resolves module paths relative to compiler.context.
|
|
15
|
+
* Prefix them under the app root so they are unique and watcher-friendly.
|
|
16
|
+
*/
|
|
17
|
+
function virtualPath(root, moduleId) {
|
|
18
|
+
return `${root}/node_modules/.virtual/${moduleId.replace(/[:#]/g, "_")}.js`;
|
|
19
|
+
}
|
|
20
|
+
function generateManifestModuleDev(devClientEntryUrl) {
|
|
21
|
+
return `const fallbackManifest = {
|
|
22
|
+
routes: {},
|
|
23
|
+
clientEntry: '${devClientEntryUrl}',
|
|
24
|
+
}
|
|
25
|
+
export const tsrStartManifest = () => globalThis[${JSON.stringify(DEV_START_MANIFEST_GLOBAL)}] ?? fallbackManifest`;
|
|
26
|
+
}
|
|
27
|
+
function buildStartManifestData(clientBuild, publicBase) {
|
|
28
|
+
const routeTreeRoutes = globalThis.TSS_ROUTES_MANIFEST;
|
|
29
|
+
return buildStartManifest({
|
|
30
|
+
clientBuild,
|
|
31
|
+
routeTreeRoutes,
|
|
32
|
+
basePath: publicBase
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function serializeStartManifestData(clientBuild, publicBase) {
|
|
36
|
+
return JSON.stringify(buildStartManifestData(clientBuild, publicBase));
|
|
37
|
+
}
|
|
38
|
+
function generateManifestModuleBuild(clientBuild, publicBase, _devClientEntryUrl) {
|
|
39
|
+
if (!clientBuild) return `const tsrStartManifestData = ${JSON.stringify(START_MANIFEST_PLACEHOLDER)}
|
|
40
|
+
export const tsrStartManifest = () => tsrStartManifestData`;
|
|
41
|
+
return `export const tsrStartManifest = () => (${serializeStartManifestData(clientBuild, publicBase)})`;
|
|
42
|
+
}
|
|
43
|
+
function generateInjectedHeadScripts(scripts) {
|
|
44
|
+
return `export const injectedHeadScripts = ${scripts ? JSON.stringify(scripts) : "undefined"}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate virtual:tanstack-rsc-runtime content.
|
|
48
|
+
* In the RSC layer this re-exports from react-server-dom-rspack/server.
|
|
49
|
+
* In other layers it provides stubs that throw.
|
|
50
|
+
*/
|
|
51
|
+
function generateRscRuntimeModule(isRscLayer) {
|
|
52
|
+
if (isRscLayer) return `export { renderToReadableStream, createTemporaryReferenceSet, decodeReply, decodeAction, decodeFormState } from 'react-server-dom-rspack/server'
|
|
53
|
+
export function createFromReadableStream() { throw new Error('createFromReadableStream is not available in RSC environment (use SSR or browser decode instead)'); }
|
|
54
|
+
// loadServerAction is provided by the RSC entry, not react-server-dom-rspack
|
|
55
|
+
import { getServerFnById } from '#tanstack-start-server-fn-resolver'
|
|
56
|
+
export const loadServerAction = async (id) => getServerFnById(id, { origin: 'server' })`;
|
|
57
|
+
return `
|
|
58
|
+
export function renderToReadableStream() { throw new Error('renderToReadableStream can only be used in RSC environment'); }
|
|
59
|
+
export function createFromReadableStream() { throw new Error('createFromReadableStream can only be used in RSC environment'); }
|
|
60
|
+
export function createTemporaryReferenceSet() { throw new Error('createTemporaryReferenceSet can only be used in RSC environment'); }
|
|
61
|
+
export function decodeReply() { throw new Error('decodeReply can only be used in RSC environment'); }
|
|
62
|
+
export function loadServerAction() { throw new Error('loadServerAction can only be used in RSC environment'); }
|
|
63
|
+
export function decodeAction() { throw new Error('decodeAction can only be used in RSC environment'); }
|
|
64
|
+
export function decodeFormState() { throw new Error('decodeFormState can only be used in RSC environment'); }
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate virtual:tanstack-rsc-hmr content.
|
|
69
|
+
* In the client env during dev, listens for rsc:update WebSocket events
|
|
70
|
+
* and invalidates the router. In all other contexts, exports nothing.
|
|
71
|
+
*/
|
|
72
|
+
function generateRscHmrModule(isClientEnv, isDev) {
|
|
73
|
+
if (!isClientEnv || !isDev) return "export function setupRscHmr() {}";
|
|
74
|
+
return `
|
|
75
|
+
// RSC HMR listener for rsbuild dev server
|
|
76
|
+
// Listens for 'rsc:update' custom events sent via sockWrite
|
|
77
|
+
export function setupRscHmr() {
|
|
78
|
+
let __invalidateQueued = false
|
|
79
|
+
|
|
80
|
+
function __queueInvalidate() {
|
|
81
|
+
if (__invalidateQueued) return
|
|
82
|
+
__invalidateQueued = true
|
|
83
|
+
queueMicrotask(async () => {
|
|
84
|
+
__invalidateQueued = false
|
|
85
|
+
try {
|
|
86
|
+
const router = window.__TSR_ROUTER__
|
|
87
|
+
if (!router) {
|
|
88
|
+
console.warn('[rsc:hmr] No router found on window.__TSR_ROUTER__')
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
await router.invalidate()
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.warn('[rsc:hmr] Failed to invalidate router:', e)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (import.meta.webpackHot) {
|
|
99
|
+
import.meta.webpackHot.on('rsc:update', () => {
|
|
100
|
+
__queueInvalidate()
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Registers virtual modules for the rsbuild adapter using VirtualModulesPlugin.
|
|
108
|
+
*
|
|
109
|
+
* Creates one VirtualModulesPlugin per environment and registers them via
|
|
110
|
+
* `modifyBundlerChain`. Provides update functions to refresh content dynamically.
|
|
111
|
+
*/
|
|
112
|
+
function registerVirtualModules(api, opts) {
|
|
113
|
+
const isDev = api.context.action === "dev";
|
|
114
|
+
const root = opts.root;
|
|
115
|
+
const paths = {
|
|
116
|
+
manifest: virtualPath(root, VIRTUAL_MODULES.startManifest),
|
|
117
|
+
injectedHeadScripts: virtualPath(root, VIRTUAL_MODULES.injectedHeadScripts),
|
|
118
|
+
serverFnResolver: virtualPath(root, VIRTUAL_MODULES.serverFnResolver),
|
|
119
|
+
pluginAdapters: virtualPath(root, VIRTUAL_MODULES.pluginAdapters)
|
|
120
|
+
};
|
|
121
|
+
const rscPaths = opts.rscEnabled ? {
|
|
122
|
+
rscRuntime: virtualPath(root, RSC_RUNTIME_VIRTUAL_ID),
|
|
123
|
+
rscHmr: virtualPath(root, RSC_HMR_VIRTUAL_ID),
|
|
124
|
+
rscBrowserDecode: virtualPath(root, RSC_BROWSER_DECODE_VIRTUAL_ID),
|
|
125
|
+
rscSsrDecode: virtualPath(root, RSC_SSR_DECODE_VIRTUAL_ID)
|
|
126
|
+
} : null;
|
|
127
|
+
const vmPlugins = {};
|
|
128
|
+
const readyVmPlugins = {};
|
|
129
|
+
const pendingWrites = /* @__PURE__ */ new Map();
|
|
130
|
+
let clientBuild;
|
|
131
|
+
const lastResolverContentByEnvironment = {};
|
|
132
|
+
const hasSeparateProviderEnvironment = !opts.rscEnabled && opts.providerEnvName !== RSBUILD_ENVIRONMENT_NAMES.server;
|
|
133
|
+
function isProviderEnvironment(environmentName) {
|
|
134
|
+
return environmentName === opts.providerEnvName;
|
|
135
|
+
}
|
|
136
|
+
function needsServerFnResolver(environmentName) {
|
|
137
|
+
return environmentName === RSBUILD_ENVIRONMENT_NAMES.server || hasSeparateProviderEnvironment && isProviderEnvironment(environmentName);
|
|
138
|
+
}
|
|
139
|
+
function generateResolverContent(environmentName) {
|
|
140
|
+
return generateServerFnResolverModule({
|
|
141
|
+
serverFnsById: opts.serverFnsById,
|
|
142
|
+
includeClientReferencedCheck: !isProviderEnvironment(environmentName),
|
|
143
|
+
useStaticImports: Boolean(opts.rscEnabled && isDev)
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function writeResolverContent(environmentName, content) {
|
|
147
|
+
if (!isDev || content !== lastResolverContentByEnvironment[environmentName]) {
|
|
148
|
+
lastResolverContentByEnvironment[environmentName] = content;
|
|
149
|
+
tryWriteModule(environmentName, paths.serverFnResolver, content);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function queuePendingWrite(environmentName, filePath, content) {
|
|
153
|
+
let writes = pendingWrites.get(environmentName);
|
|
154
|
+
if (!writes) {
|
|
155
|
+
writes = /* @__PURE__ */ new Map();
|
|
156
|
+
pendingWrites.set(environmentName, writes);
|
|
157
|
+
}
|
|
158
|
+
writes.set(filePath, content);
|
|
159
|
+
}
|
|
160
|
+
function tryWriteModule(environmentName, filePath, content) {
|
|
161
|
+
const vmPlugin = vmPlugins[environmentName];
|
|
162
|
+
if (!vmPlugin || !readyVmPlugins[environmentName]) {
|
|
163
|
+
queuePendingWrite(environmentName, filePath, content);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
vmPlugin.writeModule(filePath, content);
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
function flushPendingWrites(environmentName) {
|
|
170
|
+
if (!readyVmPlugins[environmentName]) return;
|
|
171
|
+
const writes = pendingWrites.get(environmentName);
|
|
172
|
+
if (!writes?.size) return;
|
|
173
|
+
for (const [filePath, content] of writes) {
|
|
174
|
+
if (!tryWriteModule(environmentName, filePath, content)) return;
|
|
175
|
+
writes.delete(filePath);
|
|
176
|
+
}
|
|
177
|
+
if (writes.size === 0) pendingWrites.delete(environmentName);
|
|
178
|
+
}
|
|
179
|
+
function getInitialContent(environmentName) {
|
|
180
|
+
const { resolvedStartConfig } = opts.getConfig();
|
|
181
|
+
const isServerEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.server;
|
|
182
|
+
const isClientEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.client;
|
|
183
|
+
const content = {};
|
|
184
|
+
if (isServerEnv) {
|
|
185
|
+
const devClientEntryUrl = opts.getDevClientEntryUrl(resolvedStartConfig.basePaths.publicBase);
|
|
186
|
+
content[paths.manifest] = isDev ? generateManifestModuleDev(devClientEntryUrl) : generateManifestModuleBuild(clientBuild, resolvedStartConfig.basePaths.publicBase, devClientEntryUrl);
|
|
187
|
+
} else content[paths.manifest] = "export default {}";
|
|
188
|
+
content[paths.injectedHeadScripts] = generateInjectedHeadScripts();
|
|
189
|
+
if (needsServerFnResolver(environmentName)) content[paths.serverFnResolver] = generateResolverContent(environmentName);
|
|
190
|
+
else content[paths.serverFnResolver] = "export {}";
|
|
191
|
+
content[paths.pluginAdapters] = generateSerializationAdaptersModule({
|
|
192
|
+
adapters: opts.serializationAdapters,
|
|
193
|
+
runtime: environmentName === RSBUILD_ENVIRONMENT_NAMES.client ? "client" : "server"
|
|
194
|
+
});
|
|
195
|
+
if (rscPaths) {
|
|
196
|
+
if (isServerEnv) content[rscPaths.rscRuntime] = generateRscRuntimeModule(true);
|
|
197
|
+
else content[rscPaths.rscRuntime] = generateRscRuntimeModule(false);
|
|
198
|
+
content[rscPaths.rscHmr] = generateRscHmrModule(isClientEnv, isDev);
|
|
199
|
+
content[rscPaths.rscBrowserDecode] = isClientEnv ? `export * from '@tanstack/react-start/rsbuild/browser-decode'` : `export function createFromReadableStream() { throw new Error('RSC browser decode is only available in the client environment') }
|
|
200
|
+
export function createFromFetch() { throw new Error('RSC browser decode is only available in the client environment') }`;
|
|
201
|
+
content[rscPaths.rscSsrDecode] = isServerEnv ? `export * from '@tanstack/react-start/rsbuild/ssr-decode'` : `export function setOnClientReference() {}
|
|
202
|
+
export function createFromReadableStream() { throw new Error('RSC SSR decode is only available in the server environment') }`;
|
|
203
|
+
}
|
|
204
|
+
return content;
|
|
205
|
+
}
|
|
206
|
+
const aliasMap = {
|
|
207
|
+
[VIRTUAL_MODULES.startManifest]: paths.manifest,
|
|
208
|
+
[VIRTUAL_MODULES.injectedHeadScripts]: paths.injectedHeadScripts,
|
|
209
|
+
[VIRTUAL_MODULES.serverFnResolver]: paths.serverFnResolver,
|
|
210
|
+
[VIRTUAL_MODULES.pluginAdapters]: paths.pluginAdapters
|
|
211
|
+
};
|
|
212
|
+
if (rscPaths) {
|
|
213
|
+
aliasMap[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime;
|
|
214
|
+
aliasMap[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr;
|
|
215
|
+
aliasMap[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode;
|
|
216
|
+
aliasMap[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode;
|
|
217
|
+
}
|
|
218
|
+
api.modifyRspackConfig((config, utils) => {
|
|
219
|
+
const envName = utils.environment.name;
|
|
220
|
+
const initialContent = getInitialContent(envName);
|
|
221
|
+
const VMP = utils.rspack.experiments.VirtualModulesPlugin;
|
|
222
|
+
const vmPlugin = new VMP(initialContent);
|
|
223
|
+
vmPlugins[envName] = vmPlugin;
|
|
224
|
+
readyVmPlugins[envName] = false;
|
|
225
|
+
config.plugins.push(vmPlugin);
|
|
226
|
+
config.plugins.push({ apply(compiler) {
|
|
227
|
+
compiler.hooks.thisCompilation.tap("TanStackStartFlushPendingVirtualModules", () => {
|
|
228
|
+
readyVmPlugins[envName] = true;
|
|
229
|
+
flushPendingWrites(envName);
|
|
230
|
+
});
|
|
231
|
+
} });
|
|
232
|
+
for (const [moduleId, virtualFilePath] of Object.entries(aliasMap)) {
|
|
233
|
+
const escaped = moduleId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
234
|
+
const NMR = utils.rspack.NormalModuleReplacementPlugin;
|
|
235
|
+
config.plugins.push(new NMR(new RegExp(`^${escaped}$`), virtualFilePath));
|
|
236
|
+
}
|
|
237
|
+
const resolve = config.resolve;
|
|
238
|
+
const resolveAlias = resolve.alias ??= {};
|
|
239
|
+
resolveAlias[VIRTUAL_MODULES.serverFnResolver] = paths.serverFnResolver;
|
|
240
|
+
resolveAlias[VIRTUAL_MODULES.pluginAdapters] = paths.pluginAdapters;
|
|
241
|
+
if (rscPaths) {
|
|
242
|
+
resolveAlias[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime;
|
|
243
|
+
resolveAlias[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr;
|
|
244
|
+
resolveAlias[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode;
|
|
245
|
+
resolveAlias[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
serverFnResolverPath: paths.serverFnResolver,
|
|
250
|
+
manifestPath: paths.manifest,
|
|
251
|
+
vmPlugins,
|
|
252
|
+
generateCurrentResolverContent(forProvider) {
|
|
253
|
+
return generateResolverContent(forProvider ? opts.providerEnvName : RSBUILD_ENVIRONMENT_NAMES.server);
|
|
254
|
+
},
|
|
255
|
+
generateManifestContent(newClientBuild) {
|
|
256
|
+
const { resolvedStartConfig } = opts.getConfig();
|
|
257
|
+
const devClientEntryUrl = opts.getDevClientEntryUrl(resolvedStartConfig.basePaths.publicBase);
|
|
258
|
+
return generateManifestModuleBuild(newClientBuild, resolvedStartConfig.basePaths.publicBase, devClientEntryUrl);
|
|
259
|
+
},
|
|
260
|
+
generateManifestValueLiteral(newClientBuild) {
|
|
261
|
+
const { resolvedStartConfig } = opts.getConfig();
|
|
262
|
+
return serializeStartManifestData(newClientBuild, resolvedStartConfig.basePaths.publicBase);
|
|
263
|
+
},
|
|
264
|
+
updateManifest(newClientBuild) {
|
|
265
|
+
clientBuild = newClientBuild;
|
|
266
|
+
const { resolvedStartConfig } = opts.getConfig();
|
|
267
|
+
if (isDev) globalThis[DEV_START_MANIFEST_GLOBAL] = buildStartManifestData(clientBuild, resolvedStartConfig.basePaths.publicBase);
|
|
268
|
+
},
|
|
269
|
+
updateServerFnResolver() {
|
|
270
|
+
for (const environmentName of new Set([RSBUILD_ENVIRONMENT_NAMES.server, ...hasSeparateProviderEnvironment ? [opts.providerEnvName] : []])) {
|
|
271
|
+
if (!needsServerFnResolver(environmentName)) continue;
|
|
272
|
+
writeResolverContent(environmentName, generateResolverContent(environmentName));
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
tryUpdateServerFnResolver(content) {
|
|
276
|
+
lastResolverContentByEnvironment[RSBUILD_ENVIRONMENT_NAMES.server] = content;
|
|
277
|
+
tryWriteModule(RSBUILD_ENVIRONMENT_NAMES.server, paths.serverFnResolver, content);
|
|
278
|
+
},
|
|
279
|
+
getVirtualPath(moduleId) {
|
|
280
|
+
return virtualPath(root, moduleId);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { START_MANIFEST_PLACEHOLDER, registerVirtualModules };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=virtual-modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-modules.js","names":[],"sources":["../../../src/rsbuild/virtual-modules.ts"],"sourcesContent":["import { VIRTUAL_MODULES } from '@tanstack/start-server-core'\nimport { generateSerializationAdaptersModule } from '../serialization-adapters-module'\nimport { generateServerFnResolverModule } from '../start-compiler/server-fn-resolver-module'\nimport { buildStartManifest } from '../start-manifest-plugin/manifestBuilder'\nimport { RSBUILD_ENVIRONMENT_NAMES } from './planning'\nimport type {\n RsbuildPluginAPI,\n rspack as rspackNamespaceType,\n} from '@rsbuild/core'\nimport type {\n GetConfigFn,\n NormalizedClientBuild,\n SerializationAdapterConfig,\n} from '../types'\nimport type { ServerFn } from '../start-compiler/types'\n\ntype RspackNamespace = typeof rspackNamespaceType\ntype RspackVirtualModulesPlugin = InstanceType<\n RspackNamespace['experiments']['VirtualModulesPlugin']\n>\n\n// Virtual module IDs for RSC (must match what react-start-rsc imports)\nconst RSC_RUNTIME_VIRTUAL_ID = 'virtual:tanstack-rsc-runtime'\nconst RSC_HMR_VIRTUAL_ID = 'virtual:tanstack-rsc-hmr'\nconst RSC_BROWSER_DECODE_VIRTUAL_ID = 'virtual:tanstack-rsc-browser-decode'\nconst RSC_SSR_DECODE_VIRTUAL_ID = 'virtual:tanstack-rsc-ssr-decode'\nexport const START_MANIFEST_PLACEHOLDER = '__TSS_START_MANIFEST_PLACEHOLDER__'\nconst DEV_START_MANIFEST_GLOBAL = '__TSS_DEV_START_MANIFEST__'\n/**\n * VirtualModulesPlugin resolves module paths relative to compiler.context.\n * Prefix them under the app root so they are unique and watcher-friendly.\n */\nfunction virtualPath(root: string, moduleId: string): string {\n // VirtualModulesPlugin resolves paths relative to compiler.context (root).\n // Use a recognizable prefix to avoid collisions with real files.\n const sanitized = moduleId.replace(/[:#]/g, '_')\n return `${root}/node_modules/.virtual/${sanitized}.js`\n}\n\nexport interface VirtualModuleState {\n /** Call to update manifest content after client build completes */\n updateManifest: (clientBuild: NormalizedClientBuild) => void\n /** Call to update server fn resolver content after compilation discovers fns */\n updateServerFnResolver: () => void\n /** Try to write explicit resolver content now; queues if env not ready */\n tryUpdateServerFnResolver: (content: string) => void\n /** Get the virtual path for a given module ID */\n getVirtualPath: (moduleId: string) => string\n /** Generate resolver module content from current serverFnsById state.\n * When forProvider=true, generates without isClientReferenced checks (RSC layer). */\n generateCurrentResolverContent: (forProvider?: boolean) => string\n /** The absolute virtual path of the server fn resolver module */\n serverFnResolverPath: string\n /** The absolute virtual path of the manifest module */\n manifestPath: string\n /** Generate manifest module content from a given client build */\n generateManifestContent: (clientBuild: NormalizedClientBuild) => string\n /** Generate the serialized manifest value literal for asset patching */\n generateManifestValueLiteral: (clientBuild: NormalizedClientBuild) => string\n /** VirtualModulesPlugin instances keyed by environment name */\n vmPlugins: Record<string, RspackVirtualModulesPlugin>\n}\n\n// ---------------------------------------------------------------------------\n// Manifest module codegen\n// ---------------------------------------------------------------------------\n\nfunction generateManifestModuleDev(devClientEntryUrl: string): string {\n return `const fallbackManifest = {\n routes: {},\n clientEntry: '${devClientEntryUrl}',\n}\nexport const tsrStartManifest = () => globalThis[${JSON.stringify(DEV_START_MANIFEST_GLOBAL)}] ?? fallbackManifest`\n}\n\nfunction buildStartManifestData(\n clientBuild: NormalizedClientBuild,\n publicBase: string,\n) {\n const routeTreeRoutes = globalThis.TSS_ROUTES_MANIFEST\n return buildStartManifest({\n clientBuild,\n routeTreeRoutes,\n basePath: publicBase,\n })\n}\n\nfunction serializeStartManifestData(\n clientBuild: NormalizedClientBuild,\n publicBase: string,\n): string {\n return JSON.stringify(buildStartManifestData(clientBuild, publicBase))\n}\n\nfunction generateManifestModuleBuild(\n clientBuild: NormalizedClientBuild | undefined,\n publicBase: string,\n _devClientEntryUrl: string,\n): string {\n if (!clientBuild) {\n return `const tsrStartManifestData = ${JSON.stringify(START_MANIFEST_PLACEHOLDER)}\nexport const tsrStartManifest = () => tsrStartManifestData`\n }\n\n return `export const tsrStartManifest = () => (${serializeStartManifestData(clientBuild, publicBase)})`\n}\n\n// ---------------------------------------------------------------------------\n// Injected head scripts codegen\n// ---------------------------------------------------------------------------\n\nfunction generateInjectedHeadScripts(scripts?: string): string {\n return `export const injectedHeadScripts = ${scripts ? JSON.stringify(scripts) : 'undefined'}`\n}\n\n// ---------------------------------------------------------------------------\n// RSC virtual module codegen\n// ---------------------------------------------------------------------------\n\n/**\n * Generate virtual:tanstack-rsc-runtime content.\n * In the RSC layer this re-exports from react-server-dom-rspack/server.\n * In other layers it provides stubs that throw.\n */\nfunction generateRscRuntimeModule(isRscLayer: boolean): string {\n if (isRscLayer) {\n // Re-export the RSC runtime functions from react-server-dom-rspack/server.\n // NOTE: `createFromReadableStream` is a CLIENT-side API — it's NOT exported\n // by react-server-dom-rspack/server. The RSC layer never needs it (RSC\n // renders TO streams, doesn't decode FROM them). We provide a stub that\n // throws so the export surface stays consistent across bundlers.\n return `export { renderToReadableStream, createTemporaryReferenceSet, decodeReply, decodeAction, decodeFormState } from 'react-server-dom-rspack/server'\nexport function createFromReadableStream() { throw new Error('createFromReadableStream is not available in RSC environment (use SSR or browser decode instead)'); }\n// loadServerAction is provided by the RSC entry, not react-server-dom-rspack\nimport { getServerFnById } from '#tanstack-start-server-fn-resolver'\nexport const loadServerAction = async (id) => getServerFnById(id, { origin: 'server' })`\n }\n\n // In other layers, provide stubs that throw\n return `\nexport function renderToReadableStream() { throw new Error('renderToReadableStream can only be used in RSC environment'); }\nexport function createFromReadableStream() { throw new Error('createFromReadableStream can only be used in RSC environment'); }\nexport function createTemporaryReferenceSet() { throw new Error('createTemporaryReferenceSet can only be used in RSC environment'); }\nexport function decodeReply() { throw new Error('decodeReply can only be used in RSC environment'); }\nexport function loadServerAction() { throw new Error('loadServerAction can only be used in RSC environment'); }\nexport function decodeAction() { throw new Error('decodeAction can only be used in RSC environment'); }\nexport function decodeFormState() { throw new Error('decodeFormState can only be used in RSC environment'); }\n`\n}\n\n/**\n * Generate virtual:tanstack-rsc-hmr content.\n * In the client env during dev, listens for rsc:update WebSocket events\n * and invalidates the router. In all other contexts, exports nothing.\n */\nfunction generateRscHmrModule(isClientEnv: boolean, isDev: boolean): string {\n if (!isClientEnv || !isDev) {\n return 'export function setupRscHmr() {}'\n }\n\n // Rsbuild dev server delivers custom WebSocket events through\n // import.meta.webpackHot.on(event, cb). The server-side\n // sockWrite('custom', { event: 'rsc:update' }) maps directly to that.\n return `\n// RSC HMR listener for rsbuild dev server\n// Listens for 'rsc:update' custom events sent via sockWrite\nexport function setupRscHmr() {\n let __invalidateQueued = false\n\n function __queueInvalidate() {\n if (__invalidateQueued) return\n __invalidateQueued = true\n queueMicrotask(async () => {\n __invalidateQueued = false\n try {\n const router = window.__TSR_ROUTER__\n if (!router) {\n console.warn('[rsc:hmr] No router found on window.__TSR_ROUTER__')\n return\n }\n await router.invalidate()\n } catch (e) {\n console.warn('[rsc:hmr] Failed to invalidate router:', e)\n }\n })\n }\n\n if (import.meta.webpackHot) {\n import.meta.webpackHot.on('rsc:update', () => {\n __queueInvalidate()\n })\n }\n}\n`\n}\n\n// ---------------------------------------------------------------------------\n// Main registration\n// ---------------------------------------------------------------------------\n\nexport interface RegisterVirtualModulesOptions {\n root: string\n getConfig: GetConfigFn\n serverFnsById: Record<string, ServerFn>\n providerEnvName: string\n ssrIsProvider: boolean\n serializationAdapters: Array<SerializationAdapterConfig> | undefined\n /**\n * Get the URL at which the rsbuild dev server serves the client entry JS.\n * Called lazily inside modifyRspackConfig when getConfig() is available.\n * Example return: '/static/js/index.js'\n */\n getDevClientEntryUrl: (publicBase: string) => string\n /** Whether RSC virtual modules should be registered. */\n rscEnabled?: boolean | undefined\n}\n\n/**\n * Registers virtual modules for the rsbuild adapter using VirtualModulesPlugin.\n *\n * Creates one VirtualModulesPlugin per environment and registers them via\n * `modifyBundlerChain`. Provides update functions to refresh content dynamically.\n */\nexport function registerVirtualModules(\n api: RsbuildPluginAPI,\n opts: RegisterVirtualModulesOptions,\n): VirtualModuleState {\n const isDev = api.context.action === 'dev'\n const root = opts.root\n\n // Virtual module paths keyed by module ID\n const paths = {\n manifest: virtualPath(root, VIRTUAL_MODULES.startManifest),\n injectedHeadScripts: virtualPath(root, VIRTUAL_MODULES.injectedHeadScripts),\n serverFnResolver: virtualPath(root, VIRTUAL_MODULES.serverFnResolver),\n pluginAdapters: virtualPath(root, VIRTUAL_MODULES.pluginAdapters),\n }\n\n // RSC virtual module paths (only defined when RSC is enabled)\n const rscPaths = opts.rscEnabled\n ? {\n rscRuntime: virtualPath(root, RSC_RUNTIME_VIRTUAL_ID),\n rscHmr: virtualPath(root, RSC_HMR_VIRTUAL_ID),\n rscBrowserDecode: virtualPath(root, RSC_BROWSER_DECODE_VIRTUAL_ID),\n rscSsrDecode: virtualPath(root, RSC_SSR_DECODE_VIRTUAL_ID),\n }\n : null\n\n // Track VirtualModulesPlugin instances per environment for dynamic updates\n const vmPlugins: Record<string, RspackVirtualModulesPlugin> = {}\n const readyVmPlugins: Record<string, boolean> = {}\n const pendingWrites = new Map<string, Map<string, string>>()\n\n let clientBuild: NormalizedClientBuild | undefined\n const lastResolverContentByEnvironment: Record<string, string | undefined> =\n {}\n const hasSeparateProviderEnvironment =\n !opts.rscEnabled &&\n opts.providerEnvName !== RSBUILD_ENVIRONMENT_NAMES.server\n\n function isProviderEnvironment(environmentName: string): boolean {\n return environmentName === opts.providerEnvName\n }\n\n function needsServerFnResolver(environmentName: string): boolean {\n return (\n environmentName === RSBUILD_ENVIRONMENT_NAMES.server ||\n (hasSeparateProviderEnvironment && isProviderEnvironment(environmentName))\n )\n }\n\n function generateResolverContent(environmentName: string): string {\n return generateServerFnResolverModule({\n serverFnsById: opts.serverFnsById,\n includeClientReferencedCheck: !isProviderEnvironment(environmentName),\n useStaticImports: Boolean(opts.rscEnabled && isDev),\n })\n }\n\n function writeResolverContent(environmentName: string, content: string) {\n if (\n !isDev ||\n content !== lastResolverContentByEnvironment[environmentName]\n ) {\n lastResolverContentByEnvironment[environmentName] = content\n tryWriteModule(environmentName, paths.serverFnResolver, content)\n }\n }\n\n function queuePendingWrite(\n environmentName: string,\n filePath: string,\n content: string,\n ) {\n let writes = pendingWrites.get(environmentName)\n if (!writes) {\n writes = new Map()\n pendingWrites.set(environmentName, writes)\n }\n writes.set(filePath, content)\n }\n\n function tryWriteModule(\n environmentName: string,\n filePath: string,\n content: string,\n ) {\n const vmPlugin = vmPlugins[environmentName]\n if (!vmPlugin || !readyVmPlugins[environmentName]) {\n queuePendingWrite(environmentName, filePath, content)\n return false\n }\n\n vmPlugin.writeModule(filePath, content)\n return true\n }\n\n function flushPendingWrites(environmentName: string) {\n if (!readyVmPlugins[environmentName]) {\n return\n }\n\n const writes = pendingWrites.get(environmentName)\n if (!writes?.size) {\n return\n }\n\n for (const [filePath, content] of writes) {\n if (!tryWriteModule(environmentName, filePath, content)) {\n return\n }\n writes.delete(filePath)\n }\n\n if (writes.size === 0) {\n pendingWrites.delete(environmentName)\n }\n }\n\n // NOTE: getConfig() is deferred — it must NOT be called until modifyRsbuildConfig\n // has resolved (which sets resolvedStartConfig.root). All access to resolvedStartConfig\n // happens inside modifyRspackConfig (which runs after modifyRsbuildConfig) or\n // inside update callbacks (which run even later during/after compilation).\n\n // Generate initial content for each virtual module per environment\n function getInitialContent(environmentName: string): Record<string, string> {\n // Safe to call getConfig() here — this runs inside modifyRspackConfig\n const { resolvedStartConfig } = opts.getConfig()\n const isServerEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.server\n const isClientEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.client\n const content: Record<string, string> = {}\n\n // Manifest — only meaningful for server env\n if (isServerEnv) {\n const devClientEntryUrl = opts.getDevClientEntryUrl(\n resolvedStartConfig.basePaths.publicBase,\n )\n content[paths.manifest] = isDev\n ? generateManifestModuleDev(devClientEntryUrl)\n : generateManifestModuleBuild(\n clientBuild,\n resolvedStartConfig.basePaths.publicBase,\n devClientEntryUrl,\n )\n } else {\n content[paths.manifest] = 'export default {}'\n }\n\n // Injected head scripts — only server\n content[paths.injectedHeadScripts] = generateInjectedHeadScripts()\n\n // Server fn resolver — SSR and provider environments\n if (needsServerFnResolver(environmentName)) {\n content[paths.serverFnResolver] = generateResolverContent(environmentName)\n } else {\n // Client doesn't need the resolver but needs a valid module\n content[paths.serverFnResolver] = 'export {}'\n }\n\n // Plugin adapters — both environments get environment-specific content\n content[paths.pluginAdapters] = generateSerializationAdaptersModule({\n adapters: opts.serializationAdapters,\n runtime:\n environmentName === RSBUILD_ENVIRONMENT_NAMES.client\n ? 'client'\n : 'server',\n })\n\n // --- RSC virtual modules ---\n if (rscPaths) {\n // virtual:tanstack-rsc-runtime\n // In the server env, this provides the RSC runtime for the RSC layer.\n // The virtual module content is the same regardless of layer since\n // rspack layers handle module isolation. The RSC entry imports this\n // and the react-server condition on the RSC layer resolves\n // react-server-dom-rspack/server correctly.\n if (isServerEnv) {\n // Server env gets the real RSC runtime (used by RSC layer)\n content[rscPaths.rscRuntime] = generateRscRuntimeModule(true)\n } else {\n // Client env gets stubs\n content[rscPaths.rscRuntime] = generateRscRuntimeModule(false)\n }\n\n // virtual:tanstack-rsc-hmr\n content[rscPaths.rscHmr] = generateRscHmrModule(isClientEnv, isDev)\n content[rscPaths.rscBrowserDecode] = isClientEnv\n ? `export * from '@tanstack/react-start/rsbuild/browser-decode'`\n : `export function createFromReadableStream() { throw new Error('RSC browser decode is only available in the client environment') }\nexport function createFromFetch() { throw new Error('RSC browser decode is only available in the client environment') }`\n content[rscPaths.rscSsrDecode] = isServerEnv\n ? `export * from '@tanstack/react-start/rsbuild/ssr-decode'`\n : `export function setOnClientReference() {}\nexport function createFromReadableStream() { throw new Error('RSC SSR decode is only available in the server environment') }`\n }\n\n return content\n }\n\n // Build a map from virtual module IDs to their virtual file paths.\n // Scheme-like IDs are rewritten with NormalModuleReplacementPlugin because\n // rspack validates request schemes before normal alias resolution.\n const aliasMap: Record<string, string> = {\n [VIRTUAL_MODULES.startManifest]: paths.manifest,\n [VIRTUAL_MODULES.injectedHeadScripts]: paths.injectedHeadScripts,\n [VIRTUAL_MODULES.serverFnResolver]: paths.serverFnResolver,\n [VIRTUAL_MODULES.pluginAdapters]: paths.pluginAdapters,\n }\n\n // Add RSC virtual module aliases\n if (rscPaths) {\n aliasMap[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime\n aliasMap[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr\n aliasMap[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode\n aliasMap[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode\n }\n\n // Register VirtualModulesPlugin per environment via modifyRspackConfig\n api.modifyRspackConfig((config, utils) => {\n const envName = utils.environment.name\n const initialContent = getInitialContent(envName)\n\n // Create VirtualModulesPlugin instance\n const VMP = utils.rspack.experiments.VirtualModulesPlugin\n const vmPlugin = new VMP(initialContent)\n vmPlugins[envName] = vmPlugin\n readyVmPlugins[envName] = false\n config.plugins.push(vmPlugin)\n config.plugins.push({\n apply(compiler: {\n hooks: {\n thisCompilation: { tap: (name: string, handler: () => void) => void }\n }\n }) {\n compiler.hooks.thisCompilation.tap(\n 'TanStackStartFlushPendingVirtualModules',\n () => {\n readyVmPlugins[envName] = true\n flushPendingWrites(envName)\n },\n )\n },\n })\n\n // Rewrite scheme-like IDs to the VirtualModulesPlugin-backed file paths.\n for (const [moduleId, virtualFilePath] of Object.entries(aliasMap)) {\n const escaped = moduleId.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n const NMR = utils.rspack.NormalModuleReplacementPlugin\n config.plugins.push(new NMR(new RegExp(`^${escaped}$`), virtualFilePath))\n }\n\n const resolve = config.resolve\n const resolveAlias = (resolve.alias ??= {}) as Record<string, string>\n resolveAlias[VIRTUAL_MODULES.serverFnResolver] = paths.serverFnResolver\n resolveAlias[VIRTUAL_MODULES.pluginAdapters] = paths.pluginAdapters\n\n // Add RSC-specific resolve aliases\n if (rscPaths) {\n resolveAlias[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime\n resolveAlias[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr\n resolveAlias[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode\n resolveAlias[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode\n }\n })\n\n return {\n serverFnResolverPath: paths.serverFnResolver,\n manifestPath: paths.manifest,\n vmPlugins,\n\n generateCurrentResolverContent(forProvider?: boolean): string {\n return generateResolverContent(\n forProvider ? opts.providerEnvName : RSBUILD_ENVIRONMENT_NAMES.server,\n )\n },\n\n generateManifestContent(newClientBuild: NormalizedClientBuild): string {\n const { resolvedStartConfig } = opts.getConfig()\n const devClientEntryUrl = opts.getDevClientEntryUrl(\n resolvedStartConfig.basePaths.publicBase,\n )\n return generateManifestModuleBuild(\n newClientBuild,\n resolvedStartConfig.basePaths.publicBase,\n devClientEntryUrl,\n )\n },\n\n generateManifestValueLiteral(\n newClientBuild: NormalizedClientBuild,\n ): string {\n const { resolvedStartConfig } = opts.getConfig()\n return serializeStartManifestData(\n newClientBuild,\n resolvedStartConfig.basePaths.publicBase,\n )\n },\n\n updateManifest(newClientBuild: NormalizedClientBuild) {\n clientBuild = newClientBuild\n // Safe to call getConfig() here — runs after client build\n const { resolvedStartConfig } = opts.getConfig()\n if (isDev) {\n ;(\n globalThis as typeof globalThis & {\n [DEV_START_MANIFEST_GLOBAL]?: ReturnType<typeof buildStartManifest>\n }\n )[DEV_START_MANIFEST_GLOBAL] = buildStartManifestData(\n clientBuild,\n resolvedStartConfig.basePaths.publicBase,\n )\n }\n },\n\n updateServerFnResolver() {\n for (const environmentName of new Set([\n RSBUILD_ENVIRONMENT_NAMES.server,\n ...(hasSeparateProviderEnvironment ? [opts.providerEnvName] : []),\n ])) {\n if (!needsServerFnResolver(environmentName)) {\n continue\n }\n\n writeResolverContent(\n environmentName,\n generateResolverContent(environmentName),\n )\n }\n },\n\n tryUpdateServerFnResolver(content: string) {\n lastResolverContentByEnvironment[RSBUILD_ENVIRONMENT_NAMES.server] =\n content\n tryWriteModule(\n RSBUILD_ENVIRONMENT_NAMES.server,\n paths.serverFnResolver,\n content,\n )\n },\n\n getVirtualPath(moduleId: string): string {\n return virtualPath(root, moduleId)\n },\n }\n}\n"],"mappings":";;;;;;AAsBA,IAAM,yBAAyB;AAC/B,IAAM,qBAAqB;AAC3B,IAAM,gCAAgC;AACtC,IAAM,4BAA4B;AAClC,IAAa,6BAA6B;AAC1C,IAAM,4BAA4B;;;;;AAKlC,SAAS,YAAY,MAAc,UAA0B;AAI3D,QAAO,GAAG,KAAK,yBADG,SAAS,QAAQ,SAAS,IAAI,CACE;;AA+BpD,SAAS,0BAA0B,mBAAmC;AACpE,QAAO;;kBAES,kBAAkB;;mDAEe,KAAK,UAAU,0BAA0B,CAAC;;AAG7F,SAAS,uBACP,aACA,YACA;CACA,MAAM,kBAAkB,WAAW;AACnC,QAAO,mBAAmB;EACxB;EACA;EACA,UAAU;EACX,CAAC;;AAGJ,SAAS,2BACP,aACA,YACQ;AACR,QAAO,KAAK,UAAU,uBAAuB,aAAa,WAAW,CAAC;;AAGxE,SAAS,4BACP,aACA,YACA,oBACQ;AACR,KAAI,CAAC,YACH,QAAO,gCAAgC,KAAK,UAAU,2BAA2B,CAAC;;AAIpF,QAAO,0CAA0C,2BAA2B,aAAa,WAAW,CAAC;;AAOvG,SAAS,4BAA4B,SAA0B;AAC7D,QAAO,sCAAsC,UAAU,KAAK,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QACD;;EAGH,eAAe,UAA0B;AACvC,UAAO,YAAY,MAAM,SAAS;;EAErC"}
|
package/dist/esm/schema.d.ts
CHANGED
|
@@ -142,12 +142,12 @@ export declare function parseStartConfig(opts: z.input<typeof tanstackStartOptio
|
|
|
142
142
|
enableRouteGeneration?: boolean | undefined;
|
|
143
143
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
144
144
|
plugin?: {
|
|
145
|
-
hmr?: {
|
|
146
|
-
hotExpression?: string | undefined;
|
|
147
|
-
} | undefined;
|
|
148
145
|
vite?: {
|
|
149
146
|
environmentName?: string | undefined;
|
|
150
147
|
} | undefined;
|
|
148
|
+
hmr?: {
|
|
149
|
+
style?: "vite" | "webpack" | undefined;
|
|
150
|
+
} | undefined;
|
|
151
151
|
} | undefined;
|
|
152
152
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
153
153
|
routeFilePrefix?: string | undefined;
|
|
@@ -1060,11 +1060,11 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
1060
1060
|
codeSplittingOptions: z.ZodOptional<z.ZodOptional<z.ZodType<import('@tanstack/router-plugin').CodeSplittingOptions, z.ZodTypeDef, import('@tanstack/router-plugin').CodeSplittingOptions>>>;
|
|
1061
1061
|
plugin: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1062
1062
|
hmr: z.ZodOptional<z.ZodObject<{
|
|
1063
|
-
|
|
1063
|
+
style: z.ZodOptional<z.ZodEnum<["vite", "webpack"]>>;
|
|
1064
1064
|
}, "strip", z.ZodTypeAny, {
|
|
1065
|
-
|
|
1065
|
+
style?: "vite" | "webpack" | undefined;
|
|
1066
1066
|
}, {
|
|
1067
|
-
|
|
1067
|
+
style?: "vite" | "webpack" | undefined;
|
|
1068
1068
|
}>>;
|
|
1069
1069
|
vite: z.ZodOptional<z.ZodObject<{
|
|
1070
1070
|
environmentName: z.ZodOptional<z.ZodString>;
|
|
@@ -1074,19 +1074,19 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
1074
1074
|
environmentName?: string | undefined;
|
|
1075
1075
|
}>>;
|
|
1076
1076
|
}, "strip", z.ZodTypeAny, {
|
|
1077
|
-
hmr?: {
|
|
1078
|
-
hotExpression?: string | undefined;
|
|
1079
|
-
} | undefined;
|
|
1080
1077
|
vite?: {
|
|
1081
1078
|
environmentName?: string | undefined;
|
|
1082
1079
|
} | undefined;
|
|
1083
|
-
}, {
|
|
1084
1080
|
hmr?: {
|
|
1085
|
-
|
|
1081
|
+
style?: "vite" | "webpack" | undefined;
|
|
1086
1082
|
} | undefined;
|
|
1083
|
+
}, {
|
|
1087
1084
|
vite?: {
|
|
1088
1085
|
environmentName?: string | undefined;
|
|
1089
1086
|
} | undefined;
|
|
1087
|
+
hmr?: {
|
|
1088
|
+
style?: "vite" | "webpack" | undefined;
|
|
1089
|
+
} | undefined;
|
|
1090
1090
|
}>>>;
|
|
1091
1091
|
}, "strip", z.ZodTypeAny, {
|
|
1092
1092
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
@@ -1125,12 +1125,12 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
1125
1125
|
enableRouteGeneration?: boolean | undefined;
|
|
1126
1126
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
1127
1127
|
plugin?: {
|
|
1128
|
-
hmr?: {
|
|
1129
|
-
hotExpression?: string | undefined;
|
|
1130
|
-
} | undefined;
|
|
1131
1128
|
vite?: {
|
|
1132
1129
|
environmentName?: string | undefined;
|
|
1133
1130
|
} | undefined;
|
|
1131
|
+
hmr?: {
|
|
1132
|
+
style?: "vite" | "webpack" | undefined;
|
|
1133
|
+
} | undefined;
|
|
1134
1134
|
} | undefined;
|
|
1135
1135
|
}, {
|
|
1136
1136
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
@@ -1169,12 +1169,12 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
1169
1169
|
enableRouteGeneration?: boolean | undefined;
|
|
1170
1170
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
1171
1171
|
plugin?: {
|
|
1172
|
-
hmr?: {
|
|
1173
|
-
hotExpression?: string | undefined;
|
|
1174
|
-
} | undefined;
|
|
1175
1172
|
vite?: {
|
|
1176
1173
|
environmentName?: string | undefined;
|
|
1177
1174
|
} | undefined;
|
|
1175
|
+
hmr?: {
|
|
1176
|
+
style?: "vite" | "webpack" | undefined;
|
|
1177
|
+
} | undefined;
|
|
1178
1178
|
} | undefined;
|
|
1179
1179
|
}>>>>>>;
|
|
1180
1180
|
client: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
@@ -3420,12 +3420,12 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
3420
3420
|
enableRouteGeneration?: boolean | undefined;
|
|
3421
3421
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
3422
3422
|
plugin?: {
|
|
3423
|
-
hmr?: {
|
|
3424
|
-
hotExpression?: string | undefined;
|
|
3425
|
-
} | undefined;
|
|
3426
3423
|
vite?: {
|
|
3427
3424
|
environmentName?: string | undefined;
|
|
3428
3425
|
} | undefined;
|
|
3426
|
+
hmr?: {
|
|
3427
|
+
style?: "vite" | "webpack" | undefined;
|
|
3428
|
+
} | undefined;
|
|
3429
3429
|
} | undefined;
|
|
3430
3430
|
};
|
|
3431
3431
|
serverFns: {
|
|
@@ -3745,12 +3745,12 @@ export declare const tanstackStartOptionsObjectSchema: z.ZodObject<{
|
|
|
3745
3745
|
enableRouteGeneration?: boolean | undefined;
|
|
3746
3746
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
3747
3747
|
plugin?: {
|
|
3748
|
-
hmr?: {
|
|
3749
|
-
hotExpression?: string | undefined;
|
|
3750
|
-
} | undefined;
|
|
3751
3748
|
vite?: {
|
|
3752
3749
|
environmentName?: string | undefined;
|
|
3753
3750
|
} | undefined;
|
|
3751
|
+
hmr?: {
|
|
3752
|
+
style?: "vite" | "webpack" | undefined;
|
|
3753
|
+
} | undefined;
|
|
3754
3754
|
} | undefined;
|
|
3755
3755
|
}) | undefined;
|
|
3756
3756
|
serverFns?: {
|
|
@@ -4094,11 +4094,11 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
4094
4094
|
codeSplittingOptions: z.ZodOptional<z.ZodOptional<z.ZodType<import('@tanstack/router-plugin').CodeSplittingOptions, z.ZodTypeDef, import('@tanstack/router-plugin').CodeSplittingOptions>>>;
|
|
4095
4095
|
plugin: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
4096
4096
|
hmr: z.ZodOptional<z.ZodObject<{
|
|
4097
|
-
|
|
4097
|
+
style: z.ZodOptional<z.ZodEnum<["vite", "webpack"]>>;
|
|
4098
4098
|
}, "strip", z.ZodTypeAny, {
|
|
4099
|
-
|
|
4099
|
+
style?: "vite" | "webpack" | undefined;
|
|
4100
4100
|
}, {
|
|
4101
|
-
|
|
4101
|
+
style?: "vite" | "webpack" | undefined;
|
|
4102
4102
|
}>>;
|
|
4103
4103
|
vite: z.ZodOptional<z.ZodObject<{
|
|
4104
4104
|
environmentName: z.ZodOptional<z.ZodString>;
|
|
@@ -4108,19 +4108,19 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
4108
4108
|
environmentName?: string | undefined;
|
|
4109
4109
|
}>>;
|
|
4110
4110
|
}, "strip", z.ZodTypeAny, {
|
|
4111
|
-
hmr?: {
|
|
4112
|
-
hotExpression?: string | undefined;
|
|
4113
|
-
} | undefined;
|
|
4114
4111
|
vite?: {
|
|
4115
4112
|
environmentName?: string | undefined;
|
|
4116
4113
|
} | undefined;
|
|
4117
|
-
}, {
|
|
4118
4114
|
hmr?: {
|
|
4119
|
-
|
|
4115
|
+
style?: "vite" | "webpack" | undefined;
|
|
4120
4116
|
} | undefined;
|
|
4117
|
+
}, {
|
|
4121
4118
|
vite?: {
|
|
4122
4119
|
environmentName?: string | undefined;
|
|
4123
4120
|
} | undefined;
|
|
4121
|
+
hmr?: {
|
|
4122
|
+
style?: "vite" | "webpack" | undefined;
|
|
4123
|
+
} | undefined;
|
|
4124
4124
|
}>>>;
|
|
4125
4125
|
}, "strip", z.ZodTypeAny, {
|
|
4126
4126
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
@@ -4159,12 +4159,12 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
4159
4159
|
enableRouteGeneration?: boolean | undefined;
|
|
4160
4160
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
4161
4161
|
plugin?: {
|
|
4162
|
-
hmr?: {
|
|
4163
|
-
hotExpression?: string | undefined;
|
|
4164
|
-
} | undefined;
|
|
4165
4162
|
vite?: {
|
|
4166
4163
|
environmentName?: string | undefined;
|
|
4167
4164
|
} | undefined;
|
|
4165
|
+
hmr?: {
|
|
4166
|
+
style?: "vite" | "webpack" | undefined;
|
|
4167
|
+
} | undefined;
|
|
4168
4168
|
} | undefined;
|
|
4169
4169
|
}, {
|
|
4170
4170
|
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
@@ -4203,12 +4203,12 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
4203
4203
|
enableRouteGeneration?: boolean | undefined;
|
|
4204
4204
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
4205
4205
|
plugin?: {
|
|
4206
|
-
hmr?: {
|
|
4207
|
-
hotExpression?: string | undefined;
|
|
4208
|
-
} | undefined;
|
|
4209
4206
|
vite?: {
|
|
4210
4207
|
environmentName?: string | undefined;
|
|
4211
4208
|
} | undefined;
|
|
4209
|
+
hmr?: {
|
|
4210
|
+
style?: "vite" | "webpack" | undefined;
|
|
4211
|
+
} | undefined;
|
|
4212
4212
|
} | undefined;
|
|
4213
4213
|
}>>>>>>;
|
|
4214
4214
|
client: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
@@ -6454,12 +6454,12 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
6454
6454
|
enableRouteGeneration?: boolean | undefined;
|
|
6455
6455
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
6456
6456
|
plugin?: {
|
|
6457
|
-
hmr?: {
|
|
6458
|
-
hotExpression?: string | undefined;
|
|
6459
|
-
} | undefined;
|
|
6460
6457
|
vite?: {
|
|
6461
6458
|
environmentName?: string | undefined;
|
|
6462
6459
|
} | undefined;
|
|
6460
|
+
hmr?: {
|
|
6461
|
+
style?: "vite" | "webpack" | undefined;
|
|
6462
|
+
} | undefined;
|
|
6463
6463
|
} | undefined;
|
|
6464
6464
|
};
|
|
6465
6465
|
serverFns: {
|
|
@@ -6779,12 +6779,12 @@ export declare const tanstackStartOptionsSchema: z.ZodDefault<z.ZodOptional<z.Zo
|
|
|
6779
6779
|
enableRouteGeneration?: boolean | undefined;
|
|
6780
6780
|
codeSplittingOptions?: import('@tanstack/router-plugin').CodeSplittingOptions | undefined;
|
|
6781
6781
|
plugin?: {
|
|
6782
|
-
hmr?: {
|
|
6783
|
-
hotExpression?: string | undefined;
|
|
6784
|
-
} | undefined;
|
|
6785
6782
|
vite?: {
|
|
6786
6783
|
environmentName?: string | undefined;
|
|
6787
6784
|
} | undefined;
|
|
6785
|
+
hmr?: {
|
|
6786
|
+
style?: "vite" | "webpack" | undefined;
|
|
6787
|
+
} | undefined;
|
|
6788
6788
|
} | undefined;
|
|
6789
6789
|
}) | undefined;
|
|
6790
6790
|
serverFns?: {
|
|
@@ -93,7 +93,6 @@ export declare class StartCompiler {
|
|
|
93
93
|
private init;
|
|
94
94
|
/**
|
|
95
95
|
* Extracts bindings and exports from an already-parsed AST.
|
|
96
|
-
* This is the core logic shared by ingestModule and ingestModuleFromAst.
|
|
97
96
|
*/
|
|
98
97
|
private extractModuleInfo;
|
|
99
98
|
ingestModule({ code, id }: {
|
|
@@ -104,6 +103,7 @@ export declare class StartCompiler {
|
|
|
104
103
|
ast: import('@tanstack/router-utils').ParseAstResult;
|
|
105
104
|
};
|
|
106
105
|
invalidateModule(id: string): boolean;
|
|
106
|
+
getTransitiveImporters(id: string): Promise<Set<string>>;
|
|
107
107
|
compile({ code, id, detectedKinds, }: {
|
|
108
108
|
code: string;
|
|
109
109
|
id: string;
|