@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 @@
|
|
|
1
|
+
{"version":3,"file":"import-protection.js","names":[],"sources":["../../../src/rsbuild/import-protection.ts"],"sourcesContent":["import { extname, resolve as resolvePath } from 'node:path'\n\nimport {\n getDefaultImportProtectionRules,\n getMarkerSpecifiers,\n} from '../import-protection/defaults'\nimport { normalizePath } from '../utils'\nimport { ExtensionlessAbsoluteIdResolver } from '../import-protection/extensionlessAbsoluteIdResolver'\nimport { compileMatchers, matchesAny } from '../import-protection/matchers'\nimport {\n getImportProtectionEnvType,\n getImportProtectionRelativePath,\n getImportProtectionRulesForEnvironment,\n shouldCheckImportProtectionImporter,\n} from '../import-protection/adapterUtils'\nimport {\n findOriginalUnsafeUsagePosFromResult,\n getImportSources,\n getMockExportNamesBySource,\n getNamedExports,\n} from '../import-protection/analysis'\nimport { rewriteDeniedImports } from '../import-protection/rewrite'\nimport {\n ImportLocCache,\n addTraceImportLocations,\n buildCodeSnippet,\n buildLineIndex,\n createImportSpecifierLocationIndex,\n findImportStatementLocationFromTransformed,\n findOriginalUsageLocation,\n findPostCompileUsageLocation,\n getOrCreateOriginalTransformResult,\n indexToLineColumn,\n normalizeSourceMap,\n pickOriginalCodeFromSourcesContent,\n} from '../import-protection/sourceLocation'\nimport {\n ImportGraph,\n buildTrace,\n formatViolation,\n} from '../import-protection/trace'\nimport {\n generateDevSelfDenialModule,\n generateSelfContainedMockModule,\n loadMockEdgeModule,\n loadMockRuntimeModule,\n loadSilentMockModule,\n} from '../import-protection/virtualModules'\nimport {\n buildResolutionCandidates,\n buildSourceCandidates,\n canonicalizeResolvedId,\n checkFileDenial,\n clearNormalizeFilePathCache,\n dedupePatterns,\n dedupeViolationKey,\n isFileExcluded,\n normalizeFilePath,\n} from '../import-protection/utils'\n\nimport type {\n ImportProtectionBehavior,\n ImportProtectionOptions,\n} from '../schema'\nimport type { CompiledMatcher } from '../import-protection/matchers'\nimport type {\n SourceMapLike,\n TransformResult,\n TransformResultProvider,\n} from '../import-protection/sourceLocation'\nimport type { Loc, TraceStep, ViolationInfo } from '../import-protection/trace'\nimport type { CompileStartFrameworkOptions, GetConfigFn } from '../types'\nimport type {\n RsbuildPluginAPI,\n Rspack,\n rspack as rspackNamespaceType,\n} from '@rsbuild/core'\n\ntype RspackNamespace = typeof rspackNamespaceType\ntype RspackVirtualModulesPlugin = InstanceType<\n RspackNamespace['experiments']['VirtualModulesPlugin']\n>\ntype ProcessAssetsContext = Parameters<\n Parameters<RsbuildPluginAPI['processAssets']>[1]\n>[0]\ntype TransformContext = Parameters<\n Parameters<RsbuildPluginAPI['transform']>[1]\n>[0]\ntype RspackCompilation = Rspack.Compilation\ntype RspackModule = Rspack.Module\ntype RspackModuleGraphConnection = {\n module?: RspackModule | null\n dependency?: unknown\n getActiveState?: (runtime: string | Array<string> | undefined) => unknown\n}\ntype OriginalCodeLoader = (file: string) => Promise<string | undefined>\nconst importSpecifierLocationIndex = createImportSpecifierLocationIndex()\n\ninterface EnvRules {\n specifiers: Array<CompiledMatcher>\n files: Array<CompiledMatcher>\n excludeFiles: Array<CompiledMatcher>\n}\n\ninterface PluginConfig {\n enabled: boolean\n root: string\n command: 'build' | 'serve'\n srcDirectory: string\n framework: CompileStartFrameworkOptions\n effectiveBehavior: ImportProtectionBehavior\n mockAccess: 'error' | 'warn' | 'off'\n logMode: 'once' | 'always'\n maxTraceDepth: number\n compiledRules: {\n client: EnvRules\n server: EnvRules\n }\n includeMatchers: Array<CompiledMatcher>\n excludeMatchers: Array<CompiledMatcher>\n ignoreImporterMatchers: Array<CompiledMatcher>\n markerSpecifiers: {\n serverOnly: Set<string>\n clientOnly: Set<string>\n }\n envTypeMap: Map<string, 'client' | 'server'>\n onViolation?: (\n info: ViolationInfo,\n ) => boolean | void | Promise<boolean | void>\n}\n\ninterface EnvRuntimeState {\n resolveCache: Map<string, string | null>\n seenViolations: Set<string>\n buildTransformResults: Map<string, TransformResult>\n deferredFileViolations: Array<DeferredFileViolation>\n deferredFileViolationKeys: Set<string>\n}\n\ninterface DeferredFileViolation {\n importer: string\n specifier: string\n resolved: string\n relativeResolved: string\n pattern: string | RegExp\n useOriginalLocation: boolean\n}\n\ninterface SharedState {\n root: string\n virtualModules: Map<string, string>\n vmPlugins: Record<string, RspackVirtualModulesPlugin>\n readyVmPlugins: Record<string, boolean>\n inputFileSystems: Record<string, Rspack.Compiler['inputFileSystem']>\n pendingWrites: Map<string, Map<string, string>>\n}\n\ninterface CompilationEdge {\n importer: string\n specifier?: string\n resolved: string\n}\n\ninterface MockEdgePayload {\n exports: Array<string>\n runtimeId: string\n violation: {\n env: string\n envType: 'client' | 'server'\n importer: string\n specifier: string\n resolved?: string\n patternText: string\n }\n}\n\nconst IMPORT_PROTECTION_VIRTUAL_DIR = 'node_modules/.virtual/import-protection'\nconst MOCK_EDGE_FILE_PREFIX = 'mock-edge-'\nconst MOCK_RUNTIME_FILE_PREFIX = 'mock-runtime-'\nconst MOCK_SILENT_FILE = 'mock-silent.mjs'\n\nfunction toBase64Url(input: unknown): string {\n return Buffer.from(JSON.stringify(input), 'utf8').toString('base64url')\n}\n\nfunction fromBase64Url<T>(input: string): T {\n return JSON.parse(Buffer.from(input, 'base64url').toString('utf8')) as T\n}\n\nfunction getRulesForEnvironment(\n config: PluginConfig,\n envName: string,\n): EnvRules {\n return getImportProtectionRulesForEnvironment(config, envName) as EnvRules\n}\n\nfunction serializePattern(pattern: string | RegExp): string {\n return typeof pattern === 'string' ? pattern : pattern.toString()\n}\n\nfunction dedupeKey(info: ViolationInfo): string {\n return dedupeViolationKey(info)\n}\n\nfunction getOrCreateEnvState(\n envStates: Map<string, EnvRuntimeState>,\n envName: string,\n): EnvRuntimeState {\n let env = envStates.get(envName)\n\n if (!env) {\n env = {\n resolveCache: new Map(),\n seenViolations: new Set(),\n buildTransformResults: new Map(),\n deferredFileViolations: [],\n deferredFileViolationKeys: new Set(),\n }\n envStates.set(envName, env)\n }\n\n return env\n}\n\nfunction getVirtualModulePath(\n root: string,\n envName: string,\n filename: string,\n): string {\n return normalizePath(\n resolvePath(root, IMPORT_PROTECTION_VIRTUAL_DIR, envName, filename),\n )\n}\n\nfunction queuePendingWrite(\n shared: SharedState,\n envName: string,\n filePath: string,\n code: string,\n): void {\n let writes = shared.pendingWrites.get(envName)\n if (!writes) {\n writes = new Map()\n shared.pendingWrites.set(envName, writes)\n }\n\n writes.set(filePath, code)\n}\n\nfunction tryWriteVirtualModule(\n shared: SharedState,\n envName: string,\n filePath: string,\n code: string,\n): string {\n const current = shared.virtualModules.get(filePath)\n if (current === code) {\n return filePath\n }\n\n shared.virtualModules.set(filePath, code)\n\n const vmPlugin = shared.vmPlugins[envName]\n if (!vmPlugin || !shared.readyVmPlugins[envName]) {\n queuePendingWrite(shared, envName, filePath, code)\n return filePath\n }\n\n vmPlugin.writeModule(filePath, code)\n return filePath\n}\n\nfunction flushPendingWrites(shared: SharedState, envName: string): void {\n const writes = shared.pendingWrites.get(envName)\n if (!writes?.size || !shared.readyVmPlugins[envName]) {\n return\n }\n\n for (const [filePath, code] of writes) {\n shared.vmPlugins[envName]?.writeModule(filePath, code)\n writes.delete(filePath)\n }\n\n if (writes.size === 0) {\n shared.pendingWrites.delete(envName)\n }\n}\n\nfunction ensureSilentMockModule(shared: SharedState, envName: string): string {\n return tryWriteVirtualModule(\n shared,\n envName,\n getVirtualModulePath(shared.root, envName, MOCK_SILENT_FILE),\n loadSilentMockModule().code,\n )\n}\n\nfunction ensureRuntimeMockModule(opts: {\n shared: SharedState\n envName: string\n mode: 'error' | 'warn' | 'off'\n env: string\n importer: string\n specifier: string\n}): string {\n const encoded = toBase64Url({\n mode: opts.mode,\n env: opts.env,\n importer: opts.importer,\n specifier: opts.specifier,\n trace: [],\n })\n\n return tryWriteVirtualModule(\n opts.shared,\n opts.envName,\n getVirtualModulePath(\n opts.shared.root,\n opts.envName,\n `${MOCK_RUNTIME_FILE_PREFIX}${encoded}.mjs`,\n ),\n loadMockRuntimeModule(encoded).code,\n )\n}\n\nfunction ensureMockEdgeModule(opts: {\n shared: SharedState\n envName: string\n payload: MockEdgePayload\n}): string {\n const encoded = toBase64Url(opts.payload)\n\n return tryWriteVirtualModule(\n opts.shared,\n opts.envName,\n getVirtualModulePath(\n opts.shared.root,\n opts.envName,\n `${MOCK_EDGE_FILE_PREFIX}${encoded}.mjs`,\n ),\n loadMockEdgeModule(encoded).code,\n )\n}\n\nfunction getMockEdgePayloadFromFile(\n filePath: string,\n): MockEdgePayload | undefined {\n const match = /(?:^|[\\\\/])mock-edge-([^/\\\\]+)\\.mjs$/.exec(filePath)\n if (!match) {\n return undefined\n }\n\n try {\n return fromBase64Url<MockEdgePayload>(match[1]!)\n } catch {\n return undefined\n }\n}\n\nasync function loadOriginalCode(\n cache: Map<string, Promise<string | undefined>>,\n file: string,\n loader: OriginalCodeLoader,\n): Promise<string | undefined> {\n let result = cache.get(file)\n if (!result) {\n result = loader(file)\n cache.set(file, result)\n }\n\n return result\n}\n\nasync function loadOriginalCodeFromInputFileSystem(\n inputFileSystem: NonNullable<RspackCompilation['inputFileSystem']>,\n file: string,\n): Promise<string | undefined> {\n return new Promise((resolve) => {\n inputFileSystem.readFile(file, (error, data) => {\n if (error || data == null) {\n resolve(undefined)\n return\n }\n\n resolve(typeof data === 'string' ? data : data.toString('utf8'))\n })\n })\n}\n\nasync function resolveAgainstImporter(opts: {\n envState: EnvRuntimeState\n config: PluginConfig\n ctx: TransformContext\n importerId: string\n source: string\n extensionlessResolver: ExtensionlessAbsoluteIdResolver\n}): Promise<string | null> {\n const normalizedImporter = normalizeFilePath(opts.importerId)\n const cacheKey = `${normalizedImporter}:${opts.source}`\n\n if (opts.envState.resolveCache.has(cacheKey)) {\n return opts.envState.resolveCache.get(cacheKey) ?? null\n }\n\n const importerDir =\n opts.ctx.context ?? opts.importerId.replace(/[/\\\\][^/\\\\]*$/, '')\n\n const resolved = await new Promise<string | null>((resolve, reject) => {\n opts.ctx.resolve(importerDir, opts.source, (error, result) => {\n if (error) {\n reject(error)\n return\n }\n\n resolve(typeof result === 'string' ? result : null)\n })\n }).catch(() => null)\n\n if (!resolved) {\n opts.envState.resolveCache.set(cacheKey, null)\n return null\n }\n\n const canonical = canonicalizeResolvedId(\n resolved,\n opts.config.root,\n (value) => opts.extensionlessResolver.resolve(value),\n )\n\n opts.envState.resolveCache.set(cacheKey, canonical)\n return canonical\n}\n\nfunction getModuleResource(module: RspackModule): string | undefined {\n const candidate = module as RspackModule & {\n nameForCondition?: () => string | undefined\n resourceResolveData?: { resource?: string }\n resource?: string\n userRequest?: string\n request?: string\n }\n\n return (\n candidate.nameForCondition() ??\n candidate.resourceResolveData?.resource ??\n candidate.resource ??\n candidate.userRequest ??\n candidate.request\n )\n}\n\nfunction getModuleFile(module: RspackModule): string {\n return normalizeFilePath(getModuleResource(module) ?? module.identifier())\n}\n\nconst IMPORT_PROTECTION_PARSEABLE_EXTENSIONS = new Set([\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n])\n\nfunction isImportProtectionSourceFile(file: string | undefined): boolean {\n if (!file) {\n return false\n }\n\n const extension = extname(normalizeFilePath(file))\n return (\n extension.length > 0 &&\n IMPORT_PROTECTION_PARSEABLE_EXTENSIONS.has(extension)\n )\n}\n\nfunction isImportProtectionSourceModule(module: RspackModule): boolean {\n return isImportProtectionSourceFile(getModuleResource(module))\n}\n\nfunction addTransformResult(\n cache: Map<string, TransformResult>,\n key: string,\n result: TransformResult,\n): void {\n cache.set(normalizePath(key), result)\n cache.set(normalizeFilePath(key), result)\n}\n\nfunction hasTransformResult(\n cache: Map<string, TransformResult>,\n key: string,\n): boolean {\n return cache.has(normalizePath(key)) || cache.has(normalizeFilePath(key))\n}\n\nfunction deferFileViolation(\n envState: EnvRuntimeState,\n violation: DeferredFileViolation,\n): void {\n const key = `${violation.importer}:${violation.specifier}:${violation.resolved}:${String(violation.pattern)}`\n if (envState.deferredFileViolationKeys.has(key)) {\n return\n }\n\n envState.deferredFileViolationKeys.add(key)\n envState.deferredFileViolations.push(violation)\n}\n\nfunction hasOriginalUnsafeUsage(\n result: TransformResult | undefined,\n source: string,\n envType: 'client' | 'server',\n): boolean {\n if (!result) {\n return false\n }\n\n const originalResult = getOrCreateOriginalTransformResult(result)\n if (!originalResult) {\n return false\n }\n\n return !!findOriginalUnsafeUsagePosFromResult(originalResult, source, envType)\n}\n\nasync function buildTransformResultProvider(opts: {\n modules: Array<RspackModule>\n root: string\n loadOriginalCode: OriginalCodeLoader\n preloaded?: Map<string, TransformResult>\n}): Promise<TransformResultProvider> {\n const cache = new Map<string, TransformResult>()\n\n if (opts.preloaded) {\n for (const [key, result] of opts.preloaded) {\n cache.set(key, result)\n }\n }\n\n for (const module of opts.modules) {\n const source = module.originalSource()\n if (!source) continue\n\n const sourceAndMap = source.sourceAndMap()\n const code = String(sourceAndMap.source)\n const map = normalizeSourceMap(sourceAndMap.map as SourceMapLike | null)\n const file = getModuleFile(module)\n const resource = getModuleResource(module)\n\n const originalCode = map?.sourcesContent\n ? (pickOriginalCodeFromSourcesContent(map, resource ?? file, opts.root) ??\n (resource ? await opts.loadOriginalCode(resource) : undefined))\n : resource\n ? await opts.loadOriginalCode(resource)\n : undefined\n\n const result: TransformResult = {\n code,\n map,\n originalCode,\n lineIndex: buildLineIndex(code),\n }\n\n if (!hasTransformResult(cache, file)) {\n addTransformResult(cache, file, result)\n }\n\n if (resource && !hasTransformResult(cache, resource)) {\n addTransformResult(cache, resource, result)\n }\n }\n\n return {\n getTransformResult(id: string) {\n return cache.get(normalizePath(id)) ?? cache.get(normalizeFilePath(id))\n },\n }\n}\n\nfunction getConnectionRequest(dependency: unknown): string | undefined {\n const candidate = dependency as { request?: unknown }\n return typeof candidate.request === 'string' ? candidate.request : undefined\n}\n\nfunction addEntryModulesToGraph(opts: {\n compilation: RspackCompilation\n graph: ImportGraph\n}): void {\n for (const entry of opts.compilation.entries.values()) {\n for (const dependency of entry.dependencies) {\n const connection = opts.compilation.moduleGraph.getConnection(dependency)\n const module = connection?.module\n if (!module) continue\n opts.graph.addEntry(getModuleFile(module))\n }\n }\n}\n\nfunction buildCompilationGraph(opts: {\n compilation: RspackCompilation\n modules: Array<RspackModule>\n}): { graph: ImportGraph; edges: Array<CompilationEdge> } {\n const graph = new ImportGraph()\n const edges: Array<CompilationEdge> = []\n\n addEntryModulesToGraph({\n compilation: opts.compilation,\n graph,\n })\n\n for (const module of opts.modules) {\n const importer = getModuleFile(module)\n const connections =\n opts.compilation.moduleGraph.getOutgoingConnectionsInOrder(module)\n\n for (const connection of connections) {\n if (!connection.module) continue\n if (!isActiveConnection(connection)) continue\n\n const resolved = getModuleFile(connection.module)\n const specifier = getConnectionRequest(connection.dependency)\n graph.addEdge(resolved, importer, specifier)\n edges.push({ importer, specifier, resolved })\n }\n }\n\n return { graph, edges }\n}\n\nfunction isActiveConnection(connection: RspackModuleGraphConnection): boolean {\n if (typeof connection.getActiveState !== 'function') {\n return true\n }\n\n return connection.getActiveState(undefined) === true\n}\n\nfunction findImportLocationInOriginalCode(\n provider: TransformResultProvider,\n importer: string,\n source: string,\n): Loc | undefined {\n const result = provider.getTransformResult(importer)\n if (!result) {\n return undefined\n }\n\n const originalResult = getOrCreateOriginalTransformResult(result)\n if (!originalResult) {\n return undefined\n }\n\n const index = importSpecifierLocationIndex.find(originalResult, source)\n if (index === -1) {\n return undefined\n }\n\n const lineIndex =\n originalResult.lineIndex ??\n (originalResult.lineIndex = buildLineIndex(originalResult.code))\n const loc = indexToLineColumn(lineIndex, index)\n\n return {\n file: normalizeFilePath(importer),\n line: loc.line,\n column: loc.column,\n }\n}\n\nasync function resolveImporterLocation(opts: {\n provider: TransformResultProvider\n importLocCache: ImportLocCache\n importer: string\n sourceCandidates: Iterable<string>\n preferOriginalCode?: boolean\n envType?: 'client' | 'server'\n}): Promise<Loc | undefined> {\n if (opts.preferOriginalCode) {\n for (const candidate of opts.sourceCandidates) {\n const loc =\n findOriginalUsageLocation(\n opts.provider,\n opts.importer,\n candidate,\n opts.envType,\n ) ??\n findImportLocationInOriginalCode(\n opts.provider,\n opts.importer,\n candidate,\n )\n if (loc) {\n return loc\n }\n }\n }\n\n for (const candidate of opts.sourceCandidates) {\n const loc =\n (await findPostCompileUsageLocation(\n opts.provider,\n opts.importer,\n candidate,\n )) ||\n (await findImportStatementLocationFromTransformed(\n opts.provider,\n opts.importer,\n candidate,\n opts.importLocCache,\n importSpecifierLocationIndex.find,\n ))\n\n if (loc) {\n return loc\n }\n }\n\n if (!opts.preferOriginalCode) {\n for (const candidate of opts.sourceCandidates) {\n const loc = findImportLocationInOriginalCode(\n opts.provider,\n opts.importer,\n candidate,\n )\n if (loc) {\n return loc\n }\n }\n }\n\n return undefined\n}\n\nasync function rebuildAndAnnotateTrace(opts: {\n provider: TransformResultProvider\n graph: ImportGraph\n importLocCache: ImportLocCache\n importer: string\n specifier: string\n importerLoc?: Loc\n maxTraceDepth: number\n}): Promise<Array<TraceStep>> {\n const trace = buildTrace(opts.graph, opts.importer, opts.maxTraceDepth)\n\n await addTraceImportLocations(\n opts.provider,\n trace,\n opts.importLocCache,\n importSpecifierLocationIndex.find,\n )\n\n if (trace.length > 0) {\n const last = trace[trace.length - 1]!\n if (!last.specifier) {\n last.specifier = opts.specifier\n }\n if (opts.importerLoc && last.line == null) {\n last.line = opts.importerLoc.line\n last.column = opts.importerLoc.column\n }\n }\n\n return trace\n}\n\nasync function buildViolationInfo(opts: {\n config: PluginConfig\n provider: TransformResultProvider\n graph: ImportGraph\n importLocCache: ImportLocCache\n envName: string\n envType: 'client' | 'server'\n importer: string\n source: string\n resolved?: string\n type: 'specifier' | 'file' | 'marker'\n pattern?: string | RegExp\n preferOriginalCode?: boolean\n}): Promise<ViolationInfo> {\n const importerLoc = await resolveImporterLocation({\n provider: opts.provider,\n importLocCache: opts.importLocCache,\n importer: opts.importer,\n sourceCandidates: buildSourceCandidates(\n opts.source,\n opts.resolved,\n opts.config.root,\n ),\n preferOriginalCode: opts.preferOriginalCode,\n envType: opts.envType,\n })\n\n const trace = await rebuildAndAnnotateTrace({\n provider: opts.provider,\n graph: opts.graph,\n importLocCache: opts.importLocCache,\n importer: opts.importer,\n specifier: opts.source,\n importerLoc,\n maxTraceDepth: opts.config.maxTraceDepth,\n })\n\n const snippet = importerLoc\n ? buildCodeSnippet(opts.provider, opts.importer, importerLoc)\n : undefined\n\n return {\n env: opts.envName,\n envType: opts.envType,\n behavior: opts.config.effectiveBehavior,\n type: opts.type,\n pattern: opts.pattern,\n specifier: opts.source,\n importer: opts.importer,\n ...(opts.resolved ? { resolved: opts.resolved } : {}),\n ...(importerLoc ? { importerLoc } : {}),\n trace,\n snippet,\n }\n}\n\nasync function getMarkerKindForFile(opts: {\n config: PluginConfig\n provider: TransformResultProvider\n loadOriginalCode: OriginalCodeLoader\n markerKindCache: Map<string, Promise<'server' | 'client' | undefined>>\n file: string\n}): Promise<'server' | 'client' | undefined> {\n if (!isImportProtectionSourceFile(opts.file)) {\n return undefined\n }\n\n let cached = opts.markerKindCache.get(opts.file)\n if (!cached) {\n cached = (async () => {\n const code =\n opts.provider.getTransformResult(opts.file)?.originalCode ??\n (await opts.loadOriginalCode(opts.file))\n\n if (!code) {\n return undefined\n }\n\n const imports = getImportSources(code)\n const hasServerOnly = imports.some((source) =>\n opts.config.markerSpecifiers.serverOnly.has(source),\n )\n const hasClientOnly = imports.some((source) =>\n opts.config.markerSpecifiers.clientOnly.has(source),\n )\n\n if (hasServerOnly && !hasClientOnly) {\n return 'server'\n }\n\n if (hasClientOnly && !hasServerOnly) {\n return 'client'\n }\n\n return undefined\n })()\n opts.markerKindCache.set(opts.file, cached)\n }\n\n return cached\n}\n\nasync function reportViolation(opts: {\n config: PluginConfig\n envState: EnvRuntimeState\n compilation: RspackCompilation\n rspack: RspackNamespace\n info: ViolationInfo\n}): Promise<void> {\n const key = dedupeKey(opts.info)\n if (\n opts.config.logMode !== 'always' &&\n opts.envState.seenViolations.has(key)\n ) {\n return\n }\n\n opts.envState.seenViolations.add(key)\n\n if (opts.config.onViolation) {\n const result = await opts.config.onViolation(opts.info)\n if (result === false) {\n return\n }\n }\n\n const message = formatViolation(opts.info, opts.config.root)\n const error = new opts.rspack.WebpackError(message)\n\n if (opts.config.effectiveBehavior === 'error') {\n opts.compilation.errors.push(error)\n } else {\n opts.compilation.warnings.push(error)\n }\n}\n\nexport function registerImportProtection(\n api: RsbuildPluginAPI,\n opts: {\n getConfig: GetConfigFn\n framework: CompileStartFrameworkOptions\n environments: Array<{ name: string; type: 'client' | 'server' }>\n },\n): void {\n const extensionlessResolver = new ExtensionlessAbsoluteIdResolver()\n const envStates = new Map<string, EnvRuntimeState>()\n const fileReadCache = new Map<string, Promise<string | undefined>>()\n\n const config: PluginConfig = {\n enabled: true,\n root: '',\n command: api.context.action === 'dev' ? 'serve' : 'build',\n srcDirectory: '',\n framework: opts.framework,\n effectiveBehavior: 'error',\n mockAccess: 'error',\n logMode: 'once',\n maxTraceDepth: 20,\n compiledRules: {\n client: {\n specifiers: [],\n files: [],\n excludeFiles: [],\n },\n server: {\n specifiers: [],\n files: [],\n excludeFiles: [],\n },\n },\n includeMatchers: [],\n excludeMatchers: [],\n ignoreImporterMatchers: [],\n markerSpecifiers: {\n serverOnly: new Set(),\n clientOnly: new Set(),\n },\n envTypeMap: new Map(opts.environments.map((env) => [env.name, env.type])),\n onViolation: undefined,\n }\n\n const shared: SharedState = {\n root: '',\n virtualModules: new Map(),\n vmPlugins: {},\n readyVmPlugins: {},\n inputFileSystems: {},\n pendingWrites: new Map(),\n }\n\n function applyUserConfig(): void {\n const { startConfig, resolvedStartConfig } = opts.getConfig()\n\n config.root = resolvedStartConfig.root\n config.srcDirectory = resolvedStartConfig.srcDirectory\n shared.root = resolvedStartConfig.root\n\n const userOpts: ImportProtectionOptions | undefined =\n startConfig.importProtection\n\n if (userOpts?.enabled === false) {\n config.enabled = false\n return\n }\n\n config.enabled = true\n\n const behavior = userOpts?.behavior\n if (typeof behavior === 'string') {\n config.effectiveBehavior = behavior\n } else {\n config.effectiveBehavior =\n config.command === 'serve'\n ? (behavior?.dev ?? 'mock')\n : (behavior?.build ?? 'error')\n }\n\n config.logMode = userOpts?.log ?? 'once'\n config.mockAccess = userOpts?.mockAccess ?? 'error'\n config.maxTraceDepth = userOpts?.maxTraceDepth ?? 20\n config.onViolation = userOpts?.onViolation\n ? (info) => userOpts.onViolation?.(info)\n : undefined\n\n const defaults = getDefaultImportProtectionRules()\n const pick = <T>(user: Array<T> | undefined, fallback: Array<T>) =>\n user ? [...user] : [...fallback]\n\n const clientSpecifiers = dedupePatterns([\n ...defaults.client.specifiers,\n ...(userOpts?.client?.specifiers ?? []),\n ])\n\n config.compiledRules.client = {\n specifiers: compileMatchers(clientSpecifiers),\n files: compileMatchers(\n pick(userOpts?.client?.files, defaults.client.files),\n ),\n excludeFiles: compileMatchers(\n pick(userOpts?.client?.excludeFiles, defaults.client.excludeFiles),\n ),\n }\n\n config.compiledRules.server = {\n specifiers: compileMatchers(\n dedupePatterns(\n pick(userOpts?.server?.specifiers, defaults.server.specifiers),\n ),\n ),\n files: compileMatchers(\n pick(userOpts?.server?.files, defaults.server.files),\n ),\n excludeFiles: compileMatchers(\n pick(userOpts?.server?.excludeFiles, defaults.server.excludeFiles),\n ),\n }\n\n config.includeMatchers = compileMatchers(userOpts?.include ?? [])\n config.excludeMatchers = compileMatchers(userOpts?.exclude ?? [])\n config.ignoreImporterMatchers = compileMatchers(\n userOpts?.ignoreImporters ?? [],\n )\n\n const markers = getMarkerSpecifiers()\n config.markerSpecifiers = {\n serverOnly: new Set(markers.serverOnly),\n clientOnly: new Set(markers.clientOnly),\n }\n }\n\n api.onBeforeBuild(() => {\n applyUserConfig()\n clearNormalizeFilePathCache()\n extensionlessResolver.clear()\n fileReadCache.clear()\n envStates.clear()\n })\n\n api.onBeforeDevCompile(() => {\n applyUserConfig()\n clearNormalizeFilePathCache()\n extensionlessResolver.clear()\n fileReadCache.clear()\n\n for (const envState of envStates.values()) {\n envState.resolveCache.clear()\n envState.buildTransformResults.clear()\n envState.deferredFileViolations.length = 0\n envState.deferredFileViolationKeys.clear()\n }\n })\n\n api.modifyRspackConfig((rspackConfig, utils) => {\n applyUserConfig()\n\n const envName = utils.environment.name\n const VMP = utils.rspack.experiments.VirtualModulesPlugin\n const vmPlugin = new VMP({})\n\n shared.vmPlugins[envName] = vmPlugin\n shared.readyVmPlugins[envName] = false\n\n rspackConfig.plugins.push(vmPlugin)\n rspackConfig.plugins.push({\n apply(compiler: Rspack.Compiler) {\n shared.inputFileSystems[envName] = compiler.inputFileSystem\n compiler.hooks.thisCompilation.tap(\n 'TanStackStartImportProtectionVirtualModulesReady',\n () => {\n shared.readyVmPlugins[envName] = true\n flushPendingWrites(shared, envName)\n },\n )\n },\n })\n })\n\n for (const environment of opts.environments) {\n api.transform(\n {\n test: /\\.[cm]?[tj]sx?$/,\n environments: [environment.name],\n order: 'post',\n },\n async (ctx) => {\n if (!config.enabled) {\n return ctx.code\n }\n\n const envName = environment.name\n const envType = getImportProtectionEnvType(config, envName)\n const envState = getOrCreateEnvState(envStates, envName)\n const id = ctx.resource\n const file = normalizeFilePath(ctx.resourcePath)\n\n if (!shouldCheckImportProtectionImporter(config, file)) {\n return ctx.code\n }\n\n const matchers = getRulesForEnvironment(config, envName)\n const relativeFile = getImportProtectionRelativePath(config.root, file)\n const importSources = getImportSources(ctx.code)\n const transformedImportSources = new Set(importSources)\n const transformInputFileSystem = shared.inputFileSystems[envName]\n const loadOriginalCodeForTransform: OriginalCodeLoader =\n transformInputFileSystem\n ? (target) =>\n loadOriginalCodeFromInputFileSystem(\n transformInputFileSystem,\n target,\n )\n : () => Promise.resolve(undefined)\n const originalCode =\n config.command === 'build'\n ? await loadOriginalCode(\n fileReadCache,\n file,\n loadOriginalCodeForTransform,\n )\n : undefined\n const buildImportSources = originalCode\n ? getImportSources(originalCode)\n : []\n const buildTransformResult: TransformResult | undefined =\n config.command === 'build'\n ? {\n code: ctx.code,\n map: undefined,\n originalCode,\n lineIndex: buildLineIndex(ctx.code),\n }\n : undefined\n\n if (config.command === 'build') {\n const relativeBuildFile = getImportProtectionRelativePath(\n config.root,\n file,\n )\n addTransformResult(\n envState.buildTransformResults,\n file,\n buildTransformResult!,\n )\n addTransformResult(\n envState.buildTransformResults,\n relativeBuildFile,\n buildTransformResult!,\n )\n if (id !== file) {\n addTransformResult(\n envState.buildTransformResults,\n id,\n buildTransformResult!,\n )\n }\n }\n\n const hasServerOnlyMarker = importSources.some((source) =>\n config.markerSpecifiers.serverOnly.has(source),\n )\n const hasClientOnlyMarker = importSources.some((source) =>\n config.markerSpecifiers.clientOnly.has(source),\n )\n\n if (hasServerOnlyMarker && hasClientOnlyMarker) {\n throw new Error(\n `[import-protection] File \"${relativeFile}\" has both server-only and client-only markers. This is not allowed.`,\n )\n }\n\n const markerKind = hasServerOnlyMarker\n ? ('server' as const)\n : hasClientOnlyMarker\n ? ('client' as const)\n : undefined\n\n const fileMatch = checkFileDenial(relativeFile, matchers)\n const markerViolation =\n (envType === 'client' && markerKind === 'server') ||\n (envType === 'server' && markerKind === 'client')\n\n if (fileMatch || markerViolation) {\n let exportNames: Array<string> = []\n\n try {\n exportNames = getNamedExports(ctx.code)\n } catch {\n exportNames = []\n }\n\n if (config.command === 'build') {\n return generateSelfContainedMockModule(exportNames)\n }\n\n const runtimeId = ensureRuntimeMockModule({\n shared,\n envName,\n mode: config.mockAccess,\n env: envName,\n importer: file,\n specifier: relativeFile,\n })\n\n return generateDevSelfDenialModule(exportNames, runtimeId)\n }\n\n const deniedSpecifierReplacements = new Map<string, string>()\n const exportsBySource = (() => {\n try {\n return getMockExportNamesBySource(ctx.code)\n } catch {\n return new Map<string, Array<string>>()\n }\n })()\n\n for (const source of importSources) {\n const specifierMatch = matchesAny(source, matchers.specifiers)\n if (!specifierMatch && config.command === 'build') {\n const resolved = await resolveAgainstImporter({\n envState,\n config,\n ctx,\n importerId: id,\n source,\n extensionlessResolver,\n })\n\n if (resolved) {\n const relativeResolved = getImportProtectionRelativePath(\n config.root,\n resolved,\n )\n const buildFileMatch = checkFileDenial(relativeResolved, matchers)\n if (\n buildFileMatch &&\n hasOriginalUnsafeUsage(buildTransformResult, source, envType)\n ) {\n deferFileViolation(envState, {\n importer: file,\n specifier: source,\n resolved,\n relativeResolved,\n pattern: buildFileMatch.pattern,\n useOriginalLocation: true,\n })\n }\n }\n\n continue\n }\n\n if (!specifierMatch) {\n continue\n }\n\n const resolved = await resolveAgainstImporter({\n envState,\n config,\n ctx,\n importerId: id,\n source,\n extensionlessResolver,\n })\n\n const runtimeId =\n config.command === 'build'\n ? ensureSilentMockModule(shared, envName)\n : ensureRuntimeMockModule({\n shared,\n envName,\n mode: config.mockAccess,\n env: envName,\n importer: file,\n specifier: source,\n })\n\n const replacement = ensureMockEdgeModule({\n shared,\n envName,\n payload: {\n exports: exportsBySource.get(source) ?? [],\n runtimeId,\n violation: {\n env: envName,\n envType,\n importer: file,\n specifier: source,\n ...(resolved ? { resolved } : {}),\n patternText: serializePattern(specifierMatch.pattern),\n },\n },\n })\n\n deniedSpecifierReplacements.set(source, replacement)\n }\n\n if (config.command === 'build') {\n for (const source of buildImportSources) {\n if (transformedImportSources.has(source)) {\n continue\n }\n\n if (matchesAny(source, matchers.specifiers)) {\n continue\n }\n\n const resolved = await resolveAgainstImporter({\n envState,\n config,\n ctx,\n importerId: id,\n source,\n extensionlessResolver,\n })\n\n if (!resolved) {\n continue\n }\n\n const relativeResolved = getImportProtectionRelativePath(\n config.root,\n resolved,\n )\n const buildFileMatch = checkFileDenial(relativeResolved, matchers)\n if (\n !buildFileMatch ||\n !hasOriginalUnsafeUsage(buildTransformResult, source, envType)\n ) {\n continue\n }\n\n deferFileViolation(envState, {\n importer: file,\n specifier: source,\n resolved,\n relativeResolved,\n pattern: buildFileMatch.pattern,\n useOriginalLocation: true,\n })\n }\n }\n\n if (deniedSpecifierReplacements.size === 0) {\n return ctx.code\n }\n\n const rewritten = rewriteDeniedImports(\n ctx.code,\n id,\n new Set(deniedSpecifierReplacements.keys()),\n (source) => deniedSpecifierReplacements.get(source) ?? source,\n )\n\n if (!rewritten) {\n return ctx.code\n }\n\n return {\n code: rewritten.code,\n map: normalizeSourceMap(rewritten.map) ?? null,\n }\n },\n )\n }\n\n api.processAssets(\n {\n stage: 'report',\n environments: opts.environments.map((environment) => environment.name),\n },\n async (context: ProcessAssetsContext) => {\n if (!config.enabled) {\n return\n }\n\n const envName = context.environment.name\n const envType = getImportProtectionEnvType(config, envName)\n const envState = getOrCreateEnvState(envStates, envName)\n const matchers = getRulesForEnvironment(config, envName)\n const processFileReadCache = new Map<\n string,\n Promise<string | undefined>\n >()\n const loadOriginalCodeFromCompilation: OriginalCodeLoader = (file) =>\n loadOriginalCode(\n processFileReadCache,\n file,\n context.compilation.inputFileSystem\n ? (target) =>\n loadOriginalCodeFromInputFileSystem(\n context.compilation.inputFileSystem!,\n target,\n )\n : () => Promise.resolve(undefined),\n )\n const allModules = Array.from(context.compilation.modules)\n const relevantModules = allModules.filter(isImportProtectionSourceModule)\n\n const provider = await buildTransformResultProvider({\n modules: relevantModules,\n root: config.root,\n loadOriginalCode: loadOriginalCodeFromCompilation,\n preloaded: envState.buildTransformResults,\n })\n const importLocCache = new ImportLocCache()\n const markerKindCache = new Map<\n string,\n Promise<'server' | 'client' | undefined>\n >()\n const { graph, edges } = buildCompilationGraph({\n compilation: context.compilation,\n modules: relevantModules,\n })\n const liveFileEdgeKeys = new Set(\n edges\n .filter((edge) => !!edge.specifier)\n .map(\n (edge) =>\n `${normalizeFilePath(edge.importer)}::${edge.specifier!}::${normalizeFilePath(edge.resolved)}`,\n ),\n )\n const survivingModules = new Set<string>()\n for (const module of relevantModules) {\n for (const candidate of buildResolutionCandidates(\n getModuleFile(module),\n )) {\n survivingModules.add(candidate)\n }\n }\n\n const didModuleSurvive = (id: string): boolean =>\n buildResolutionCandidates(id).some((candidate) =>\n survivingModules.has(candidate),\n )\n\n for (const module of relevantModules) {\n const payload = getMockEdgePayloadFromFile(getModuleFile(module))\n if (!payload) {\n continue\n }\n if (\n !shouldCheckImportProtectionImporter(\n config,\n payload.violation.importer,\n )\n ) {\n continue\n }\n\n const info = await buildViolationInfo({\n config,\n provider,\n graph,\n importLocCache,\n envName,\n envType,\n importer: payload.violation.importer,\n source: payload.violation.specifier,\n resolved: payload.violation.resolved,\n type: 'specifier',\n pattern: payload.violation.patternText,\n preferOriginalCode: true,\n })\n\n await reportViolation({\n config,\n envState,\n compilation: context.compilation,\n rspack: context.compiler.rspack,\n info,\n })\n }\n\n for (const edge of edges) {\n if (!edge.specifier) {\n continue\n }\n if (!shouldCheckImportProtectionImporter(config, edge.importer)) {\n continue\n }\n\n const relativeResolved = getImportProtectionRelativePath(\n config.root,\n edge.resolved,\n )\n if (isFileExcluded(relativeResolved, matchers)) {\n continue\n }\n const fileMatch = checkFileDenial(relativeResolved, matchers)\n if (fileMatch) {\n const info = await buildViolationInfo({\n config,\n provider,\n graph,\n importLocCache,\n envName,\n envType,\n importer: edge.importer,\n source: edge.specifier,\n resolved: edge.resolved,\n type: 'file',\n pattern: fileMatch.pattern,\n })\n\n await reportViolation({\n config,\n envState,\n compilation: context.compilation,\n rspack: context.compiler.rspack,\n info,\n })\n continue\n }\n\n const markerKind = await getMarkerKindForFile({\n config,\n provider,\n loadOriginalCode: loadOriginalCodeFromCompilation,\n markerKindCache,\n file: edge.resolved,\n })\n const violatesMarker =\n (envType === 'client' && markerKind === 'server') ||\n (envType === 'server' && markerKind === 'client')\n\n if (!violatesMarker) {\n continue\n }\n\n const info = await buildViolationInfo({\n config,\n provider,\n graph,\n importLocCache,\n envName,\n envType,\n importer: edge.importer,\n source: edge.specifier,\n resolved: edge.resolved,\n type: 'marker',\n })\n\n await reportViolation({\n config,\n envState,\n compilation: context.compilation,\n rspack: context.compiler.rspack,\n info,\n })\n }\n\n for (const violation of envState.deferredFileViolations) {\n const liveEdgeKey = `${normalizeFilePath(violation.importer)}::${violation.specifier}::${normalizeFilePath(violation.resolved)}`\n if (liveFileEdgeKeys.has(liveEdgeKey)) {\n continue\n }\n\n if (!didModuleSurvive(violation.resolved)) {\n continue\n }\n\n if (!didModuleSurvive(violation.importer)) {\n continue\n }\n\n const info = await buildViolationInfo({\n config,\n provider,\n graph,\n importLocCache,\n envName,\n envType,\n importer: violation.importer,\n source: violation.specifier,\n resolved: violation.resolved,\n type: 'file',\n pattern: violation.pattern,\n preferOriginalCode: violation.useOriginalLocation,\n })\n\n await reportViolation({\n config,\n envState,\n compilation: context.compilation,\n rspack: context.compiler.rspack,\n info,\n })\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAgGA,IAAM,+BAA+B,oCAAoC;AAgFzE,IAAM,gCAAgC;AACtC,IAAM,wBAAwB;AAC9B,IAAM,2BAA2B;AACjC,IAAM,mBAAmB;AAEzB,SAAS,YAAY,OAAwB;AAC3C,QAAO,OAAO,KAAK,KAAK,UAAU,MAAM,EAAE,OAAO,CAAC,SAAS,YAAY;;AAGzE,SAAS,cAAiB,OAAkB;AAC1C,QAAO,KAAK,MAAM,OAAO,KAAK,OAAO,YAAY,CAAC,SAAS,O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;AAKF,OAAI,EAHD,YAAY,YAAY,eAAe,YACvC,YAAY,YAAY,eAAe,UAGxC;GAGF,MAAM,OAAO,MAAM,mBAAmB;IACpC;IACA;IACA;IACA;IACA;IACA;IACA,UAAU,KAAK;IACf,QAAQ,KAAK;IACb,UAAU,KAAK;IACf,MAAM;IACP,CAAC;AAEF,SAAM,gBAAgB;IACpB;IACA;IACA,aAAa,QAAQ;IACrB,QAAQ,QAAQ,SAAS;IACzB;IACD,CAAC;;AAGJ,OAAK,MAAM,aAAa,SAAS,wBAAwB;GACvD,MAAM,cAAc,GAAG,kBAAkB,UAAU,SAAS,CAAC,IAAI,UAAU,UAAU,IAAI,kBAAkB,UAAU,SAAS;AAC9H,OAAI,iBAAiB,IAAI,YAAY,CACnC;AAGF,OAAI,CAAC,iBAAiB,UAAU,SAAS,CACvC;AAGF,OAAI,CAAC,iBAAiB,UAAU,SAAS,CACvC;GAGF,MAAM,OAAO,MAAM,mBAAmB;IACpC;IACA;IACA;IACA;IACA;IACA;IACA,UAAU,UAAU;IACpB,QAAQ,UAAU;IAClB,UAAU,UAAU;IACpB,MAAM;IACN,SAAS,UAAU;IACnB,oBAAoB,UAAU;IAC/B,CAAC;AAEF,SAAM,gBAAgB;IACpB;IACA;IACA,aAAa,QAAQ;IACrB,QAAQ,QAAQ,SAAS;IACzB;IACD,CAAC;;GAGP"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RsbuildPluginAPI, Rspack } from '@rsbuild/core';
|
|
2
|
+
import { NormalizedClientBuild } from '../types.js';
|
|
3
|
+
type RspackCompilation = Rspack.Compilation;
|
|
4
|
+
/**
|
|
5
|
+
* Normalize an rspack compilation into a NormalizedClientBuild.
|
|
6
|
+
*
|
|
7
|
+
* Iterates ALL chunks in the compilation (initial + async), not just
|
|
8
|
+
* entrypoint chunks, to ensure route-split async chunks are included.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeRspackClientBuild(compilation: RspackCompilation): NormalizedClientBuild;
|
|
11
|
+
/**
|
|
12
|
+
* Registers a processAssets hook to capture the client build stats
|
|
13
|
+
* after compilation. Returns a getter for the captured build.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerClientBuildCapture(api: RsbuildPluginAPI): {
|
|
16
|
+
getClientBuild: () => NormalizedClientBuild | undefined;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { RSBUILD_ENVIRONMENT_NAMES } from "./planning.js";
|
|
2
|
+
import { tsrSplit } from "@tanstack/router-plugin";
|
|
3
|
+
//#region src/rsbuild/normalized-client-build.ts
|
|
4
|
+
/**
|
|
5
|
+
* Extract route file paths from rspack module identifiers.
|
|
6
|
+
*
|
|
7
|
+
* In rspack, module identifiers contain query params similar to Vite's moduleIds.
|
|
8
|
+
* We look for the `tsr-split` query to identify route-split chunks.
|
|
9
|
+
*/
|
|
10
|
+
function getRouteFilePathsFromModules(modules) {
|
|
11
|
+
let routeFilePaths;
|
|
12
|
+
let seen;
|
|
13
|
+
for (const mod of modules) {
|
|
14
|
+
const identifier = mod.identifier();
|
|
15
|
+
const lastBangIndex = identifier.lastIndexOf("!");
|
|
16
|
+
const resourcePart = lastBangIndex >= 0 ? identifier.slice(lastBangIndex + 1) : identifier;
|
|
17
|
+
const queryIndex = resourcePart.indexOf("?");
|
|
18
|
+
if (queryIndex < 0) continue;
|
|
19
|
+
const query = resourcePart.slice(queryIndex + 1);
|
|
20
|
+
if (!query.includes(tsrSplit)) continue;
|
|
21
|
+
if (!new URLSearchParams(query).has(tsrSplit)) continue;
|
|
22
|
+
const routeFilePath = mod.nameForCondition() ?? resourcePart.slice(0, queryIndex);
|
|
23
|
+
if (seen?.has(routeFilePath)) continue;
|
|
24
|
+
if (!routeFilePaths || !seen) {
|
|
25
|
+
routeFilePaths = [];
|
|
26
|
+
seen = /* @__PURE__ */ new Set();
|
|
27
|
+
}
|
|
28
|
+
routeFilePaths.push(routeFilePath);
|
|
29
|
+
seen.add(routeFilePath);
|
|
30
|
+
}
|
|
31
|
+
return routeFilePaths ?? [];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns true for Rspack/webpack HMR runtime chunks that should never be
|
|
35
|
+
* surfaced to the Start manifest. These files are emitted on every rebuild
|
|
36
|
+
* (e.g. `index.<hash>.hot-update.mjs`) and must not be treated as the entry
|
|
37
|
+
* chunk, route preloads, or sibling imports.
|
|
38
|
+
*/
|
|
39
|
+
function isHotUpdateAsset(file) {
|
|
40
|
+
return file.includes(".hot-update.");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* True for any JS/MJS asset that should be included in the manifest.
|
|
44
|
+
* Excludes HMR runtime patches.
|
|
45
|
+
*/
|
|
46
|
+
function isManifestJsAsset(file) {
|
|
47
|
+
if (!file.endsWith(".js") && !file.endsWith(".mjs")) return false;
|
|
48
|
+
return !isHotUpdateAsset(file);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get all JS file names from a chunk.
|
|
52
|
+
*/
|
|
53
|
+
function getChunkJsFiles(chunk) {
|
|
54
|
+
const jsFiles = [];
|
|
55
|
+
for (const file of chunk.files) if (isManifestJsAsset(file)) jsFiles.push(file);
|
|
56
|
+
return jsFiles;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Compute dynamicImports for a chunk by traversing its chunk groups'
|
|
60
|
+
* childrenIterable (async/dynamic import edges).
|
|
61
|
+
*
|
|
62
|
+
* In rspack, a chunk belongs to one or more ChunkGroups. Each ChunkGroup
|
|
63
|
+
* has childrenIterable — child ChunkGroups representing dynamic import()
|
|
64
|
+
* points. The JS files from those child groups' chunks are the
|
|
65
|
+
* dynamicImports (analogous to Rollup's OutputChunk.dynamicImports).
|
|
66
|
+
*/
|
|
67
|
+
function computeDynamicImports(chunk) {
|
|
68
|
+
const dynamicImportFiles = [];
|
|
69
|
+
const seen = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const group of chunk.groupsIterable) for (const childGroup of group.childrenIterable) for (const childChunk of childGroup.chunks) for (const file of childChunk.files) if (isManifestJsAsset(file) && !seen.has(file)) {
|
|
71
|
+
seen.add(file);
|
|
72
|
+
dynamicImportFiles.push(file);
|
|
73
|
+
}
|
|
74
|
+
return dynamicImportFiles;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compute static imports (sibling chunks) for an async chunk.
|
|
78
|
+
*
|
|
79
|
+
* In rspack/webpack, an async chunk's ChunkGroup contains ALL chunks needed to
|
|
80
|
+
* satisfy that dynamic import — the async chunk itself plus any shared/vendor
|
|
81
|
+
* chunks it statically imports. This is analogous to Rollup's
|
|
82
|
+
* `OutputChunk.imports` for async chunks.
|
|
83
|
+
*
|
|
84
|
+
* We collect JS files from all sibling chunks in the group (excluding the
|
|
85
|
+
* current chunk's own file) to populate the `imports` field.
|
|
86
|
+
*/
|
|
87
|
+
function computeAsyncChunkImports(chunk, currentFile) {
|
|
88
|
+
const imports = [];
|
|
89
|
+
const seen = /* @__PURE__ */ new Set();
|
|
90
|
+
seen.add(currentFile);
|
|
91
|
+
for (const group of chunk.groupsIterable) for (const siblingChunk of group.chunks) for (const file of siblingChunk.files) if (isManifestJsAsset(file) && !seen.has(file)) {
|
|
92
|
+
seen.add(file);
|
|
93
|
+
imports.push(file);
|
|
94
|
+
}
|
|
95
|
+
return imports;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Normalize an rspack compilation into a NormalizedClientBuild.
|
|
99
|
+
*
|
|
100
|
+
* Iterates ALL chunks in the compilation (initial + async), not just
|
|
101
|
+
* entrypoint chunks, to ensure route-split async chunks are included.
|
|
102
|
+
*/
|
|
103
|
+
function normalizeRspackClientBuild(compilation) {
|
|
104
|
+
const chunksByFileName = /* @__PURE__ */ new Map();
|
|
105
|
+
const chunkFileNamesByRouteFilePath = /* @__PURE__ */ new Map();
|
|
106
|
+
const cssFilesBySourcePath = /* @__PURE__ */ new Map();
|
|
107
|
+
let entryChunkFileName;
|
|
108
|
+
const entrypoint = compilation.entrypoints.get("index");
|
|
109
|
+
const initialJsFileNames = [];
|
|
110
|
+
const entryChunkSet = /* @__PURE__ */ new Set();
|
|
111
|
+
if (entrypoint) for (const chunk of entrypoint.chunks) {
|
|
112
|
+
entryChunkSet.add(chunk);
|
|
113
|
+
for (const file of chunk.files) if (isManifestJsAsset(file)) initialJsFileNames.push(file);
|
|
114
|
+
}
|
|
115
|
+
for (const chunk of compilation.chunks) {
|
|
116
|
+
const modules = compilation.chunkGraph.getChunkModules(chunk);
|
|
117
|
+
const routeFilePaths = getRouteFilePathsFromModules(modules);
|
|
118
|
+
const cssFiles = [];
|
|
119
|
+
const seenCssFiles = /* @__PURE__ */ new Set();
|
|
120
|
+
for (const auxFile of chunk.auxiliaryFiles) if (auxFile.endsWith(".css") && !seenCssFiles.has(auxFile)) {
|
|
121
|
+
seenCssFiles.add(auxFile);
|
|
122
|
+
cssFiles.push(auxFile);
|
|
123
|
+
}
|
|
124
|
+
for (const mainFile of chunk.files) if (mainFile.endsWith(".css") && !seenCssFiles.has(mainFile)) {
|
|
125
|
+
seenCssFiles.add(mainFile);
|
|
126
|
+
cssFiles.push(mainFile);
|
|
127
|
+
}
|
|
128
|
+
if (cssFiles.length > 0) for (const mod of modules) {
|
|
129
|
+
const sourcePath = mod.nameForCondition();
|
|
130
|
+
if (!sourcePath) continue;
|
|
131
|
+
const existing = cssFilesBySourcePath.get(sourcePath);
|
|
132
|
+
cssFilesBySourcePath.set(sourcePath, existing ? appendUniqueStrings(existing, cssFiles) : cssFiles.slice());
|
|
133
|
+
}
|
|
134
|
+
const isEntryChunk = chunk.name === "index" && entryChunkSet.has(chunk);
|
|
135
|
+
const jsFiles = getChunkJsFiles(chunk);
|
|
136
|
+
if (jsFiles.length === 0) continue;
|
|
137
|
+
const dynamicImports = computeDynamicImports(chunk);
|
|
138
|
+
for (const file of jsFiles) {
|
|
139
|
+
const normalizedChunk = {
|
|
140
|
+
fileName: file,
|
|
141
|
+
isEntry: isEntryChunk,
|
|
142
|
+
imports: isEntryChunk ? initialJsFileNames.filter((f) => f !== file) : computeAsyncChunkImports(chunk, file),
|
|
143
|
+
dynamicImports,
|
|
144
|
+
css: [],
|
|
145
|
+
routeFilePaths
|
|
146
|
+
};
|
|
147
|
+
chunksByFileName.set(file, normalizedChunk);
|
|
148
|
+
if (isEntryChunk && !entryChunkFileName) entryChunkFileName = file;
|
|
149
|
+
for (const routeFilePath of routeFilePaths) {
|
|
150
|
+
let chunkFileNames = chunkFileNamesByRouteFilePath.get(routeFilePath);
|
|
151
|
+
if (!chunkFileNames) {
|
|
152
|
+
chunkFileNames = [];
|
|
153
|
+
chunkFileNamesByRouteFilePath.set(routeFilePath, chunkFileNames);
|
|
154
|
+
}
|
|
155
|
+
chunkFileNames.push(file);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const cssFile of cssFiles) for (const file of jsFiles) {
|
|
159
|
+
const existing = chunksByFileName.get(file);
|
|
160
|
+
if (existing && !existing.css.includes(cssFile)) existing.css.push(cssFile);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (!entryChunkFileName) throw new Error("No entry file found in rspack client build");
|
|
164
|
+
const rscEntrypoint = compilation.entrypoints.get("rsc");
|
|
165
|
+
if (rscEntrypoint && entryChunkFileName) {
|
|
166
|
+
const mainEntryChunk = chunksByFileName.get(entryChunkFileName);
|
|
167
|
+
if (mainEntryChunk) for (const rscChunk of rscEntrypoint.chunks) {
|
|
168
|
+
const allFiles = [...rscChunk.files, ...rscChunk.auxiliaryFiles];
|
|
169
|
+
for (const file of allFiles) if (file.endsWith(".css") && !mainEntryChunk.css.includes(file)) mainEntryChunk.css.push(file);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
entryChunkFileName,
|
|
174
|
+
chunksByFileName,
|
|
175
|
+
chunkFileNamesByRouteFilePath,
|
|
176
|
+
cssFilesBySourcePath
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function appendUniqueStrings(target, source) {
|
|
180
|
+
const seen = new Set(target);
|
|
181
|
+
let result;
|
|
182
|
+
for (const value of source) {
|
|
183
|
+
if (seen.has(value)) continue;
|
|
184
|
+
seen.add(value);
|
|
185
|
+
if (!result) result = target.slice();
|
|
186
|
+
result.push(value);
|
|
187
|
+
}
|
|
188
|
+
return result ?? target;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Registers a processAssets hook to capture the client build stats
|
|
192
|
+
* after compilation. Returns a getter for the captured build.
|
|
193
|
+
*/
|
|
194
|
+
function registerClientBuildCapture(api) {
|
|
195
|
+
let clientBuild;
|
|
196
|
+
api.processAssets({
|
|
197
|
+
stage: "report",
|
|
198
|
+
environments: [RSBUILD_ENVIRONMENT_NAMES.client]
|
|
199
|
+
}, (context) => {
|
|
200
|
+
clientBuild = normalizeRspackClientBuild(context.compilation);
|
|
201
|
+
});
|
|
202
|
+
return { getClientBuild: () => clientBuild };
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { registerClientBuildCapture };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=normalized-client-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-client-build.js","names":[],"sources":["../../../src/rsbuild/normalized-client-build.ts"],"sourcesContent":["import { tsrSplit } from '@tanstack/router-plugin'\nimport { RSBUILD_ENVIRONMENT_NAMES } from './planning'\nimport type { RsbuildPluginAPI, Rspack } from '@rsbuild/core'\nimport type { NormalizedClientBuild, NormalizedClientChunk } from '../types'\n\ntype ProcessAssetsContext = Parameters<\n Parameters<RsbuildPluginAPI['processAssets']>[1]\n>[0]\ntype RspackCompilation = Rspack.Compilation\ntype RspackCompilationChunk = Rspack.Chunk\ntype RspackModule = Rspack.Module\n\n/**\n * Extract route file paths from rspack module identifiers.\n *\n * In rspack, module identifiers contain query params similar to Vite's moduleIds.\n * We look for the `tsr-split` query to identify route-split chunks.\n */\nfunction getRouteFilePathsFromModules(\n modules: Array<RspackModule>,\n): Array<string> {\n let routeFilePaths: Array<string> | undefined\n let seen: Set<string> | undefined\n\n for (const mod of modules) {\n const identifier = mod.identifier()\n\n // rspack module identifiers include loader prefixes separated by '!'.\n // The actual file path (with query string) is after the last '!'.\n // Example: \"builtin:swc-loader??ruleSet[...]!.../transform.js??...!.../rsc-basic.tsx?tsr-split=component\"\n const lastBangIndex = identifier.lastIndexOf('!')\n const resourcePart =\n lastBangIndex >= 0 ? identifier.slice(lastBangIndex + 1) : identifier\n\n const queryIndex = resourcePart.indexOf('?')\n if (queryIndex < 0) continue\n\n const query = resourcePart.slice(queryIndex + 1)\n if (!query.includes(tsrSplit)) continue\n if (!new URLSearchParams(query).has(tsrSplit)) continue\n\n const nameForCondition = mod.nameForCondition()\n const routeFilePath = nameForCondition ?? resourcePart.slice(0, queryIndex)\n\n if (seen?.has(routeFilePath)) continue\n\n if (!routeFilePaths || !seen) {\n routeFilePaths = []\n seen = new Set()\n }\n\n routeFilePaths.push(routeFilePath)\n seen.add(routeFilePath)\n }\n\n return routeFilePaths ?? []\n}\n\n/**\n * Returns true for Rspack/webpack HMR runtime chunks that should never be\n * surfaced to the Start manifest. These files are emitted on every rebuild\n * (e.g. `index.<hash>.hot-update.mjs`) and must not be treated as the entry\n * chunk, route preloads, or sibling imports.\n */\nfunction isHotUpdateAsset(file: string): boolean {\n return file.includes('.hot-update.')\n}\n\n/**\n * True for any JS/MJS asset that should be included in the manifest.\n * Excludes HMR runtime patches.\n */\nfunction isManifestJsAsset(file: string): boolean {\n if (!file.endsWith('.js') && !file.endsWith('.mjs')) return false\n return !isHotUpdateAsset(file)\n}\n\n/**\n * Get all JS file names from a chunk.\n */\nfunction getChunkJsFiles(chunk: RspackCompilationChunk): Array<string> {\n const jsFiles: Array<string> = []\n for (const file of chunk.files) {\n if (isManifestJsAsset(file)) {\n jsFiles.push(file)\n }\n }\n return jsFiles\n}\n\n/**\n * Compute dynamicImports for a chunk by traversing its chunk groups'\n * childrenIterable (async/dynamic import edges).\n *\n * In rspack, a chunk belongs to one or more ChunkGroups. Each ChunkGroup\n * has childrenIterable — child ChunkGroups representing dynamic import()\n * points. The JS files from those child groups' chunks are the\n * dynamicImports (analogous to Rollup's OutputChunk.dynamicImports).\n */\nfunction computeDynamicImports(chunk: RspackCompilationChunk): Array<string> {\n const dynamicImportFiles: Array<string> = []\n const seen = new Set<string>()\n\n for (const group of chunk.groupsIterable) {\n for (const childGroup of group.childrenIterable) {\n for (const childChunk of childGroup.chunks) {\n for (const file of childChunk.files) {\n if (isManifestJsAsset(file) && !seen.has(file)) {\n seen.add(file)\n dynamicImportFiles.push(file)\n }\n }\n }\n }\n }\n\n return dynamicImportFiles\n}\n\n/**\n * Compute static imports (sibling chunks) for an async chunk.\n *\n * In rspack/webpack, an async chunk's ChunkGroup contains ALL chunks needed to\n * satisfy that dynamic import — the async chunk itself plus any shared/vendor\n * chunks it statically imports. This is analogous to Rollup's\n * `OutputChunk.imports` for async chunks.\n *\n * We collect JS files from all sibling chunks in the group (excluding the\n * current chunk's own file) to populate the `imports` field.\n */\nfunction computeAsyncChunkImports(\n chunk: RspackCompilationChunk,\n currentFile: string,\n): Array<string> {\n const imports: Array<string> = []\n const seen = new Set<string>()\n seen.add(currentFile)\n\n for (const group of chunk.groupsIterable) {\n for (const siblingChunk of group.chunks) {\n for (const file of siblingChunk.files) {\n if (isManifestJsAsset(file) && !seen.has(file)) {\n seen.add(file)\n imports.push(file)\n }\n }\n }\n }\n\n return imports\n}\n\n/**\n * Normalize an rspack compilation into a NormalizedClientBuild.\n *\n * Iterates ALL chunks in the compilation (initial + async), not just\n * entrypoint chunks, to ensure route-split async chunks are included.\n */\nexport function normalizeRspackClientBuild(\n compilation: RspackCompilation,\n): NormalizedClientBuild {\n const chunksByFileName = new Map<string, NormalizedClientChunk>()\n const chunkFileNamesByRouteFilePath = new Map<string, Array<string>>()\n const cssFilesBySourcePath = new Map<string, Array<string>>()\n let entryChunkFileName: string | undefined\n\n // Collect all initial JS file names from the main entry for computing\n // the entry chunk's `imports` (vendor/shared sibling chunks).\n const entrypoint = compilation.entrypoints.get('index')\n const initialJsFileNames: Array<string> = []\n const entryChunkSet = new Set<RspackCompilationChunk>()\n if (entrypoint) {\n for (const chunk of entrypoint.chunks) {\n entryChunkSet.add(chunk)\n for (const file of chunk.files) {\n if (isManifestJsAsset(file)) {\n initialJsFileNames.push(file)\n }\n }\n }\n }\n\n // Iterate ALL chunks (initial + async) to capture route-split chunks\n for (const chunk of compilation.chunks) {\n const modules = compilation.chunkGraph.getChunkModules(chunk)\n const routeFilePaths = getRouteFilePathsFromModules(modules)\n const cssFiles: Array<string> = []\n const seenCssFiles = new Set<string>()\n\n for (const auxFile of chunk.auxiliaryFiles) {\n if (auxFile.endsWith('.css') && !seenCssFiles.has(auxFile)) {\n seenCssFiles.add(auxFile)\n cssFiles.push(auxFile)\n }\n }\n\n for (const mainFile of chunk.files) {\n if (mainFile.endsWith('.css') && !seenCssFiles.has(mainFile)) {\n seenCssFiles.add(mainFile)\n cssFiles.push(mainFile)\n }\n }\n\n if (cssFiles.length > 0) {\n for (const mod of modules) {\n const sourcePath = mod.nameForCondition()\n if (!sourcePath) continue\n\n const existing = cssFilesBySourcePath.get(sourcePath)\n cssFilesBySourcePath.set(\n sourcePath,\n existing ? appendUniqueStrings(existing, cssFiles) : cssFiles.slice(),\n )\n }\n }\n\n // The entry chunk is the one named 'index' in the 'index' entrypoint\n const isEntryChunk = chunk.name === 'index' && entryChunkSet.has(chunk)\n\n const jsFiles = getChunkJsFiles(chunk)\n if (jsFiles.length === 0) continue\n\n // Compute dynamicImports from chunk group children\n const dynamicImports = computeDynamicImports(chunk)\n\n for (const file of jsFiles) {\n // For the entry chunk, `imports` contains all sibling initial chunks\n // (vendor/shared). For async chunks, `imports` contains all sibling\n // chunks from the ChunkGroup (shared dependencies the browser must\n // load alongside this chunk). This mirrors Rollup's\n // OutputChunk.imports which lists statically imported chunks.\n const imports = isEntryChunk\n ? initialJsFileNames.filter((f) => f !== file)\n : computeAsyncChunkImports(chunk, file)\n\n const normalizedChunk: NormalizedClientChunk = {\n fileName: file,\n isEntry: isEntryChunk,\n imports,\n dynamicImports,\n css: [],\n routeFilePaths,\n }\n\n chunksByFileName.set(file, normalizedChunk)\n\n if (isEntryChunk && !entryChunkFileName) {\n entryChunkFileName = file\n }\n\n for (const routeFilePath of routeFilePaths) {\n let chunkFileNames = chunkFileNamesByRouteFilePath.get(routeFilePath)\n if (!chunkFileNames) {\n chunkFileNames = []\n chunkFileNamesByRouteFilePath.set(routeFilePath, chunkFileNames)\n }\n chunkFileNames.push(file)\n }\n }\n\n for (const cssFile of cssFiles) {\n for (const file of jsFiles) {\n const existing = chunksByFileName.get(file)\n if (existing && !existing.css.includes(cssFile)) {\n existing.css.push(cssFile)\n }\n }\n }\n }\n\n if (!entryChunkFileName) {\n throw new Error('No entry file found in rspack client build')\n }\n\n // In RSC mode, CSS from server components is associated with the 'rsc'\n // client entry chunk (not the main 'index' entry). The manifest builder\n // merges the entry chunk's CSS into __root__, so by appending RSC CSS\n // to the entry chunk, those stylesheets get loaded on all pages.\n // CSS may appear in either `files` or `auxiliaryFiles` depending on\n // rspack's CSS extraction strategy.\n const rscEntrypoint = compilation.entrypoints.get('rsc')\n\n if (rscEntrypoint && entryChunkFileName) {\n const mainEntryChunk = chunksByFileName.get(entryChunkFileName)\n if (mainEntryChunk) {\n for (const rscChunk of rscEntrypoint.chunks) {\n const allFiles = [...rscChunk.files, ...rscChunk.auxiliaryFiles]\n for (const file of allFiles) {\n if (file.endsWith('.css') && !mainEntryChunk.css.includes(file)) {\n mainEntryChunk.css.push(file)\n }\n }\n }\n }\n }\n\n return {\n entryChunkFileName,\n chunksByFileName,\n chunkFileNamesByRouteFilePath,\n cssFilesBySourcePath,\n }\n}\n\nfunction appendUniqueStrings(\n target: Array<string>,\n source: Array<string>,\n): Array<string> {\n const seen = new Set(target)\n let result: Array<string> | undefined\n\n for (const value of source) {\n if (seen.has(value)) continue\n seen.add(value)\n if (!result) {\n result = target.slice()\n }\n result.push(value)\n }\n\n return result ?? target\n}\n\n/**\n * Registers a processAssets hook to capture the client build stats\n * after compilation. Returns a getter for the captured build.\n */\nexport function registerClientBuildCapture(api: RsbuildPluginAPI): {\n getClientBuild: () => NormalizedClientBuild | undefined\n} {\n let clientBuild: NormalizedClientBuild | undefined\n\n api.processAssets(\n {\n stage: 'report',\n environments: [RSBUILD_ENVIRONMENT_NAMES.client],\n },\n (context: ProcessAssetsContext) => {\n clientBuild = normalizeRspackClientBuild(context.compilation)\n },\n )\n\n return {\n getClientBuild: () => clientBuild,\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAS,6BACP,SACe;CACf,IAAI;CACJ,IAAI;AAEJ,MAAK,MAAM,OAAO,SAAS;EACzB,MAAM,aAAa,IAAI,YAAY;EAKnC,MAAM,gBAAgB,WAAW,YAAY,IAAI;EACjD,MAAM,eACJ,iBAAiB,IAAI,WAAW,MAAM,gBAAgB,EAAE,GAAG;EAE7D,MAAM,aAAa,aAAa,QAAQ,IAAI;AAC5C,MAAI,aAAa,EAAG;EAEpB,MAAM,QAAQ,aAAa,MAAM,aAAa,EAAE;AAChD,MAAI,CAAC,MAAM,SAAS,SAAS,CAAE;AAC/B,MAAI,CAAC,IAAI,gBAAgB,MAAM,CAAC,IAAI,SAAS,CAAE;EAG/C,MAAM,gBADmB,IAAI,kBAAkB,IACL,aAAa,MAAM,GAAG,WAAW;AAE3E,MAAI,MAAM,IAAI,cAAc,CAAE;AAE9B,MAAI,CAAC,kBAAkB,CAAC,MAAM;AAC5B,oBAAiB,EAAE;AACnB,0BAAO,IAAI,KAAK;;AAGlB,iBAAe,KAAK,cAAc;AAClC,OAAK,IAAI,cAAc;;AAGzB,QAAO,kBAAkB,EAAE;;;;;;;;AAS7B,SAAS,iBAAiB,MAAuB;AAC/C,QAAO,KAAK,SAAS,eAAe;;;;;;AAOtC,SAAS,kBAAkB,MAAuB;AAChD,KAAI,CAAC,KAAK,SAAS,MAA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AAQ,YAAY;GAEhE;AAED,QAAO,EACL,sBAAsB,aACvB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ENTRY_POINTS } from '../constants.js';
|
|
2
|
+
import { EnvironmentConfig } from '@rsbuild/core';
|
|
3
|
+
import { ResolvedStartEntryPlan } from '../planning.js';
|
|
4
|
+
import { RsbuildEnvironmentOverrides } from './types.js';
|
|
5
|
+
export declare const RSBUILD_ENVIRONMENT_NAMES: {
|
|
6
|
+
readonly client: "client";
|
|
7
|
+
readonly server: "ssr";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Rspack layer names for the rsbuild RSC layered model.
|
|
11
|
+
* These match the canonical names from `rspack.experiments.rsc.Layers`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const RSBUILD_RSC_LAYERS: {
|
|
14
|
+
/** React Server Components layer — uses `react-server` resolve condition */
|
|
15
|
+
readonly rsc: "react-server-components";
|
|
16
|
+
/** Server-Side Rendering layer — standard Node resolve */
|
|
17
|
+
readonly ssr: "server-side-rendering";
|
|
18
|
+
};
|
|
19
|
+
export type RsbuildEnvironmentName = (typeof RSBUILD_ENVIRONMENT_NAMES)[keyof typeof RSBUILD_ENVIRONMENT_NAMES];
|
|
20
|
+
type RsbuildDistPath = NonNullable<EnvironmentConfig['output']>['distPath'];
|
|
21
|
+
export interface RsbuildResolvedEntryAliases {
|
|
22
|
+
client: string;
|
|
23
|
+
server: string;
|
|
24
|
+
start: string;
|
|
25
|
+
router: string;
|
|
26
|
+
alias: Record<(typeof ENTRY_POINTS)[keyof typeof ENTRY_POINTS], string>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createRsbuildResolvedEntryAliases(opts: {
|
|
29
|
+
entryPaths: ResolvedStartEntryPlan['entryPaths'];
|
|
30
|
+
}): RsbuildResolvedEntryAliases;
|
|
31
|
+
export interface RsbuildEnvironmentPlanResult {
|
|
32
|
+
environments: Record<string, EnvironmentConfig>;
|
|
33
|
+
alias: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
export declare function createRsbuildEnvironmentPlan(opts: {
|
|
36
|
+
root: string;
|
|
37
|
+
entryAliases: RsbuildResolvedEntryAliases;
|
|
38
|
+
clientOutputDirectory: string;
|
|
39
|
+
serverOutputDirectory: string;
|
|
40
|
+
publicBase: string;
|
|
41
|
+
serverFnProviderEnv: string;
|
|
42
|
+
environmentOverrides?: RsbuildEnvironmentOverrides;
|
|
43
|
+
rsc?: boolean | undefined;
|
|
44
|
+
dev?: boolean | undefined;
|
|
45
|
+
}): RsbuildEnvironmentPlanResult;
|
|
46
|
+
export declare function resolveRsbuildOutputDirectory(opts: {
|
|
47
|
+
distPath: RsbuildDistPath | undefined;
|
|
48
|
+
rootDistPath: RsbuildDistPath | undefined;
|
|
49
|
+
fallback: string;
|
|
50
|
+
subdirectory: string;
|
|
51
|
+
}): string;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ENTRY_POINTS } from "../constants.js";
|
|
2
|
+
import { join } from "pathe";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
5
|
+
//#region src/rsbuild/planning.ts
|
|
6
|
+
var require = createRequire(import.meta.url);
|
|
7
|
+
var RSBUILD_ENVIRONMENT_NAMES = {
|
|
8
|
+
client: "client",
|
|
9
|
+
server: "ssr"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Rspack layer names for the rsbuild RSC layered model.
|
|
13
|
+
* These match the canonical names from `rspack.experiments.rsc.Layers`.
|
|
14
|
+
*/
|
|
15
|
+
var RSBUILD_RSC_LAYERS = {
|
|
16
|
+
rsc: "react-server-components",
|
|
17
|
+
ssr: "server-side-rendering"
|
|
18
|
+
};
|
|
19
|
+
function createRsbuildResolvedEntryAliases(opts) {
|
|
20
|
+
const client = normalizeEntryPath(opts.entryPaths.client);
|
|
21
|
+
const server = normalizeEntryPath(opts.entryPaths.server);
|
|
22
|
+
const start = normalizeEntryPath(opts.entryPaths.start);
|
|
23
|
+
const router = normalizeEntryPath(opts.entryPaths.router);
|
|
24
|
+
return {
|
|
25
|
+
client,
|
|
26
|
+
server,
|
|
27
|
+
start,
|
|
28
|
+
router,
|
|
29
|
+
alias: {
|
|
30
|
+
[ENTRY_POINTS.client]: client,
|
|
31
|
+
[ENTRY_POINTS.server]: server,
|
|
32
|
+
[ENTRY_POINTS.start]: start,
|
|
33
|
+
[ENTRY_POINTS.router]: router
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function createRsbuildEnvironmentPlan(opts) {
|
|
38
|
+
const alias = {
|
|
39
|
+
...opts.entryAliases.alias,
|
|
40
|
+
...opts.rsc ? { "react-server-dom-rspack/server$": resolveFromRoot("react-server-dom-rspack/server.node", opts.root) } : {}
|
|
41
|
+
};
|
|
42
|
+
const environmentOverrides = opts.environmentOverrides ?? {};
|
|
43
|
+
return {
|
|
44
|
+
environments: {
|
|
45
|
+
[RSBUILD_ENVIRONMENT_NAMES.client]: mergeRsbuildConfig({
|
|
46
|
+
source: { entry: { index: {
|
|
47
|
+
import: opts.entryAliases.client,
|
|
48
|
+
html: false
|
|
49
|
+
} } },
|
|
50
|
+
output: {
|
|
51
|
+
target: "web",
|
|
52
|
+
module: true,
|
|
53
|
+
distPath: { root: opts.clientOutputDirectory },
|
|
54
|
+
assetPrefix: opts.publicBase
|
|
55
|
+
},
|
|
56
|
+
resolve: { alias },
|
|
57
|
+
performance: { chunkSplit: {
|
|
58
|
+
strategy: "custom",
|
|
59
|
+
override: { chunks: "async" }
|
|
60
|
+
} }
|
|
61
|
+
}, environmentOverrides.all, environmentOverrides.client),
|
|
62
|
+
[RSBUILD_ENVIRONMENT_NAMES.server]: mergeRsbuildConfig({
|
|
63
|
+
source: { entry: { index: {
|
|
64
|
+
import: opts.entryAliases.server,
|
|
65
|
+
html: false,
|
|
66
|
+
...opts.rsc ? { layer: RSBUILD_RSC_LAYERS.ssr } : {}
|
|
67
|
+
} } },
|
|
68
|
+
output: {
|
|
69
|
+
target: "node",
|
|
70
|
+
...opts.dev ? { module: false } : {},
|
|
71
|
+
distPath: { root: opts.serverOutputDirectory }
|
|
72
|
+
},
|
|
73
|
+
resolve: { alias },
|
|
74
|
+
...opts.rsc ? { splitChunks: { preset: "single-vendor" } } : {}
|
|
75
|
+
}, environmentOverrides.all, environmentOverrides.server),
|
|
76
|
+
...opts.serverFnProviderEnv !== RSBUILD_ENVIRONMENT_NAMES.server && !opts.rsc ? { [opts.serverFnProviderEnv]: mergeRsbuildConfig({
|
|
77
|
+
source: { entry: { index: {
|
|
78
|
+
import: opts.entryAliases.server,
|
|
79
|
+
html: false
|
|
80
|
+
} } },
|
|
81
|
+
output: {
|
|
82
|
+
target: "node",
|
|
83
|
+
...opts.dev ? { module: false } : {},
|
|
84
|
+
distPath: { root: `${opts.serverOutputDirectory}/${opts.serverFnProviderEnv}` }
|
|
85
|
+
},
|
|
86
|
+
resolve: { alias }
|
|
87
|
+
}, environmentOverrides.all, environmentOverrides.provider) } : {}
|
|
88
|
+
},
|
|
89
|
+
alias
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function resolveRsbuildOutputDirectory(opts) {
|
|
93
|
+
if (typeof opts.distPath === "string") return opts.distPath;
|
|
94
|
+
if (typeof opts.distPath?.root === "string") return opts.distPath.root;
|
|
95
|
+
if (typeof opts.rootDistPath === "string") return join(opts.rootDistPath, opts.subdirectory);
|
|
96
|
+
if (typeof opts.rootDistPath?.root === "string") return join(opts.rootDistPath.root, opts.subdirectory);
|
|
97
|
+
return opts.fallback;
|
|
98
|
+
}
|
|
99
|
+
function normalizeEntryPath(path) {
|
|
100
|
+
return path.replaceAll("\\", "/");
|
|
101
|
+
}
|
|
102
|
+
function resolveFromRoot(specifier, root) {
|
|
103
|
+
return require.resolve(specifier, { paths: [root] });
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { RSBUILD_ENVIRONMENT_NAMES, RSBUILD_RSC_LAYERS, createRsbuildEnvironmentPlan, createRsbuildResolvedEntryAliases, resolveRsbuildOutputDirectory };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=planning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning.js","names":[],"sources":["../../../src/rsbuild/planning.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { join } from 'pathe'\nimport { mergeRsbuildConfig } from '@rsbuild/core'\nimport { ENTRY_POINTS } from '../constants'\nimport type { EnvironmentConfig } from '@rsbuild/core'\nimport type { ResolvedStartEntryPlan } from '../planning'\nimport type { RsbuildEnvironmentOverrides } from './types'\n\nconst require = createRequire(import.meta.url)\n\nexport const RSBUILD_ENVIRONMENT_NAMES = {\n client: 'client',\n server: 'ssr',\n} as const\n\n/**\n * Rspack layer names for the rsbuild RSC layered model.\n * These match the canonical names from `rspack.experiments.rsc.Layers`.\n */\nexport const RSBUILD_RSC_LAYERS = {\n /** React Server Components layer — uses `react-server` resolve condition */\n rsc: 'react-server-components',\n /** Server-Side Rendering layer — standard Node resolve */\n ssr: 'server-side-rendering',\n} as const\n\nexport type RsbuildEnvironmentName =\n (typeof RSBUILD_ENVIRONMENT_NAMES)[keyof typeof RSBUILD_ENVIRONMENT_NAMES]\n\ntype RsbuildDistPath = NonNullable<EnvironmentConfig['output']>['distPath']\n\nexport interface RsbuildResolvedEntryAliases {\n client: string\n server: string\n start: string\n router: string\n alias: Record<(typeof ENTRY_POINTS)[keyof typeof ENTRY_POINTS], string>\n}\n\nexport function createRsbuildResolvedEntryAliases(opts: {\n entryPaths: ResolvedStartEntryPlan['entryPaths']\n}): RsbuildResolvedEntryAliases {\n const client = normalizeEntryPath(opts.entryPaths.client)\n const server = normalizeEntryPath(opts.entryPaths.server)\n const start = normalizeEntryPath(opts.entryPaths.start)\n const router = normalizeEntryPath(opts.entryPaths.router)\n\n return {\n client,\n server,\n start,\n router,\n alias: {\n [ENTRY_POINTS.client]: client,\n [ENTRY_POINTS.server]: server,\n [ENTRY_POINTS.start]: start,\n [ENTRY_POINTS.router]: router,\n },\n }\n}\n\nexport interface RsbuildEnvironmentPlanResult {\n environments: Record<string, EnvironmentConfig>\n alias: Record<string, string>\n}\n\nexport function createRsbuildEnvironmentPlan(opts: {\n root: string\n entryAliases: RsbuildResolvedEntryAliases\n clientOutputDirectory: string\n serverOutputDirectory: string\n publicBase: string\n serverFnProviderEnv: string\n environmentOverrides?: RsbuildEnvironmentOverrides\n rsc?: boolean | undefined\n dev?: boolean | undefined\n}): RsbuildEnvironmentPlanResult {\n const alias = {\n ...opts.entryAliases.alias,\n ...(opts.rsc\n ? {\n 'react-server-dom-rspack/server$': resolveFromRoot(\n 'react-server-dom-rspack/server.node',\n opts.root,\n ),\n }\n : {}),\n }\n const environmentOverrides = opts.environmentOverrides ?? {}\n\n return {\n environments: {\n [RSBUILD_ENVIRONMENT_NAMES.client]: mergeRsbuildConfig(\n {\n source: {\n entry: {\n index: {\n import: opts.entryAliases.client,\n html: false,\n },\n },\n },\n output: {\n target: 'web',\n module: true,\n distPath: {\n root: opts.clientOutputDirectory,\n },\n assetPrefix: opts.publicBase,\n },\n resolve: {\n alias,\n },\n // Only split async chunks (route code-splitting). Keep all initial\n // vendor/shared code inlined in the entry chunk so the SSR HTML only\n // needs the single client entry bootstrap.\n performance: {\n chunkSplit: {\n strategy: 'custom',\n override: {\n chunks: 'async',\n },\n },\n },\n },\n environmentOverrides.all,\n environmentOverrides.client,\n ),\n [RSBUILD_ENVIRONMENT_NAMES.server]: mergeRsbuildConfig(\n {\n source: {\n entry: {\n index: {\n import: opts.entryAliases.server,\n html: false,\n ...(opts.rsc ? { layer: RSBUILD_RSC_LAYERS.ssr } : {}),\n },\n },\n },\n output: {\n target: 'node',\n // Rsbuild's dev `loadBundle()` path evaluates ESM via vm.SourceTextModule,\n // which requires `--experimental-vm-modules`. Emit CJS for the dev\n // server bundle so SSR works without extra Node flags.\n ...(opts.dev ? { module: false } : {}),\n distPath: {\n root: opts.serverOutputDirectory,\n },\n },\n resolve: {\n alias,\n },\n ...(opts.rsc\n ? {\n splitChunks: {\n preset: 'single-vendor',\n },\n }\n : {}),\n },\n environmentOverrides.all,\n environmentOverrides.server,\n ),\n // When provider is a separate environment (not layered RSC),\n // create a third environment. With the layered RSC setup this branch\n // is not taken because provider maps to the same `ssr` environment.\n ...(opts.serverFnProviderEnv !== RSBUILD_ENVIRONMENT_NAMES.server &&\n !opts.rsc\n ? {\n [opts.serverFnProviderEnv]: mergeRsbuildConfig(\n {\n source: {\n entry: {\n index: {\n import: opts.entryAliases.server,\n html: false,\n },\n },\n },\n output: {\n target: 'node',\n ...(opts.dev ? { module: false } : {}),\n distPath: {\n root: `${opts.serverOutputDirectory}/${opts.serverFnProviderEnv}`,\n },\n },\n resolve: {\n alias,\n },\n },\n environmentOverrides.all,\n environmentOverrides.provider,\n ),\n }\n : {}),\n },\n alias,\n }\n}\n\nexport function resolveRsbuildOutputDirectory(opts: {\n distPath: RsbuildDistPath | undefined\n rootDistPath: RsbuildDistPath | undefined\n fallback: string\n subdirectory: string\n}): string {\n if (typeof opts.distPath === 'string') {\n return opts.distPath\n }\n\n if (typeof opts.distPath?.root === 'string') {\n return opts.distPath.root\n }\n\n if (typeof opts.rootDistPath === 'string') {\n return join(opts.rootDistPath, opts.subdirectory)\n }\n\n if (typeof opts.rootDistPath?.root === 'string') {\n return join(opts.rootDistPath.root, opts.subdirectory)\n }\n\n return opts.fallback\n}\n\nfunction normalizeEntryPath(path: string) {\n return path.replaceAll('\\\\', '/')\n}\n\nfunction resolveFromRoot(specifier: string, root: string): string {\n return require.resolve(specifier, {\n paths: [root],\n })\n}\n"],"mappings":";;;;;AAQA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAa,4BAA4B;CACvC,QAAQ;CACR,QAAQ;CACT;;;;;AAMD,IAAa,qBAAqB;CAEhC,KAAK;CAEL,KAAK;CACN;AAeD,SAAgB,kCAAkC,MAElB;CAC9B,MAAM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ACP,EACD,qBAAqB,KACrB,qBAAqB,OACtB;GAID,GAAI,KAAK,wBAAwB,0BAA0B,UAC3D,CAAC,KAAK,MACF,GACG,KAAK,sBAAsB,mBAC1B;IACE,QAAQ,EACN,OAAO,EACL,OAAO;KACL,QAAQ,KAAK,aAAa;KAC1B,MAAM;KACP,EACF,EACF;IACD,QAAQ;KACN,QAAQ;KACR,GAAI,KAAK,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE;KACrC,UAAU,EACR,MAAM,GAAG,KAAK,sBAAsB,GAAG,KAAK,uBAC7C;KACF;IACD,SAAS,EACP,OACD;IACF,EACD,qBAAqB,KACrB,qBAAqB,SACtB,EACF,GACD,EAAE;GACP;EACD;EACD;;AAGH,SAAgB,8BAA8B,MAKnC;AACT,KAAI,OAAO,KAAK,aAAa,SAC3B,QAAO,KAAK;AAGd,KAAI,OAAO,KAAK,UAAU,SAAS,SACjC,QAAO,KAAK,SAAS;AAGvB,KAAI,OAAO,KAAK,iBAAiB,SAC/B,QAAO,KAAK,KAAK,cAAc,KAAK,aAAa;AAGnD,KAAI,OAAO,KAAK,cAAc,SAAS,SACrC,QAAO,KAAK,KAAK,aAAa,MAAM,KAAK,aAAa;AAGxD,QAAO,KAAK;;AAGd,SAAS,mBAAmB,MAAc;AACxC,QAAO,KAAK,WAAW,MAAM,IAAI;;AAGnC,SAAS,gBAAgB,WAAmB,MAAsB;AAChE,QAAO,QAAQ,QAAQ,WAAW,EAChC,OAAO,CAAC,KAAK,EACd,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TanStackStartRsbuildPluginCoreOptions } from './types.js';
|
|
2
|
+
import { RsbuildPlugin } from '@rsbuild/core';
|
|
3
|
+
import { TanStackStartRsbuildInputConfig } from './schema.js';
|
|
4
|
+
export declare function tanStackStartRsbuild(corePluginOpts: TanStackStartRsbuildPluginCoreOptions, startPluginOpts?: TanStackStartRsbuildInputConfig): RsbuildPlugin;
|