rsbuild-plugin-react-router 0.0.5 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -3
- package/dist/906.js +1 -0
- package/dist/946.js +1 -0
- package/dist/babel.d.ts +2 -2
- package/dist/build-manifest.d.ts +19 -0
- package/dist/constants.d.ts +10 -3
- package/dist/export-utils.d.ts +7 -0
- package/dist/index.cjs +1824 -645
- package/dist/index.js +1594 -483
- package/dist/manifest.d.ts +18 -1
- package/dist/modify-browser-manifest.d.ts +7 -1
- package/dist/plugin-utils.d.ts +2 -0
- package/dist/prerender.d.ts +16 -0
- package/dist/react-router-config.d.ts +51 -0
- package/dist/route-chunks.d.ts +32 -0
- package/dist/route-config.d.ts +13 -0
- package/dist/rslib-runtime.js +23 -0
- package/dist/server-utils.d.ts +22 -6
- package/dist/ssr-externals.d.ts +1 -0
- package/dist/templates/entry.client.cjs +5 -7
- package/dist/templates/entry.client.js +5 -5
- package/dist/templates/entry.server.cjs +7 -6
- package/dist/templates/entry.server.js +10 -11
- package/dist/types.d.ts +6 -0
- package/dist/validation/validate-plugin-order.d.ts +9 -0
- package/dist/warnings/warn-on-client-source-maps.d.ts +6 -0
- package/package.json +46 -47
- package/dist/transform-route-federation.d.ts +0 -6
package/dist/manifest.d.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import type { Route, PluginOptions, RouteManifestItem } from './types.js';
|
|
2
2
|
import type { RouteConfigEntry } from '@react-router/dev/routes';
|
|
3
3
|
import type { Rspack } from '@rsbuild/core';
|
|
4
|
+
import { type RouteChunkCache } from './route-chunks.js';
|
|
4
5
|
export declare function configRoutesToRouteManifest(appDirectory: string, routes: RouteConfigEntry[], rootId?: string): Record<string, Route>;
|
|
5
|
-
|
|
6
|
+
type RouteChunkManifestOptions = {
|
|
7
|
+
splitRouteModules?: boolean | 'enforce';
|
|
8
|
+
rootRouteFile?: string;
|
|
9
|
+
isBuild?: boolean;
|
|
10
|
+
cache?: RouteChunkCache;
|
|
11
|
+
};
|
|
12
|
+
export declare const getReactRouterManifestPath: ({ version, isBuild, entryModulePath, }: {
|
|
13
|
+
version: string;
|
|
14
|
+
isBuild: boolean;
|
|
15
|
+
entryModulePath?: string;
|
|
16
|
+
}) => string;
|
|
17
|
+
export declare function getReactRouterManifestForDev(routes: Record<string, Route>, options: PluginOptions, clientStats: Rspack.StatsCompilation | undefined, context: string, assetPrefix?: string, routeChunkOptions?: RouteChunkManifestOptions): Promise<{
|
|
6
18
|
version: string;
|
|
7
19
|
url: string;
|
|
20
|
+
hmr?: {
|
|
21
|
+
runtime: string;
|
|
22
|
+
};
|
|
8
23
|
entry: {
|
|
9
24
|
module: string;
|
|
10
25
|
imports: string[];
|
|
11
26
|
css: string[];
|
|
12
27
|
};
|
|
28
|
+
sri?: Record<string, string>;
|
|
13
29
|
routes: Record<string, RouteManifestItem>;
|
|
14
30
|
}>;
|
|
31
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Route, PluginOptions } from './types.js';
|
|
2
2
|
import type { Rspack } from '@rsbuild/core';
|
|
3
|
+
import { getReactRouterManifestForDev } from './manifest.js';
|
|
3
4
|
/**
|
|
4
5
|
* Creates a Webpack/Rspack plugin that modifies the browser manifest
|
|
5
6
|
* @param routes - The routes configuration
|
|
@@ -7,6 +8,11 @@ import type { Rspack } from '@rsbuild/core';
|
|
|
7
8
|
* @param appDirectory - The application directory
|
|
8
9
|
* @returns A webpack/rspack plugin
|
|
9
10
|
*/
|
|
10
|
-
export declare function createModifyBrowserManifestPlugin(routes: Record<string, Route>, pluginOptions: PluginOptions, appDirectory: string
|
|
11
|
+
export declare function createModifyBrowserManifestPlugin(routes: Record<string, Route>, pluginOptions: PluginOptions, appDirectory: string, assetPrefix?: string, routeChunkOptions?: Parameters<typeof getReactRouterManifestForDev>[5], options?: {
|
|
12
|
+
future?: {
|
|
13
|
+
unstable_subResourceIntegrity?: boolean;
|
|
14
|
+
};
|
|
15
|
+
onManifest?: (manifest: Awaited<ReturnType<typeof getReactRouterManifestForDev>>, sri: Record<string, string> | undefined) => void;
|
|
16
|
+
}): {
|
|
11
17
|
apply(compiler: Rspack.Compiler): void;
|
|
12
18
|
};
|
package/dist/plugin-utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare function validateDestructuredExports(id: Babel.ArrayPattern | Bab
|
|
|
3
3
|
export declare function invalidDestructureError(name: string): Error;
|
|
4
4
|
export declare function toFunctionExpression(decl: Babel.FunctionDeclaration): any;
|
|
5
5
|
export declare function combineURLs(baseURL: string, relativeURL: string): string;
|
|
6
|
+
export declare function normalizeAssetPrefix(assetPrefix?: string): string;
|
|
6
7
|
export declare function stripFileExtension(file: string): string;
|
|
7
8
|
export declare function createRouteId(file: string): string;
|
|
8
9
|
/**
|
|
@@ -13,4 +14,5 @@ export declare function createRouteId(file: string): string;
|
|
|
13
14
|
export declare function findEntryFile(basePath: string): string;
|
|
14
15
|
export declare function generateWithProps(): string;
|
|
15
16
|
export declare const removeExports: (ast: ParseResult<Babel.File>, exportsToRemove: string[]) => void;
|
|
17
|
+
export declare const removeUnusedImports: (ast: ParseResult<Babel.File>) => void;
|
|
16
18
|
export declare const transformRoute: (ast: ParseResult<Babel.File>) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Config } from './react-router-config.js';
|
|
2
|
+
import type { RouteConfigEntry } from '@react-router/dev/routes';
|
|
3
|
+
type PrerenderConfig = Config['prerender'];
|
|
4
|
+
type PrerenderResolveOptions = {
|
|
5
|
+
logWarning?: boolean;
|
|
6
|
+
warn?: (message: string) => void;
|
|
7
|
+
};
|
|
8
|
+
type StaticPrerenderPaths = {
|
|
9
|
+
paths: string[];
|
|
10
|
+
paramRoutes: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const getStaticPrerenderPaths: (routes: RouteConfigEntry[]) => StaticPrerenderPaths;
|
|
13
|
+
export declare const resolvePrerenderPaths: (prerender: PrerenderConfig, ssr: boolean, routes: RouteConfigEntry[], options?: PrerenderResolveOptions) => Promise<string[]>;
|
|
14
|
+
export declare const getPrerenderConcurrency: (prerender: PrerenderConfig) => number;
|
|
15
|
+
export declare const validatePrerenderConfig: (prerender: PrerenderConfig) => string | null;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BuildManifest as ReactRouterBuildManifest, Config as ReactRouterConfig } from '@react-router/dev/config';
|
|
2
|
+
import type { NormalizedConfig } from '@rsbuild/core';
|
|
3
|
+
import type { RouteConfigEntry } from '@react-router/dev/routes';
|
|
4
|
+
export type BuildEndHook = {
|
|
5
|
+
bivarianceHack(args: {
|
|
6
|
+
buildManifest: ReactRouterBuildManifest | undefined;
|
|
7
|
+
reactRouterConfig: ResolvedReactRouterConfig;
|
|
8
|
+
viteConfig: NormalizedConfig;
|
|
9
|
+
}): void | Promise<void>;
|
|
10
|
+
}['bivarianceHack'];
|
|
11
|
+
export type Config = Omit<ReactRouterConfig, 'buildEnd'> & {
|
|
12
|
+
buildEnd?: BuildEndHook;
|
|
13
|
+
};
|
|
14
|
+
type FutureConfig = {
|
|
15
|
+
unstable_optimizeDeps: boolean;
|
|
16
|
+
unstable_subResourceIntegrity: boolean;
|
|
17
|
+
unstable_trailingSlashAwareDataRequests: boolean;
|
|
18
|
+
v8_middleware: boolean;
|
|
19
|
+
v8_splitRouteModules: boolean | 'enforce';
|
|
20
|
+
v8_viteEnvironmentApi: boolean;
|
|
21
|
+
};
|
|
22
|
+
type RouteManifestEntry = {
|
|
23
|
+
id: string;
|
|
24
|
+
parentId?: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
index?: boolean;
|
|
27
|
+
caseSensitive?: boolean;
|
|
28
|
+
file: string;
|
|
29
|
+
};
|
|
30
|
+
type RouteManifest = Record<string, RouteManifestEntry>;
|
|
31
|
+
export type ResolvedReactRouterConfig = Readonly<{
|
|
32
|
+
appDirectory: string;
|
|
33
|
+
basename: string;
|
|
34
|
+
buildDirectory: string;
|
|
35
|
+
buildEnd?: Config['buildEnd'];
|
|
36
|
+
future: FutureConfig;
|
|
37
|
+
prerender: Config['prerender'];
|
|
38
|
+
routeDiscovery: Config['routeDiscovery'];
|
|
39
|
+
routes: RouteManifest;
|
|
40
|
+
serverBuildFile: NonNullable<ReactRouterConfig['serverBuildFile']>;
|
|
41
|
+
serverBundles?: Config['serverBundles'];
|
|
42
|
+
serverModuleFormat: NonNullable<ReactRouterConfig['serverModuleFormat']>;
|
|
43
|
+
ssr: NonNullable<ReactRouterConfig['ssr']>;
|
|
44
|
+
allowedActionOrigins: string[] | false;
|
|
45
|
+
unstable_routeConfig: RouteConfigEntry[];
|
|
46
|
+
}>;
|
|
47
|
+
export declare const resolveReactRouterConfig: (reactRouterUserConfig: Config) => Promise<{
|
|
48
|
+
resolved: ResolvedReactRouterConfig;
|
|
49
|
+
presets: NonNullable<Config["presets"]>;
|
|
50
|
+
}>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type RouteChunkExportName = 'clientAction' | 'clientLoader' | 'clientMiddleware' | 'HydrateFallback';
|
|
2
|
+
export type RouteChunkName = 'main' | RouteChunkExportName;
|
|
3
|
+
export type RouteChunkConfig = {
|
|
4
|
+
splitRouteModules?: boolean | 'enforce';
|
|
5
|
+
appDirectory: string;
|
|
6
|
+
rootRouteFile: string;
|
|
7
|
+
};
|
|
8
|
+
export type RouteChunkCacheEntry<T> = {
|
|
9
|
+
value: T;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
export type RouteChunkCache = Map<string, RouteChunkCacheEntry<unknown>>;
|
|
13
|
+
export type RouteChunkInfo = {
|
|
14
|
+
hasRouteChunks: boolean;
|
|
15
|
+
hasRouteChunkByExportName: Record<RouteChunkExportName, boolean>;
|
|
16
|
+
chunkedExports: RouteChunkExportName[];
|
|
17
|
+
};
|
|
18
|
+
export declare const routeChunkExportNames: RouteChunkExportName[];
|
|
19
|
+
export declare const routeChunkNames: RouteChunkName[];
|
|
20
|
+
export declare const detectRouteChunks: (code: string, cache: RouteChunkCache | undefined, cacheKey: string) => RouteChunkInfo;
|
|
21
|
+
export declare const getRouteChunkCode: (code: string, chunkName: RouteChunkName, cache: RouteChunkCache | undefined, cacheKey: string) => string | undefined;
|
|
22
|
+
export declare const getRouteChunkModuleId: (filePath: string, chunkName: RouteChunkName) => string;
|
|
23
|
+
export declare const isRouteChunkModuleId: (id: string) => boolean;
|
|
24
|
+
export declare const getRouteChunkNameFromModuleId: (id: string) => RouteChunkName | null;
|
|
25
|
+
export declare const detectRouteChunksIfEnabled: (cache: RouteChunkCache | undefined, config: RouteChunkConfig, id: string, code: string) => Promise<RouteChunkInfo>;
|
|
26
|
+
export declare const getRouteChunkIfEnabled: (cache: RouteChunkCache | undefined, config: RouteChunkConfig, id: string, chunkName: RouteChunkName, code: string) => Promise<string | null>;
|
|
27
|
+
export declare const validateRouteChunks: (args: {
|
|
28
|
+
config: RouteChunkConfig;
|
|
29
|
+
id: string;
|
|
30
|
+
valid: Record<RouteChunkExportName, boolean>;
|
|
31
|
+
}) => void;
|
|
32
|
+
export declare const getRouteChunkEntryName: (routeId: string, chunkName: RouteChunkExportName) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RouteConfigEntry } from '@react-router/dev/routes';
|
|
2
|
+
type ValidationResult = {
|
|
3
|
+
valid: true;
|
|
4
|
+
routeConfig: RouteConfigEntry[];
|
|
5
|
+
} | {
|
|
6
|
+
valid: false;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const validateRouteConfig: ({ routeConfigFile, routeConfig, }: {
|
|
10
|
+
routeConfigFile: string;
|
|
11
|
+
routeConfig: unknown;
|
|
12
|
+
}) => ValidationResult;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __webpack_module_cache__ = {};
|
|
2
|
+
function __webpack_require__(moduleId) {
|
|
3
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
4
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
5
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
6
|
+
exports: {}
|
|
7
|
+
};
|
|
8
|
+
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
9
|
+
}
|
|
10
|
+
__webpack_require__.add = function(modules) {
|
|
11
|
+
Object.assign(__webpack_require__.m, modules);
|
|
12
|
+
}, __webpack_require__.n = (module)=>{
|
|
13
|
+
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
14
|
+
return __webpack_require__.d(getter, {
|
|
15
|
+
a: getter
|
|
16
|
+
}), getter;
|
|
17
|
+
}, __webpack_require__.d = (exports, definition)=>{
|
|
18
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
19
|
+
enumerable: !0,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
|
+
export { __webpack_require__ };
|
package/dist/server-utils.d.ts
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import type { Route } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Generates the server build
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Generates the server build template string.
|
|
4
|
+
*
|
|
5
|
+
* Note: Federation mode used to require async `import()` wrappers for entrypoints.
|
|
6
|
+
* With Rspack/@module-federation support for `experiments.asyncStartup`, the
|
|
7
|
+
* server build can always use static imports.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
interface ServerBuildOptions {
|
|
9
10
|
entryServerPath: string;
|
|
10
11
|
assetsBuildDirectory: string;
|
|
11
12
|
basename: string;
|
|
12
13
|
appDirectory: string;
|
|
13
14
|
ssr: boolean;
|
|
14
|
-
|
|
15
|
+
future?: unknown;
|
|
16
|
+
allowedActionOrigins?: string[];
|
|
17
|
+
prerender?: string[];
|
|
18
|
+
publicPath?: string;
|
|
19
|
+
serverManifestId?: string;
|
|
15
20
|
routeDiscovery: {
|
|
16
21
|
mode: 'lazy';
|
|
17
22
|
manifestPath?: string;
|
|
18
23
|
} | {
|
|
19
24
|
mode: 'initial';
|
|
20
25
|
} | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generates the server build module content
|
|
29
|
+
* @param routes The route manifest
|
|
30
|
+
* @param options Build options
|
|
31
|
+
* @returns The generated module content as a string
|
|
32
|
+
*/
|
|
33
|
+
declare function generateServerBuild(routes: Record<string, Route>, options: ServerBuildOptions & {
|
|
34
|
+
federation?: boolean;
|
|
21
35
|
}): string;
|
|
36
|
+
export declare const normalizeBuildModule: <T extends Record<string, any>>(build: T) => T;
|
|
37
|
+
export declare const resolveBuildExports: <T extends Record<string, any>>(build: T) => Promise<T>;
|
|
22
38
|
export { generateServerBuild };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSsrExternals(rootDirectory: string): string[];
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_exports__ = {};
|
|
4
|
-
|
|
5
|
-
external_react_namespaceObject.startTransition(()=>{
|
|
4
|
+
const external_react_namespaceObject = require("react"), client_namespaceObject = require("react-dom/client"), dom_namespaceObject = require("react-router/dom");
|
|
5
|
+
for(var __rspack_i in external_react_namespaceObject.startTransition(()=>{
|
|
6
6
|
(0, client_namespaceObject.hydrateRoot)(document, external_react_namespaceObject.createElement(external_react_namespaceObject.StrictMode, null, external_react_namespaceObject.createElement(dom_namespaceObject.HydratedRouter, null)));
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
10
|
-
__webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
7
|
+
}), __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
8
|
+
Object.defineProperty(exports, '__esModule', {
|
|
11
9
|
value: !0
|
|
12
10
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { hydrateRoot } from "react-dom/client";
|
|
2
|
+
import { HydratedRouter } from "react-router/dom";
|
|
3
|
+
import { startTransition, createElement, StrictMode } from "../946.js";
|
|
4
|
+
startTransition(()=>{
|
|
5
|
+
hydrateRoot(document, createElement(StrictMode, null, createElement(HydratedRouter, null)));
|
|
6
6
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
__webpack_require__.d = (exports1, definition)=>{
|
|
5
5
|
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
@@ -7,7 +7,7 @@ __webpack_require__.d = (exports1, definition)=>{
|
|
|
7
7
|
get: definition[key]
|
|
8
8
|
});
|
|
9
9
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
10
|
-
|
|
10
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
11
11
|
value: 'Module'
|
|
12
12
|
}), Object.defineProperty(exports1, '__esModule', {
|
|
13
13
|
value: !0
|
|
@@ -17,7 +17,7 @@ var __webpack_exports__ = {};
|
|
|
17
17
|
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
18
18
|
default: ()=>handleRequest
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
const external_node_stream_namespaceObject = require("node:stream"), node_namespaceObject = require("@react-router/node"), external_isbot_namespaceObject = require("isbot"), external_react_namespaceObject = require("react"), server_namespaceObject = require("react-dom/server"), external_react_router_namespaceObject = require("react-router"), ABORT_DELAY = 5000;
|
|
21
21
|
function handleRequest(request, responseStatusCode, responseHeaders, routerContext) {
|
|
22
22
|
return new Promise((resolve, reject)=>{
|
|
23
23
|
let shellRendered = !1, statusCode = responseStatusCode, userAgent = request.headers.get('user-agent'), readyOption = userAgent && (0, external_isbot_namespaceObject.isbot)(userAgent) || routerContext.isSpaMode ? 'onAllReady' : 'onShellReady', { pipe, abort } = (0, server_namespaceObject.renderToPipeableStream)(external_react_namespaceObject.createElement(external_react_router_namespaceObject.ServerRouter, {
|
|
@@ -42,8 +42,9 @@ function handleRequest(request, responseStatusCode, responseHeaders, routerConte
|
|
|
42
42
|
setTimeout(abort, 5000);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
for(var __rspack_i in exports.default = __webpack_exports__.default, __webpack_exports__)-1 === [
|
|
46
|
+
"default"
|
|
47
|
+
].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
|
|
48
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
49
|
value: !0
|
|
49
50
|
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
1
|
+
import { PassThrough } from "node:stream";
|
|
2
|
+
import { createReadableStreamFromReadable } from "@react-router/node";
|
|
3
|
+
import { isbot } from "isbot";
|
|
4
|
+
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
+
import { createElement } from "../946.js";
|
|
6
|
+
import { ServerRouter } from "../906.js";
|
|
7
|
+
export default function(request, responseStatusCode, responseHeaders, routerContext) {
|
|
8
8
|
return new Promise((resolve, reject)=>{
|
|
9
|
-
let shellRendered = !1, statusCode = responseStatusCode, userAgent = request.headers.get('user-agent'), readyOption = userAgent &&
|
|
9
|
+
let shellRendered = !1, statusCode = responseStatusCode, userAgent = request.headers.get('user-agent'), readyOption = userAgent && isbot(userAgent) || routerContext.isSpaMode ? 'onAllReady' : 'onShellReady', { pipe, abort } = renderToPipeableStream(createElement(ServerRouter, {
|
|
10
10
|
context: routerContext,
|
|
11
11
|
url: request.url
|
|
12
12
|
}), {
|
|
13
13
|
[readyOption] () {
|
|
14
14
|
shellRendered = !0;
|
|
15
|
-
let body = new
|
|
15
|
+
let body = new PassThrough(), stream = createReadableStreamFromReadable(body);
|
|
16
16
|
responseHeaders.set('Content-Type', 'text/html'), resolve(new Response(stream, {
|
|
17
17
|
headers: responseHeaders,
|
|
18
18
|
status: statusCode
|
|
@@ -27,5 +27,4 @@ function handleRequest(request, responseStatusCode, responseHeaders, routerConte
|
|
|
27
27
|
});
|
|
28
28
|
setTimeout(abort, 5000);
|
|
29
29
|
});
|
|
30
|
-
}
|
|
31
|
-
export { handleRequest as default };
|
|
30
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -39,10 +39,16 @@ export type TransformArgs = {
|
|
|
39
39
|
};
|
|
40
40
|
export type RouteManifestItem = Omit<Route, 'file' | 'children'> & {
|
|
41
41
|
module: string;
|
|
42
|
+
clientActionModule?: string;
|
|
43
|
+
clientLoaderModule?: string;
|
|
44
|
+
clientMiddlewareModule?: string;
|
|
45
|
+
hydrateFallbackModule?: string;
|
|
42
46
|
hasAction: boolean;
|
|
43
47
|
hasLoader: boolean;
|
|
44
48
|
hasClientAction: boolean;
|
|
45
49
|
hasClientLoader: boolean;
|
|
50
|
+
hasClientMiddleware: boolean;
|
|
51
|
+
hasDefaultExport: boolean;
|
|
46
52
|
hasErrorBoundary: boolean;
|
|
47
53
|
imports: string[];
|
|
48
54
|
css: string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
export type PluginOrderIssue = {
|
|
3
|
+
kind: 'error';
|
|
4
|
+
message: string;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'warn';
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function validatePluginOrderFromConfig(config: RsbuildConfig): PluginOrderIssue[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '@rsbuild/core';
|
|
2
|
+
type Warn = (message: string) => void;
|
|
3
|
+
export declare function getClientSourceMapSetting(normalized: NormalizedConfig, clientEnvName?: string): unknown;
|
|
4
|
+
export declare function getClientDevtoolSetting(normalized: NormalizedConfig, clientEnvName?: string): unknown;
|
|
5
|
+
export declare function warnOnClientSourceMaps(normalized: NormalizedConfig, warn: Warn, clientEnvName?: string): void;
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Router plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,55 +48,54 @@
|
|
|
48
48
|
"ignoreMissingDts": true
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/generator": "^7.
|
|
53
|
-
"@babel/parser": "^7.
|
|
54
|
-
"@babel/traverse": "^7.
|
|
55
|
-
"@babel/types": "^7.
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@rspack/plugin-react-refresh": "^1.0
|
|
59
|
-
"babel-dead-code-elimination": "^1.0.
|
|
60
|
-
"esbuild": "^0.
|
|
61
|
-
"execa": "^9.
|
|
62
|
-
"fs-extra": "11.3.
|
|
63
|
-
"isbot": "5.1.
|
|
64
|
-
"jiti": "^2.
|
|
51
|
+
"@babel/core": "^7.28.6",
|
|
52
|
+
"@babel/generator": "^7.28.6",
|
|
53
|
+
"@babel/parser": "^7.28.6",
|
|
54
|
+
"@babel/traverse": "^7.28.6",
|
|
55
|
+
"@babel/types": "^7.28.6",
|
|
56
|
+
"@react-router/node": "^7.13.0",
|
|
57
|
+
"@remix-run/node-fetch-server": "^0.13.0",
|
|
58
|
+
"@rspack/plugin-react-refresh": "^1.6.0",
|
|
59
|
+
"babel-dead-code-elimination": "^1.0.12",
|
|
60
|
+
"esbuild": "^0.27.2",
|
|
61
|
+
"execa": "^9.6.1",
|
|
62
|
+
"fs-extra": "11.3.3",
|
|
63
|
+
"isbot": "5.1.34",
|
|
64
|
+
"jiti": "^2.6.1",
|
|
65
65
|
"jsesc": "^3.1.0",
|
|
66
|
-
"pathe": "^
|
|
67
|
-
"react-refresh": "^0.
|
|
68
|
-
"rspack-plugin-virtual-module": "^0.1
|
|
66
|
+
"pathe": "^2.0.3",
|
|
67
|
+
"react-refresh": "^0.18.0",
|
|
68
|
+
"rspack-plugin-virtual-module": "^1.0.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@changesets/cli": "^2.
|
|
72
|
-
"@react-router/dev": "^7.
|
|
73
|
-
"@
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"@
|
|
78
|
-
"@types/
|
|
79
|
-
"@types/
|
|
71
|
+
"@changesets/cli": "^2.29.8",
|
|
72
|
+
"@react-router/dev": "^7.13.0",
|
|
73
|
+
"@rsbuild/core": "1.7.2",
|
|
74
|
+
"@rslib/core": "^0.19.3",
|
|
75
|
+
"@rspack/core": "1.7.4",
|
|
76
|
+
"@rstest/core": "^0.8.1",
|
|
77
|
+
"@rstest/coverage-istanbul": "^0.2.0",
|
|
78
|
+
"@types/babel__core": "^7.20.5",
|
|
79
|
+
"@types/babel__generator": "^7.27.0",
|
|
80
|
+
"@types/babel__traverse": "^7.28.0",
|
|
80
81
|
"@types/fs-extra": "11.0.4",
|
|
81
82
|
"@types/jsesc": "^3.0.3",
|
|
82
|
-
"@types/node": "^
|
|
83
|
-
"@types/react": "^19.
|
|
84
|
-
"@types/react-dom": "^19.
|
|
85
|
-
"
|
|
83
|
+
"@types/node": "^25.0.10",
|
|
84
|
+
"@types/react": "^19.2.10",
|
|
85
|
+
"@types/react-dom": "^19.2.3",
|
|
86
|
+
"es-module-lexer": "1.7.0",
|
|
86
87
|
"kill-port": "^2.0.1",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"react": "^19.
|
|
91
|
-
"react-
|
|
92
|
-
"react-router": "^7.
|
|
93
|
-
"
|
|
94
|
-
"typescript": "^5.7.2",
|
|
95
|
-
"vitest": "^3.0.5",
|
|
88
|
+
"playwright": "^1.58.0",
|
|
89
|
+
"prettier": "3.8.1",
|
|
90
|
+
"react": "^19.2.4",
|
|
91
|
+
"react-dom": "^19.2.4",
|
|
92
|
+
"react-router": "^7.13.0",
|
|
93
|
+
"react-router-dom": "^7.13.0",
|
|
94
|
+
"typescript": "^5.9.3",
|
|
96
95
|
"@rsbuild/config": "1.0.1"
|
|
97
96
|
},
|
|
98
97
|
"peerDependencies": {
|
|
99
|
-
"@rsbuild/core": "^1.
|
|
98
|
+
"@rsbuild/core": "^1.7.2"
|
|
100
99
|
},
|
|
101
100
|
"publishConfig": {
|
|
102
101
|
"access": "public",
|
|
@@ -105,13 +104,13 @@
|
|
|
105
104
|
},
|
|
106
105
|
"scripts": {
|
|
107
106
|
"build": "rslib build",
|
|
108
|
-
"e2e": "pnpm build &&
|
|
107
|
+
"e2e": "pnpm build && pnpm --filter './examples/{default-template,spa-mode,prerender,custom-node-server,cloudflare,client-only}' test:e2e",
|
|
109
108
|
"dev": "rslib build --watch",
|
|
110
|
-
"test": "
|
|
111
|
-
"test:watch": "
|
|
112
|
-
"test:coverage": "
|
|
113
|
-
"test:core": "
|
|
114
|
-
"test:core:watch": "
|
|
109
|
+
"test": "rstest run",
|
|
110
|
+
"test:watch": "rstest watch",
|
|
111
|
+
"test:coverage": "rstest run --coverage",
|
|
112
|
+
"test:core": "rstest run -c ./rstest.config.ts",
|
|
113
|
+
"test:core:watch": "rstest watch -c ./rstest.config.ts",
|
|
115
114
|
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
116
115
|
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
117
116
|
"changeset": "changeset",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TransformArgs } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Transforms route modules with the react-router-route-federation resource query
|
|
4
|
-
* This handles proper code transformation for federated routes
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformRouteFederation(args: TransformArgs): Promise<string>;
|