rsbuild-plugin-react-router 0.4.1 → 0.6.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.
Files changed (126) hide show
  1. package/README.md +72 -240
  2. package/dist/{451.js → 511.js} +461 -331
  3. package/dist/build-output-transforms.d.ts +32 -7
  4. package/dist/classic-mode.d.ts +56 -0
  5. package/dist/config-imports.d.ts +8 -2
  6. package/dist/constants.d.ts +3 -0
  7. package/dist/dev-background-resources.d.ts +3 -3
  8. package/dist/dev-generation.d.ts +2 -3
  9. package/dist/dev-hmr.d.ts +8 -2
  10. package/dist/dev-runtime-controller.d.ts +6 -1
  11. package/dist/dev-source-maps.d.ts +4 -0
  12. package/dist/effect-runtime.d.ts +17 -5
  13. package/dist/entry-paths.d.ts +16 -0
  14. package/dist/environment-output.d.ts +6 -0
  15. package/dist/export-utils.d.ts +2 -1
  16. package/dist/federation.d.ts +2 -0
  17. package/dist/index.cjs +3675 -2107
  18. package/dist/index.d.ts +3 -1
  19. package/dist/index.js +3614 -2214
  20. package/dist/lazy-compilation-prewarm.d.ts +8 -5
  21. package/dist/manifest.d.ts +16 -4
  22. package/dist/mode-plan.d.ts +82 -0
  23. package/dist/modify-browser-manifest.d.ts +8 -4
  24. package/dist/performance.d.ts +4 -1
  25. package/dist/plugin-utils.d.ts +27 -1
  26. package/dist/prerender-build.d.ts +5 -5
  27. package/dist/prerender.d.ts +1 -5
  28. package/dist/react-router-config.d.ts +11 -3
  29. package/dist/route-artifacts.d.ts +4 -2
  30. package/dist/route-chunks.d.ts +2 -1
  31. package/dist/route-component-transform.d.ts +0 -2
  32. package/dist/route-export-pruning.d.ts +4 -1
  33. package/dist/route-imports.d.ts +18 -0
  34. package/dist/route-module-transform-loader.d.ts +14 -0
  35. package/dist/route-module-transform-loader.js +44 -0
  36. package/dist/route-module-transform-rules.d.ts +14 -0
  37. package/dist/route-transform-tasks.d.ts +6 -0
  38. package/dist/route-watch.d.ts +11 -6
  39. package/dist/rsc-dev-server.d.ts +26 -0
  40. package/dist/rsc-prerender.d.ts +54 -0
  41. package/dist/rsc-route-config.d.ts +6 -0
  42. package/dist/rsc-route-exports.d.ts +15 -0
  43. package/dist/rsc-route-transform-loader.cjs +43 -0
  44. package/dist/rsc-route-transform-loader.d.ts +30 -0
  45. package/dist/rsc-route-transform-loader.js +16 -0
  46. package/dist/rsc-route-transform-registration.d.ts +12 -0
  47. package/dist/rsc-route-transforms.d.ts +21 -0
  48. package/dist/rsc-support.d.ts +23 -0
  49. package/dist/rsc-virtual-modules.d.ts +19 -0
  50. package/dist/server-build-plan.d.ts +2 -1
  51. package/dist/server-build-resolution.d.ts +1 -2
  52. package/dist/server-utils.d.ts +4 -5
  53. package/dist/ssr-asset-relocation.d.ts +98 -0
  54. package/dist/templates/entry.rsc.client.d.ts +1 -0
  55. package/dist/templates/entry.rsc.client.js +61 -0
  56. package/dist/templates/entry.rsc.d.ts +9 -0
  57. package/dist/templates/entry.rsc.js +38 -0
  58. package/dist/templates/entry.rsc.ssr.d.ts +4 -0
  59. package/dist/templates/entry.rsc.ssr.js +24 -0
  60. package/dist/typegen.d.ts +4 -2
  61. package/dist/types.d.ts +34 -6
  62. package/package.json +76 -22
  63. package/src/build-output-transforms.ts +181 -43
  64. package/src/classic-mode.ts +253 -0
  65. package/src/config-imports.ts +153 -6
  66. package/src/constants.ts +6 -2
  67. package/src/dev-background-resources.ts +46 -100
  68. package/src/dev-generation.ts +52 -33
  69. package/src/dev-hmr.ts +112 -80
  70. package/src/dev-runtime-artifacts.ts +11 -12
  71. package/src/dev-runtime-controller.ts +75 -85
  72. package/src/dev-runtime-session.ts +14 -18
  73. package/src/dev-server.ts +2 -0
  74. package/src/dev-source-maps.ts +257 -0
  75. package/src/effect-runtime.ts +105 -57
  76. package/src/entry-paths.ts +80 -0
  77. package/src/environment-output.ts +55 -0
  78. package/src/export-utils.ts +15 -11
  79. package/src/federation.ts +38 -0
  80. package/src/index.ts +666 -519
  81. package/src/lazy-compilation-prewarm.ts +20 -4
  82. package/src/manifest.ts +157 -82
  83. package/src/mode-plan.ts +367 -0
  84. package/src/modify-browser-manifest.ts +130 -124
  85. package/src/performance.ts +11 -2
  86. package/src/plugin-utils.ts +103 -39
  87. package/src/prerender-build.ts +82 -104
  88. package/src/prerender.ts +23 -24
  89. package/src/react-router-config.ts +72 -26
  90. package/src/route-artifacts.ts +96 -66
  91. package/src/route-chunks.ts +167 -51
  92. package/src/route-component-transform.ts +14 -21
  93. package/src/route-export-pruning.ts +4 -3
  94. package/src/route-imports.ts +100 -0
  95. package/src/route-module-transform-loader.ts +149 -0
  96. package/src/route-module-transform-rules.ts +115 -0
  97. package/src/route-transform-tasks.ts +44 -29
  98. package/src/route-watch.ts +166 -188
  99. package/src/rsc-dev-server.ts +112 -0
  100. package/src/rsc-prerender.ts +362 -0
  101. package/src/rsc-route-config.ts +175 -0
  102. package/src/rsc-route-exports.ts +67 -0
  103. package/src/rsc-route-transform-loader.ts +65 -0
  104. package/src/rsc-route-transform-registration.ts +145 -0
  105. package/src/rsc-route-transforms.ts +995 -0
  106. package/src/rsc-runtime.d.ts +143 -0
  107. package/src/rsc-support.ts +116 -0
  108. package/src/rsc-virtual-modules.ts +113 -0
  109. package/src/server-build-plan.ts +14 -3
  110. package/src/server-build-resolution.ts +37 -47
  111. package/src/server-utils.ts +21 -35
  112. package/src/ssr-asset-relocation.ts +183 -0
  113. package/src/ssr-externals.ts +8 -26
  114. package/src/templates/entry.rsc.client.tsx +168 -0
  115. package/src/templates/entry.rsc.ssr.tsx +45 -0
  116. package/src/templates/entry.rsc.tsx +80 -0
  117. package/src/typegen.ts +40 -23
  118. package/src/types.ts +43 -6
  119. package/src/warnings/warn-on-client-source-maps.ts +6 -10
  120. package/dist/parallel-route-transform-protocol.d.ts +0 -25
  121. package/dist/parallel-route-transform-worker.d.ts +0 -1
  122. package/dist/parallel-route-transform-worker.js +0 -38
  123. package/dist/parallel-route-transforms.d.ts +0 -29
  124. package/src/parallel-route-transform-protocol.ts +0 -35
  125. package/src/parallel-route-transform-worker.ts +0 -82
  126. package/src/parallel-route-transforms.ts +0 -458
@@ -1,10 +1,31 @@
1
1
  import type { RsbuildPluginAPI } from '@rsbuild/core';
2
- import { getReactRouterManifestForDev, type ReactRouterManifestStats } from './manifest.js';
3
- import type { RouteTransformExecutor } from './parallel-route-transforms.js';
2
+ import { type ReactRouterManifestForDev as ReactRouterManifest, type RouteChunkManifestOptions, type RouteModuleAnalysisProvider, type ReactRouterManifestStats } from './manifest.js';
4
3
  import type { ReactRouterPerformanceProfiler } from './performance.js';
5
- import type { RouteChunkConfig } from './route-chunks.js';
4
+ import { type RouteTransformRunner } from './route-transform-tasks.js';
5
+ import { type RouteChunkConfig } from './route-chunks.js';
6
6
  import type { PluginOptions, Route } from './types.js';
7
- type ReactRouterManifest = Awaited<ReturnType<typeof getReactRouterManifestForDev>>;
7
+ import { type RouteModuleAnalysis } from './export-utils.js';
8
+ /**
9
+ * Register the node-compilation hook that relocates server-only static assets
10
+ * (`?url` imports, `.css?url` files, and other `asset/resource` outputs
11
+ * referenced only by loaders or `.server` modules) into the client build. The
12
+ * loader/`links()` export returns the asset URL to the client, which fetches it
13
+ * from `build/client` at runtime, so the file must exist there even though only
14
+ * the node compilation referenced it. The assets are also stripped from the
15
+ * server build to avoid shipping duplicate static files, mirroring upstream
16
+ * React Router's Vite plugin. This runs for every node compilation, so it also
17
+ * covers `serverBundles` (multiple node outputs) and dev mode (where
18
+ * `writeToDisk` is enabled).
19
+ *
20
+ * Registered by both the classic build-output transforms and the RSC branch so
21
+ * `.css?url`/`?url` assets referenced from `links()` resolve in RSC framework
22
+ * mode too.
23
+ */
24
+ export declare const registerSsrAssetRelocation: ({ api, outputClientPath, performanceProfiler, }: {
25
+ api: RsbuildPluginAPI;
26
+ outputClientPath: string;
27
+ performanceProfiler: ReactRouterPerformanceProfiler;
28
+ }) => void;
8
29
  type RegisterBuildOutputTransformsOptions = {
9
30
  api: RsbuildPluginAPI;
10
31
  resolvedServerOutput: 'module' | 'commonjs';
@@ -16,16 +37,20 @@ type RegisterBuildOutputTransformsOptions = {
16
37
  getClientStats: () => ReactRouterManifestStats | undefined;
17
38
  appDirectory: string;
18
39
  getAssetPrefix: () => string;
19
- routeChunkOptions: Parameters<typeof getReactRouterManifestForDev>[5];
20
- routeTransformExecutor: RouteTransformExecutor;
40
+ routeChunkOptions: RouteChunkManifestOptions | undefined;
41
+ routeModuleAnalysis?: RouteModuleAnalysisProvider;
42
+ routeTransformRunner: RouteTransformRunner;
21
43
  routeByFilePath: Map<string, Route>;
22
44
  routeChunkConfig: RouteChunkConfig;
23
45
  isBuild: boolean;
24
46
  splitRouteModules: boolean;
47
+ useRouteModuleTransformApi: boolean;
25
48
  ssr: boolean;
26
49
  isSpaMode: boolean;
27
50
  rootRoutePath: string;
51
+ outputClientPath: string;
28
52
  isDevHmrEnabled?: () => boolean;
53
+ onRouteModuleAnalysis?: (resourcePath: string, analysis: RouteModuleAnalysis) => void;
29
54
  };
30
- export declare const registerBuildOutputTransforms: ({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions, routeTransformExecutor, routeByFilePath, routeChunkConfig, isBuild, splitRouteModules, ssr, isSpaMode, rootRoutePath, isDevHmrEnabled, }: RegisterBuildOutputTransformsOptions) => void;
55
+ export declare const registerBuildOutputTransforms: ({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions, routeModuleAnalysis, routeTransformRunner, routeByFilePath, routeChunkConfig, isBuild, splitRouteModules, useRouteModuleTransformApi, ssr, isSpaMode, rootRoutePath, outputClientPath, isDevHmrEnabled, onRouteModuleAnalysis, }: RegisterBuildOutputTransformsOptions) => void;
31
56
  export {};
@@ -0,0 +1,56 @@
1
+ import type { RsbuildEntryDescription, RsbuildPluginAPI } from '@rsbuild/core';
2
+ import type { RouteConfigEntry } from '@react-router/dev/routes';
3
+ import { getBuildManifest } from './build-manifest.js';
4
+ import { type DevHmrPlanOptions } from './dev-hmr.js';
5
+ import { type ReactRouterDevRuntimeController } from './dev-runtime-controller.js';
6
+ import { type ReactRouterServerBundleEntry } from './server-build-plan.js';
7
+ import type { Config } from './react-router-config.js';
8
+ import type { Route } from './types.js';
9
+ type CreateClassicWebRouteEntriesOptions = {
10
+ appDirectory: string;
11
+ isBuild: boolean;
12
+ routes: Record<string, Route>;
13
+ splitRouteModules: boolean;
14
+ };
15
+ type CreateClassicVirtualModulesOptions = {
16
+ allowedActionOrigins: string[] | undefined;
17
+ appDirectory: string;
18
+ assetsBuildDirectory: string;
19
+ basename: string;
20
+ devHmrRuntimeModule?: string;
21
+ entryServerPath: string;
22
+ future: Config['future'];
23
+ isSpaMode: boolean;
24
+ prerenderPaths: string[];
25
+ publicPath: string;
26
+ routeDiscovery: Config['routeDiscovery'];
27
+ routes: Record<string, Route>;
28
+ routesByServerBundleId: Record<string, Record<string, Route>>;
29
+ ssr: boolean;
30
+ };
31
+ type CreateClassicBuildArtifactsOptions = {
32
+ api: RsbuildPluginAPI;
33
+ defaultEntryName: string;
34
+ isBuild: boolean;
35
+ prerenderConfig: Config['prerender'];
36
+ reactRouterConfig: Required<Pick<Config, 'appDirectory' | 'buildDirectory' | 'serverBuildFile' | 'future'>> & Pick<Config, 'serverBundles'>;
37
+ routeConfig: RouteConfigEntry[];
38
+ routes: Record<string, Route>;
39
+ rootDirectory: string;
40
+ ssr: boolean;
41
+ devHmr?: DevHmrPlanOptions;
42
+ };
43
+ export type ClassicBuildArtifacts = {
44
+ buildManifest: Awaited<ReturnType<typeof getBuildManifest>>;
45
+ devRuntime: ReactRouterDevRuntimeController;
46
+ prerenderPaths: string[];
47
+ routesByServerBundleId: Record<string, Record<string, Route>>;
48
+ serverBundleEntries: ReactRouterServerBundleEntry[];
49
+ };
50
+ export declare const createClassicBuildArtifacts: ({ api, defaultEntryName, isBuild, prerenderConfig, reactRouterConfig, routeConfig, routes, rootDirectory, ssr, devHmr, }: CreateClassicBuildArtifactsOptions) => Promise<ClassicBuildArtifacts>;
51
+ export declare const createClassicWebRouteEntries: ({ appDirectory, isBuild, routes, splitRouteModules, }: CreateClassicWebRouteEntriesOptions) => {
52
+ manifestChunkNames: Set<string>;
53
+ webRouteEntries: Record<string, RsbuildEntryDescription>;
54
+ };
55
+ export declare const createClassicVirtualModules: ({ allowedActionOrigins, appDirectory, assetsBuildDirectory, basename, devHmrRuntimeModule, entryServerPath, future, isSpaMode, prerenderPaths, publicPath, routeDiscovery, routes, routesByServerBundleId, ssr, }: CreateClassicVirtualModulesOptions) => Record<string, string>;
56
+ export {};
@@ -1,9 +1,15 @@
1
1
  import type { ModuleCache } from 'jiti';
2
2
  import { createJiti } from 'jiti';
3
- type ConfigImporter = Pick<ReturnType<typeof createJiti>, 'import'>;
3
+ export type ConfigImporter = Pick<ReturnType<typeof createJiti>, 'import'>;
4
+ type ConfigImportOptions = {
5
+ define?: Record<string, unknown>;
6
+ moduleCache?: boolean;
7
+ };
8
+ export declare const applyConfigDefines: (source: string, define: Record<string, unknown> | undefined) => string;
9
+ export declare const createConfigImporter: ({ define, moduleCache, }?: ConfigImportOptions) => ReturnType<typeof createJiti>;
4
10
  export declare const collectConfigImportWatchPaths: (configPath: string, moduleCache: ModuleCache, previousCacheKeys: ReadonlySet<string>) => string[];
5
11
  export declare const clearConfigImportCache: (moduleCache: ModuleCache, filePaths: readonly string[]) => void;
6
- export declare const importConfigWithWatchPaths: <T>(configPath: string, load?: (importer: ConfigImporter) => PromiseLike<T> | T) => Promise<{
12
+ export declare const importConfigWithWatchPaths: <T>(configPath: string, load?: (importer: ConfigImporter) => PromiseLike<T> | T, options?: ConfigImportOptions) => Promise<{
7
13
  value: Awaited<T>;
8
14
  watchPaths: string | string[];
9
15
  }>;
@@ -1,4 +1,6 @@
1
1
  export declare const PLUGIN_NAME = "rsbuild:react-router";
2
+ /** Default web `output.distPath.js` segment when the user has not customized it. */
3
+ export declare const DEFAULT_JS_DIST_PATH = "static/js";
2
4
  export declare const JS_EXTENSIONS: readonly [".tsx", ".ts", ".jsx", ".js", ".mjs", ".mts"];
3
5
  export declare const JS_LOADERS: {
4
6
  readonly '.ts': "ts";
@@ -36,3 +38,4 @@ export declare const CLIENT_EXPORTS: {
36
38
  readonly meta: "meta";
37
39
  readonly shouldRevalidate: "shouldRevalidate";
38
40
  };
41
+ export declare const SPA_FALLBACK_HTML_FILE = "__spa-fallback.html";
@@ -1,14 +1,14 @@
1
1
  import type { RsbuildPluginAPI } from '@rsbuild/core';
2
2
  import type { RouteConfigEntry } from '@react-router/dev/routes';
3
+ import { type PluginEffectRuntime } from './effect-runtime.js';
3
4
  import { type ReactRouterManifestForDev } from './manifest.js';
4
- import type { RouteTransformExecutor } from './parallel-route-transforms.js';
5
5
  import { type WatchFileConfig } from './route-watch.js';
6
6
  import type { PluginOptions } from './types.js';
7
7
  type RegisterReactRouterDevBackgroundResourcesOptions = {
8
8
  api: RsbuildPluginAPI;
9
+ runtime: PluginEffectRuntime;
9
10
  isBuild: boolean;
10
11
  lazyCompilationPrewarm: PluginOptions['unstableLazyCompilationPrewarm'];
11
- routeTransformExecutor: RouteTransformExecutor;
12
12
  routeRestartMarkerPath: string;
13
13
  watchDirectory: string;
14
14
  getRouteTopology: () => Promise<Set<string>>;
@@ -34,5 +34,5 @@ export declare const createReactRouterRouteWatchFiles: ({ configWatchPaths, rout
34
34
  routeRestartMarkerPath: string;
35
35
  onRouteTopologyChange: PluginOptions["onRouteTopologyChange"];
36
36
  }) => WatchFileConfig[];
37
- export declare const registerReactRouterDevBackgroundResources: ({ api, isBuild, lazyCompilationPrewarm, routeTransformExecutor, routeRestartMarkerPath, watchDirectory, getRouteTopology, initialRouteTopology, onRouteTopologyChange, }: RegisterReactRouterDevBackgroundResourcesOptions) => ReactRouterDevBackgroundResources;
37
+ export declare const registerReactRouterDevBackgroundResources: ({ api, runtime, isBuild, lazyCompilationPrewarm, routeRestartMarkerPath, watchDirectory, getRouteTopology, initialRouteTopology, onRouteTopologyChange, }: RegisterReactRouterDevBackgroundResourcesOptions) => Promise<ReactRouterDevBackgroundResources>;
38
38
  export {};
@@ -1,8 +1,7 @@
1
1
  import type { RsbuildDevServer, Rspack } from '@rsbuild/core';
2
2
  import type { ServerBuild } from 'react-router';
3
3
  import { type DevGraphChanges, type DevGraphIdentity, type DevRuntimeStats, type ReactRouterDevBuildPlan, type ReactRouterDevManifestSet } from './dev-runtime-artifacts.js';
4
- export { snapshotDevChangedFiles } from './dev-runtime-artifacts.js';
5
- export type { DevChangedFiles, DevGraphChanges, DevGraphIdentity, ReactRouterDevBuildPlan, ReactRouterDevManifest, ReactRouterDevManifestSet, } from './dev-runtime-artifacts.js';
4
+ export type { DevGraphChanges, DevGraphIdentity, ReactRouterDevManifest, } from './dev-runtime-artifacts.js';
6
5
  export type ReactRouterDevRuntime = {
7
6
  beginAttempt: () => void;
8
7
  captureWeb: (compilation: Rspack.Compilation, manifestsByEntryName: ReactRouterDevManifestSet) => void;
@@ -16,7 +15,7 @@ type CreateReactRouterDevRuntimeOptions = {
16
15
  buildPlan: ReactRouterDevBuildPlan;
17
16
  onEvaluationError: (error: Error) => void;
18
17
  onCssAssetOwnershipChanged?: (change: 'removed' | 'restored') => void;
19
- onRouteManifestChanged?: () => void;
18
+ onRouteManifestChanged?: (manifest: ReactRouterDevManifestSet[string]) => void;
20
19
  onWarning?: (message: string) => void;
21
20
  };
22
21
  export declare const createReactRouterDevRuntime: ({ server, buildPlan, onEvaluationError, onCssAssetOwnershipChanged, onRouteManifestChanged, onWarning, }: CreateReactRouterDevRuntimeOptions) => ReactRouterDevRuntime;
package/dist/dev-hmr.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import type { Rspack } from '@rsbuild/core';
2
2
  export declare const DEV_HMR_RUNTIME_MODULE_ID = "virtual/react-router/hmr-runtime";
3
+ export declare const DEV_MANIFEST_UPDATE_EVENT = "react-router:manifest-update";
4
+ export type DevHmrPlanOptions = {
5
+ isEnabled: () => boolean;
6
+ runtimeModule: string;
7
+ onNodeRebuildCommitted: () => void;
8
+ };
3
9
  export declare const isRspackSwcReactRefreshEnabled: (rspackConfig: Rspack.Configuration) => boolean;
4
10
  /**
5
11
  * Resolves the `react-refresh/runtime` module that
@@ -17,9 +23,9 @@ export declare const resolveReactRefreshRuntimePath: (rootPath: string) => strin
17
23
  * whenever server code changes, which the client answers by revalidating
18
24
  * React Router loader data.
19
25
  */
20
- export declare const DEV_HDR_REVISION_RELATIVE_PATH = ".react-router/hdr-revision.mjs";
21
26
  export declare const getDevHdrRevisionFilePath: (rootPath: string) => string;
22
27
  export type DevHdrRevisionSignal = {
28
+ filePath: string;
23
29
  /** Writes the initial revision module so the first compile can resolve it. */
24
30
  ensure: () => void;
25
31
  /** Increments the revision, signaling hot data revalidation to the client. */
@@ -32,7 +38,7 @@ export declare const createDevHdrRevisionSignal: ({ filePath, onError, }: {
32
38
  /**
33
39
  * Browser-side HMR runtime shared by all route client entries in development.
34
40
  *
35
- * This mirrors React Router's Vite HMR contract (see `refresh-utils.mjs` in
41
+ * This mirrors React Router framework HMR contract (see `refresh-utils.mjs` in
36
42
  * `@react-router/dev`): route module updates are applied by patching
37
43
  * `window.__reactRouterRouteModules` while preserving the previous component
38
44
  * identities (React Fast Refresh swaps their implementations in place),
@@ -9,11 +9,16 @@ type CreateControllerOptions = {
9
9
  api: RsbuildPluginAPI;
10
10
  isBuild: boolean;
11
11
  buildPlan: ReactRouterDevBuildPlan;
12
+ /**
13
+ * The browser HMR runtime patches route manifest metadata (loader/action
14
+ * flags) in place, so metadata-only changes no longer need a full reload.
15
+ */
16
+ clientPatchesRouteMetadata?: boolean | (() => boolean);
12
17
  /**
13
18
  * Invoked after a development attempt commits a re-evaluated node build for
14
19
  * changed server files. Used to signal hot data revalidation to the client.
15
20
  */
16
21
  onNodeRebuildCommitted?: () => void;
17
22
  };
18
- export declare const createReactRouterDevRuntimeController: ({ api, isBuild, buildPlan, onNodeRebuildCommitted, }: CreateControllerOptions) => ReactRouterDevRuntimeController;
23
+ export declare const createReactRouterDevRuntimeController: ({ api, isBuild, buildPlan, clientPatchesRouteMetadata, onNodeRebuildCommitted, }: CreateControllerOptions) => ReactRouterDevRuntimeController;
19
24
  export {};
@@ -0,0 +1,4 @@
1
+ import type { Rspack } from '@rsbuild/core';
2
+ export declare const registerDevServerSourceMaps: (compilation: Pick<Rspack.Compilation, "getAssets" | "outputOptions">) => void;
3
+ export declare const remapDevServerStack: (stack: string) => string;
4
+ export declare const installDevServerSourceMapSupport: () => void;
@@ -1,18 +1,30 @@
1
+ import * as Context from 'effect/Context';
1
2
  import * as Effect from 'effect/Effect';
3
+ import * as FiberSet from 'effect/FiberSet';
4
+ import * as ManagedRuntime from 'effect/ManagedRuntime';
5
+ import * as Scope from 'effect/Scope';
6
+ type PluginResources = {
7
+ readonly scope: Scope.CloseableScope;
8
+ };
9
+ declare const PluginResources: Context.Tag<PluginResources, PluginResources>;
10
+ type PluginRuntimeContext = Scope.Scope | FiberSet.FiberSet | PluginResources;
11
+ export type PluginEffectRuntime = Pick<ManagedRuntime.ManagedRuntime<PluginRuntimeContext, never>, 'runFork' | 'runPromise'> & {
12
+ readonly dispose: () => Promise<void>;
13
+ };
14
+ export declare const createPluginEffectRuntime: () => PluginEffectRuntime;
2
15
  export declare const DEV_BACKGROUND_STARTUP_DELAY_MS = 3000;
3
16
  export declare const normalizeEffectError: (cause: unknown) => Error;
4
17
  export declare const runPluginEffect: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>;
5
- export declare const tryPluginSync: <A>(evaluate: () => A) => Effect.Effect<A, Error, never>;
6
18
  export declare const tryPluginPromise: <A>(evaluate: () => PromiseLike<A> | A) => Effect.Effect<A, Error, never>;
7
19
  type DelayedPluginTask = {
8
20
  schedule(): void;
9
21
  reschedule(): void;
10
- cancelEffect(): Effect.Effect<void, Error, never>;
11
- cancel(): Promise<void>;
22
+ cancelEffect(): Effect.Effect<void>;
12
23
  };
13
- export declare const createDelayedPluginTask: ({ delayMs, run, onError, }: {
24
+ export declare const createDelayedPluginTask: ({ runtime, delayMs, run, onError, }: {
25
+ runtime: PluginEffectRuntime;
14
26
  delayMs: number;
15
- run: () => Effect.Effect<void, Error, never>;
27
+ run: () => Effect.Effect<void, Error, Scope.Scope>;
16
28
  onError: (error: Error) => void;
17
29
  }) => DelayedPluginTask;
18
30
  export {};
@@ -0,0 +1,16 @@
1
+ type ReactRouterEntryPathsOptions = {
2
+ appDirectory: string;
3
+ templatesDirectory: string;
4
+ };
5
+ export type ReactRouterEntryPaths = {
6
+ devServerBuildEntryName: string;
7
+ finalEntryClientPath: string;
8
+ finalEntryRscClientPath: string;
9
+ finalEntryRscPath: string;
10
+ finalEntryRscSsrPath: string;
11
+ finalEntryServerPath: string;
12
+ hasServerApp: boolean;
13
+ serverAppPath: string;
14
+ };
15
+ export declare const resolveReactRouterEntryPaths: ({ appDirectory, templatesDirectory, }: ReactRouterEntryPathsOptions) => ReactRouterEntryPaths;
16
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { RsbuildPluginAPI } from '@rsbuild/core';
2
+ export declare const registerReactRouterEnvironmentOutput: ({ api, federation, resolvedServerOutput, }: {
3
+ api: RsbuildPluginAPI;
4
+ federation: boolean | undefined;
5
+ resolvedServerOutput: "commonjs" | "module";
6
+ }) => void;
@@ -3,7 +3,7 @@ type ExportInfo = {
3
3
  readonly exportNames: readonly string[];
4
4
  readonly exportAllModules: readonly string[];
5
5
  };
6
- type RouteModuleAnalysis = {
6
+ export type RouteModuleAnalysis = {
7
7
  readonly code: string;
8
8
  readonly exports: readonly string[];
9
9
  readonly exportAllModules: readonly string[];
@@ -11,5 +11,6 @@ type RouteModuleAnalysis = {
11
11
  export declare const collectProgramExportNames: (program: ProgramNode) => string[];
12
12
  export declare const getExportNames: (code: string, resourcePath?: string) => Promise<readonly string[]>;
13
13
  export declare const getExportNamesAndExportAll: (code: string, resourcePath?: string) => Promise<ExportInfo>;
14
+ export declare const analyzeRouteModuleCode: (code: string, resourcePath?: string) => RouteModuleAnalysis;
14
15
  export declare const getRouteModuleAnalysis: (resourcePath: string) => Promise<RouteModuleAnalysis>;
15
16
  export {};
@@ -0,0 +1,2 @@
1
+ import type { Rspack } from '@rsbuild/core';
2
+ export declare const ensureFederationAsyncStartup: (rspackConfig: Rspack.Configuration | undefined) => void;