rsbuild-plugin-react-router 0.1.1 → 0.2.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/0~rslib-runtime.js +16 -0
- package/dist/index.cjs +60 -53
- package/dist/index.js +95 -91
- package/dist/templates/entry.client.js +3 -3
- package/dist/templates/entry.server.cjs +8 -5
- package/dist/templates/entry.server.js +3 -3
- package/package.json +8 -7
- package/dist/906.js +0 -1
- package/dist/946.js +0 -1
- package/dist/rslib-runtime.js +0 -23
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __webpack_require__ = {};
|
|
2
|
+
__webpack_require__.n = (module)=>{
|
|
3
|
+
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
4
|
+
return __webpack_require__.d(getter, {
|
|
5
|
+
a: getter
|
|
6
|
+
}), getter;
|
|
7
|
+
}, __webpack_require__.d = (exports, getters, values)=>{
|
|
8
|
+
var define = (defs, kind)=>{
|
|
9
|
+
for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
10
|
+
enumerable: !0,
|
|
11
|
+
[kind]: defs[key]
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
define(getters, "get"), define(values, "value");
|
|
15
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
16
|
+
export { __webpack_require__ };
|
package/dist/index.cjs
CHANGED
|
@@ -7,11 +7,14 @@ __webpack_require__.n = (module)=>{
|
|
|
7
7
|
return __webpack_require__.d(getter, {
|
|
8
8
|
a: getter
|
|
9
9
|
}), getter;
|
|
10
|
-
}, __webpack_require__.d = (exports1,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
}, __webpack_require__.d = (exports1, getters, values)=>{
|
|
11
|
+
var define = (defs, kind)=>{
|
|
12
|
+
for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
13
|
+
enumerable: !0,
|
|
14
|
+
[kind]: defs[key]
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
define(getters, "get"), define(values, "value");
|
|
15
18
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
16
19
|
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
20
|
value: 'Module'
|
|
@@ -886,7 +889,10 @@ const DEFAULT_MANIFEST_DIR = 'static/js', getManifestDirFromEntryAsset = (entryM
|
|
|
886
889
|
if (!isBuild) return 'static/js/virtual/react-router/browser-manifest.js';
|
|
887
890
|
let dir = getManifestDirFromEntryAsset(entryModulePath);
|
|
888
891
|
return `${dir}/manifest-${version}.js`;
|
|
889
|
-
}, getManifestVersion = (fingerprintedValues, isBuild)=>isBuild ? (0, external_node_crypto_namespaceObject.createHash)('md5').update(JSON.stringify(fingerprintedValues)).digest('hex').slice(0, 8) : String(Math.random())
|
|
892
|
+
}, getManifestVersion = (fingerprintedValues, isBuild)=>isBuild ? (0, external_node_crypto_namespaceObject.createHash)('md5').update(JSON.stringify(fingerprintedValues)).digest('hex').slice(0, 8) : String(Math.random()), getRouteEntryName = (route)=>{
|
|
893
|
+
let extensionIndex = route.file.lastIndexOf('.');
|
|
894
|
+
return extensionIndex >= 0 ? route.file.slice(0, extensionIndex) : route.file;
|
|
895
|
+
};
|
|
890
896
|
async function getReactRouterManifestForDev(routes, options, clientStats, context, assetPrefix = '/', routeChunkOptions) {
|
|
891
897
|
let result = {}, splitRouteModules = routeChunkOptions?.splitRouteModules ?? !1, enforceSplitRouteModules = 'enforce' === splitRouteModules, isBuild = routeChunkOptions?.isBuild ?? !1, routeChunkConfig = splitRouteModules && routeChunkOptions?.rootRouteFile ? {
|
|
892
898
|
splitRouteModules,
|
|
@@ -894,22 +900,33 @@ async function getReactRouterManifestForDev(routes, options, clientStats, contex
|
|
|
894
900
|
rootRouteFile: routeChunkOptions.rootRouteFile
|
|
895
901
|
} : null, getAssetsForChunk = (chunkName)=>{
|
|
896
902
|
let assets = clientStats?.assetsByChunkName?.[chunkName];
|
|
897
|
-
|
|
903
|
+
if (!assets) return [
|
|
904
|
+
`${DEFAULT_MANIFEST_DIR}/${chunkName}.js`
|
|
905
|
+
];
|
|
906
|
+
let normalizedAssets = Array.isArray(assets) ? assets : [
|
|
898
907
|
assets
|
|
899
|
-
]
|
|
908
|
+
];
|
|
909
|
+
return normalizedAssets.some((asset)=>asset.endsWith('.js')) ? normalizedAssets : [
|
|
910
|
+
`${DEFAULT_MANIFEST_DIR}/${chunkName}.js`,
|
|
911
|
+
...normalizedAssets
|
|
912
|
+
];
|
|
900
913
|
}, getModulePathForChunk = (chunkName)=>{
|
|
901
914
|
let jsAssets = getAssetsForChunk(chunkName).filter((asset)=>asset.endsWith('.js'));
|
|
902
915
|
return jsAssets[0] ? combineURLs(assetPrefix, jsAssets[0]) : void 0;
|
|
903
916
|
};
|
|
904
917
|
for (let [key, route] of Object.entries(routes)){
|
|
905
|
-
let assets = getAssetsForChunk(
|
|
918
|
+
let routeEntryName = getRouteEntryName(route), assets = getAssetsForChunk(routeEntryName), jsAssets = assets.filter((asset)=>asset.endsWith('.js')) || [], cssAssets = assets.filter((asset)=>asset.endsWith('.css')) || [], routeFilePath = (0, external_pathe_namespaceObject.resolve)(context, route.file), exports1 = new Set(), hasRouteChunkByExportName = {
|
|
906
919
|
clientAction: !1,
|
|
907
920
|
clientLoader: !1,
|
|
908
921
|
clientMiddleware: !1,
|
|
909
922
|
HydrateFallback: !1
|
|
910
923
|
};
|
|
911
924
|
try {
|
|
912
|
-
let source = await (0, promises_namespaceObject.readFile)(routeFilePath, 'utf8')
|
|
925
|
+
let source = await (0, promises_namespaceObject.readFile)(routeFilePath, 'utf8');
|
|
926
|
+
!isBuild && 0 === cssAssets.length && /\.(?:css|less|sass|scss)(?:\?[^'"`]+)?['"`]/.test(source) && (cssAssets = [
|
|
927
|
+
`${DEFAULT_MANIFEST_DIR.replace('/js', '/css')}/${routeEntryName}.css`
|
|
928
|
+
]);
|
|
929
|
+
let code = await transformToEsm(source, routeFilePath);
|
|
913
930
|
if (exports1 = new Set(await getExportNames(code)), isBuild && routeChunkConfig) {
|
|
914
931
|
let { hasRouteChunkByExportName: chunkInfo } = await detectRouteChunksIfEnabled(routeChunkOptions?.cache, routeChunkConfig, routeFilePath, code);
|
|
915
932
|
hasRouteChunkByExportName = chunkInfo;
|
|
@@ -949,7 +966,7 @@ async function getReactRouterManifestForDev(routes, options, clientStats, contex
|
|
|
949
966
|
css: cssAssets.map((asset)=>combineURLs(assetPrefix, asset))
|
|
950
967
|
};
|
|
951
968
|
}
|
|
952
|
-
let entryAssets =
|
|
969
|
+
let entryAssets = getAssetsForChunk('entry.client'), entryJsAssets = entryAssets.filter((asset)=>asset.endsWith('.js')), entryCssAssets = entryAssets.filter((asset)=>asset.endsWith('.css')), fingerprintedValues = {
|
|
953
970
|
entry: {
|
|
954
971
|
module: combineURLs(assetPrefix, entryJsAssets[0] || ''),
|
|
955
972
|
imports: entryJsAssets.map((asset)=>combineURLs(assetPrefix, asset)),
|
|
@@ -1546,9 +1563,32 @@ const redirectStatusCodes = new Set([
|
|
|
1546
1563
|
});
|
|
1547
1564
|
}
|
|
1548
1565
|
});
|
|
1549
|
-
let allowedActionOriginsForBuild = !1 === allowedActionOrigins ? void 0 : allowedActionOrigins,
|
|
1550
|
-
|
|
1551
|
-
|
|
1566
|
+
let allowedActionOriginsForBuild = !1 === allowedActionOrigins ? void 0 : allowedActionOrigins, vmodTempDir = `rspack-virtual-module-${process.pid}-${Math.random().toString(16).slice(2)}`;
|
|
1567
|
+
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig })=>{
|
|
1568
|
+
var publicPath;
|
|
1569
|
+
let bundleVirtualModules, bundleManifestModules, vmodPlugin = (publicPath = assetPrefix = normalizeAssetPrefix(config.output?.assetPrefix), bundleVirtualModules = Object.fromEntries(Object.entries(routesByServerBundleId).map(([bundleId, bundleRoutes])=>[
|
|
1570
|
+
`virtual/react-router/server-build-${bundleId}`,
|
|
1571
|
+
generateServerBuild(bundleRoutes, {
|
|
1572
|
+
entryServerPath: finalEntryServerPath,
|
|
1573
|
+
assetsBuildDirectory,
|
|
1574
|
+
basename,
|
|
1575
|
+
appDirectory,
|
|
1576
|
+
ssr,
|
|
1577
|
+
federation: options.federation,
|
|
1578
|
+
future,
|
|
1579
|
+
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1580
|
+
prerender: prerenderPaths,
|
|
1581
|
+
routeDiscovery,
|
|
1582
|
+
publicPath,
|
|
1583
|
+
serverManifestId: `virtual/react-router/server-manifest-${bundleId}`
|
|
1584
|
+
})
|
|
1585
|
+
])), bundleManifestModules = Object.fromEntries(Object.entries(routesByServerBundleId).filter(([, bundleRoutes])=>bundleRoutes && Object.keys(bundleRoutes).length > 0).map(([bundleId])=>[
|
|
1586
|
+
`virtual/react-router/server-manifest-${bundleId}`,
|
|
1587
|
+
'export default {};'
|
|
1588
|
+
])), new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({
|
|
1589
|
+
'virtual/react-router/browser-manifest': 'export default {};',
|
|
1590
|
+
'virtual/react-router/server-manifest': 'export default {};',
|
|
1591
|
+
'virtual/react-router/server-build': generateServerBuild(routes, {
|
|
1552
1592
|
entryServerPath: finalEntryServerPath,
|
|
1553
1593
|
assetsBuildDirectory,
|
|
1554
1594
|
basename,
|
|
@@ -1559,35 +1599,12 @@ const redirectStatusCodes = new Set([
|
|
|
1559
1599
|
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1560
1600
|
prerender: prerenderPaths,
|
|
1561
1601
|
routeDiscovery,
|
|
1562
|
-
publicPath
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
])), vmodTempDir = `rspack-virtual-module-${process.pid}-${Math.random().toString(16).slice(2)}`, vmodPlugin = new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({
|
|
1569
|
-
'virtual/react-router/browser-manifest': 'export default {};',
|
|
1570
|
-
'virtual/react-router/server-manifest': 'export default {};',
|
|
1571
|
-
'virtual/react-router/server-build': generateServerBuild(routes, {
|
|
1572
|
-
entryServerPath: finalEntryServerPath,
|
|
1573
|
-
assetsBuildDirectory,
|
|
1574
|
-
basename,
|
|
1575
|
-
appDirectory,
|
|
1576
|
-
ssr,
|
|
1577
|
-
federation: options.federation,
|
|
1578
|
-
future,
|
|
1579
|
-
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1580
|
-
prerender: prerenderPaths,
|
|
1581
|
-
routeDiscovery,
|
|
1582
|
-
publicPath: assetPrefix
|
|
1583
|
-
}),
|
|
1584
|
-
...bundleVirtualModules,
|
|
1585
|
-
...bundleManifestModules,
|
|
1586
|
-
'virtual/react-router/with-props': generateWithProps()
|
|
1587
|
-
}, vmodTempDir);
|
|
1588
|
-
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig })=>{
|
|
1589
|
-
assetPrefix = normalizeAssetPrefix(config.output?.assetPrefix);
|
|
1590
|
-
let useAsyncNodeChunkLoading = options.federation && 'commonjs' === resolvedServerOutput, nodeChunkLoading = 'module' === resolvedServerOutput ? 'import' : useAsyncNodeChunkLoading ? 'async-node' : 'require', serverBuildFileBase = (serverBuildFile || 'index.js').replace(/\.js$/, ''), nodeEntries = {
|
|
1602
|
+
publicPath
|
|
1603
|
+
}),
|
|
1604
|
+
...bundleVirtualModules,
|
|
1605
|
+
...bundleManifestModules,
|
|
1606
|
+
'virtual/react-router/with-props': generateWithProps()
|
|
1607
|
+
}, vmodTempDir)), useAsyncNodeChunkLoading = options.federation && 'commonjs' === resolvedServerOutput, nodeChunkLoading = 'module' === resolvedServerOutput ? 'import' : useAsyncNodeChunkLoading ? 'async-node' : 'require', serverBuildFileBase = (serverBuildFile || 'index.js').replace(/\.js$/, ''), nodeEntries = {
|
|
1591
1608
|
...hasServerApp ? {
|
|
1592
1609
|
'static/js/app': serverAppPath
|
|
1593
1610
|
} : {
|
|
@@ -1635,10 +1652,6 @@ const redirectStatusCodes = new Set([
|
|
|
1635
1652
|
tools: {
|
|
1636
1653
|
rspack: {
|
|
1637
1654
|
name: 'web',
|
|
1638
|
-
experiments: {
|
|
1639
|
-
topLevelAwait: !0,
|
|
1640
|
-
outputModule: !0
|
|
1641
|
-
},
|
|
1642
1655
|
...options.federation ? {
|
|
1643
1656
|
output: {
|
|
1644
1657
|
chunkLoading: 'import'
|
|
@@ -1682,12 +1695,6 @@ const redirectStatusCodes = new Set([
|
|
|
1682
1695
|
dependencies: [
|
|
1683
1696
|
'web'
|
|
1684
1697
|
],
|
|
1685
|
-
experiments: {
|
|
1686
|
-
outputModule: 'module' === resolvedServerOutput,
|
|
1687
|
-
...options.federation ? {
|
|
1688
|
-
asyncStartup: !0
|
|
1689
|
-
} : {}
|
|
1690
|
-
},
|
|
1691
1698
|
externalsType: resolvedServerOutput,
|
|
1692
1699
|
output: {
|
|
1693
1700
|
chunkFormat: resolvedServerOutput,
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
let lexer_C;
|
|
2
|
-
import {
|
|
3
|
-
import { dirname as __rspack_dirname, sep } from "node:path";
|
|
4
|
-
import * as __rspack_external__babel_types_69e65b52 from "@babel/types";
|
|
5
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
6
3
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
7
4
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
5
|
import { createRequire } from "node:module";
|
|
6
|
+
import { pathToFileURL, fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
9
7
|
import fs_extra from "fs-extra";
|
|
10
8
|
import { createJiti } from "jiti";
|
|
11
9
|
import jsesc from "jsesc";
|
|
12
10
|
import { basename as external_pathe_basename, dirname, extname, isAbsolute, normalize, relative, resolve } from "pathe";
|
|
13
11
|
import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
|
|
14
12
|
import { parse } from "@babel/parser";
|
|
13
|
+
import { callExpression, functionExpression, identifier as types_identifier, importDeclaration, importSpecifier, isClassDeclaration, isExportAllDeclaration, isExportDeclaration, isExportDefaultDeclaration, isExportNamedDeclaration, isFunctionDeclaration, isIdentifier, isImportDeclaration, isNodesEquivalent, isObjectProperty, isPattern, isRestElement, isStatement, isVariableDeclaration, isVariableDeclarator, stringLiteral, variableDeclaration, variableDeclarator as types_variableDeclarator } from "@babel/types";
|
|
15
14
|
import { deadCodeElimination, findReferencedIdentifiers } from "babel-dead-code-elimination";
|
|
16
15
|
import { createHash } from "node:crypto";
|
|
17
|
-
import { transform } from "esbuild";
|
|
18
16
|
import { rspack } from "@rsbuild/core";
|
|
19
|
-
import { createRequestHandler, matchRoutes } from "
|
|
17
|
+
import { createRequestHandler, matchRoutes } from "react-router";
|
|
18
|
+
import { sep, dirname as __rspack_dirname } from "node:path";
|
|
19
|
+
import * as __rspack_external_esbuild from "esbuild";
|
|
20
20
|
let generator_namespaceObject = require("@babel/generator");
|
|
21
21
|
var A, A1, ImportType, generator_default = __webpack_require__.n(generator_namespaceObject);
|
|
22
22
|
let traverse_namespaceObject = require("@babel/traverse");
|
|
@@ -123,7 +123,7 @@ function invalidDestructureError(name) {
|
|
|
123
123
|
return Error(`Cannot remove destructured export "${name}"`);
|
|
124
124
|
}
|
|
125
125
|
function toFunctionExpression(decl) {
|
|
126
|
-
return
|
|
126
|
+
return functionExpression(decl.id, decl.params, decl.body, decl.generator, decl.async);
|
|
127
127
|
}
|
|
128
128
|
function combineURLs(baseURL, relativeURL) {
|
|
129
129
|
return relativeURL ? `${baseURL.replace(/\/+$/, '')}/${relativeURL.replace(/^\/+/, '')}` : baseURL;
|
|
@@ -293,17 +293,17 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
293
293
|
}, codeToAst = (code, cache, cacheKey)=>structuredClone(getOrSetFromCache(cache, `${cacheKey}::codeToAst`, code, ()=>parse(code, {
|
|
294
294
|
sourceType: 'module'
|
|
295
295
|
}))), isNodePathWithNode = (path)=>!(!path || 'object' != typeof path || Array.isArray(path)) && 'node' in path && !!path.node, assertNodePathIsVariableDeclarator = (path)=>{
|
|
296
|
-
invariant(path && !Array.isArray(path) &&
|
|
296
|
+
invariant(path && !Array.isArray(path) && isVariableDeclarator(path.node), `Expected a VariableDeclarator path, but got ${Array.isArray(path) ? 'an array' : path?.node?.type}`);
|
|
297
297
|
}, assertNodePathIsPattern = (path)=>{
|
|
298
|
-
invariant(path && !Array.isArray(path) &&
|
|
298
|
+
invariant(path && !Array.isArray(path) && isPattern(path.node), `Expected a Pattern path, but got ${Array.isArray(path) ? 'an array' : path?.node?.type}`);
|
|
299
299
|
}, getExportDependencies = (code, cache, cacheKey)=>getOrSetFromCache(cache, `${cacheKey}::getExportDependencies`, code, ()=>{
|
|
300
300
|
let exportDependencies = new Map();
|
|
301
301
|
function handleExport(exportName, exportPath, identifiersPath = exportPath) {
|
|
302
302
|
let identifiers = getDependentIdentifiersForPath(identifiersPath), topLevelStatements = new Set([
|
|
303
303
|
exportPath.node,
|
|
304
304
|
...getTopLevelStatementsForPaths(identifiers)
|
|
305
|
-
]), topLevelNonModuleStatements = new Set(Array.from(topLevelStatements).filter((statement)=>!
|
|
306
|
-
for (let identifier of identifiers)
|
|
305
|
+
]), topLevelNonModuleStatements = new Set(Array.from(topLevelStatements).filter((statement)=>!isImportDeclaration(statement) && !isExportDeclaration(statement))), importedIdentifierNames = new Set();
|
|
306
|
+
for (let identifier of identifiers)isIdentifier(identifier.node) && identifier.parentPath?.parentPath?.isImportDeclaration() && importedIdentifierNames.add(identifier.node.name);
|
|
307
307
|
let exportedVariableDeclarators = new Set();
|
|
308
308
|
for (let identifier of identifiers){
|
|
309
309
|
if (identifier.parentPath?.isVariableDeclarator()) {
|
|
@@ -334,31 +334,31 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
334
334
|
return traverse(codeToAst(code, cache, cacheKey), {
|
|
335
335
|
ExportDeclaration (exportPath) {
|
|
336
336
|
let { node } = exportPath;
|
|
337
|
-
if (
|
|
338
|
-
if (
|
|
337
|
+
if (isExportAllDeclaration(node)) return;
|
|
338
|
+
if (isExportDefaultDeclaration(node)) return void handleExport('default', exportPath);
|
|
339
339
|
let { declaration } = node;
|
|
340
|
-
if (
|
|
340
|
+
if (isVariableDeclaration(declaration)) {
|
|
341
341
|
let { declarations } = declaration;
|
|
342
342
|
for(let i = 0; i < declarations.length; i++){
|
|
343
343
|
let declarator = declarations[i];
|
|
344
|
-
if (
|
|
344
|
+
if (isIdentifier(declarator.id)) {
|
|
345
345
|
let declaratorPath = exportPath.get(`declaration.declarations.${i}`);
|
|
346
346
|
assertNodePathIsVariableDeclarator(declaratorPath), handleExport(declarator.id.name, exportPath, declaratorPath);
|
|
347
347
|
continue;
|
|
348
348
|
}
|
|
349
|
-
if (
|
|
349
|
+
if (isPattern(declarator.id)) {
|
|
350
350
|
let exportedPatternPath = exportPath.get(`declaration.declarations.${i}.id`);
|
|
351
|
-
for (let identifier of (assertNodePathIsPattern(exportedPatternPath), getIdentifiersForPatternPath(exportedPatternPath)))
|
|
351
|
+
for (let identifier of (assertNodePathIsPattern(exportedPatternPath), getIdentifiersForPatternPath(exportedPatternPath)))isIdentifier(identifier.node) && handleExport(identifier.node.name, exportPath, identifier);
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
356
|
-
if (
|
|
356
|
+
if (isFunctionDeclaration(declaration) || isClassDeclaration(declaration)) {
|
|
357
357
|
invariant(declaration.id, 'Expected exported function or class declaration to have a name when not the default export'), handleExport(declaration.id.name, exportPath);
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
|
-
if (
|
|
361
|
-
for (let specifier of node.specifiers)if (
|
|
360
|
+
if (isExportNamedDeclaration(node)) {
|
|
361
|
+
for (let specifier of node.specifiers)if (isIdentifier(specifier.exported)) {
|
|
362
362
|
let name = specifier.exported.name, specifierPath = exportPath.get('specifiers').find((path)=>path.node === specifier);
|
|
363
363
|
invariant(specifierPath, `Expected to find specifier path for ${name}`), handleExport(name, exportPath, specifierPath);
|
|
364
364
|
}
|
|
@@ -397,7 +397,7 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
397
397
|
if (withinImportStatement || withinExportStatement || getDependentIdentifiersForPath(topLevelStatement, {
|
|
398
398
|
visited,
|
|
399
399
|
identifiers
|
|
400
|
-
}), withinExportStatement && path.isIdentifier() && (
|
|
400
|
+
}), withinExportStatement && path.isIdentifier() && (isPattern(path.parentPath.node) || isPattern(path.parentPath.parentPath?.node))) {
|
|
401
401
|
let variableDeclarator = path.findParent((p)=>p.isVariableDeclarator());
|
|
402
402
|
variableDeclarator && (invariant(variableDeclarator && !Array.isArray(variableDeclarator), `Expected a Path, but got ${Array.isArray(variableDeclarator) ? 'an array' : variableDeclarator}`), getDependentIdentifiersForPath(variableDeclarator, {
|
|
403
403
|
visited,
|
|
@@ -407,7 +407,7 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
407
407
|
return identifiers;
|
|
408
408
|
}, getTopLevelStatementPathForPath = (path)=>{
|
|
409
409
|
let ancestry = path.getAncestry(), topLevelStatement = ancestry[ancestry.length - 2];
|
|
410
|
-
return invariant(topLevelStatement && !Array.isArray(topLevelStatement) &&
|
|
410
|
+
return invariant(topLevelStatement && !Array.isArray(topLevelStatement) && isStatement(topLevelStatement.node), `Expected a Statement path, but got ${Array.isArray(topLevelStatement) ? 'an array' : topLevelStatement?.node?.type}`), topLevelStatement;
|
|
411
411
|
}, getTopLevelStatementsForPaths = (paths)=>{
|
|
412
412
|
let topLevelStatements = new Set();
|
|
413
413
|
for (let path of paths){
|
|
@@ -421,10 +421,10 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
421
421
|
let { properties } = currentPath.node;
|
|
422
422
|
for(let i = 0; i < properties.length; i++){
|
|
423
423
|
let property = properties[i];
|
|
424
|
-
if (
|
|
424
|
+
if (isObjectProperty(property)) {
|
|
425
425
|
let valuePath = currentPath.get(`properties.${i}.value`);
|
|
426
426
|
isNodePathWithNode(valuePath) && walk(valuePath);
|
|
427
|
-
} else if (
|
|
427
|
+
} else if (isRestElement(property)) {
|
|
428
428
|
let argumentPath = currentPath.get(`properties.${i}.argument`);
|
|
429
429
|
isNodePathWithNode(argumentPath) && walk(argumentPath);
|
|
430
430
|
}
|
|
@@ -439,7 +439,7 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
439
439
|
let argumentPath = currentPath.get('argument');
|
|
440
440
|
isNodePathWithNode(argumentPath) && walk(argumentPath);
|
|
441
441
|
}
|
|
442
|
-
}(patternPath), identifiers), getExportedName = (exported)=>
|
|
442
|
+
}(patternPath), identifiers), getExportedName = (exported)=>isIdentifier(exported) ? exported.name : exported.value, setsIntersect = (set1, set2)=>{
|
|
443
443
|
let smallerSet = set1, largerSet = set2;
|
|
444
444
|
for (let element of (set1.size > set2.size && (smallerSet = set2, largerSet = set1), smallerSet))if (largerSet.has(element)) return !0;
|
|
445
445
|
return !1;
|
|
@@ -487,7 +487,7 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
487
487
|
for (let declarator of dependencies.exportedVariableDeclarators)omittedExportedVariableDeclarators.add(declarator);
|
|
488
488
|
}
|
|
489
489
|
let ast = codeToAst(code, cache, cacheKey), omittedStatementsArray = Array.from(omittedStatements), omittedExportedVariableDeclaratorsArray = Array.from(omittedExportedVariableDeclarators);
|
|
490
|
-
if (ast.program.body = ast.program.body.filter((node)=>omittedStatementsArray.every((statement)=>!
|
|
490
|
+
if (ast.program.body = ast.program.body.filter((node)=>omittedStatementsArray.every((statement)=>!isNodesEquivalent(node, statement))).map((node)=>isImportDeclaration(node) && 0 !== node.specifiers.length && (node.specifiers = node.specifiers.filter((specifier)=>{
|
|
491
491
|
let importedName = specifier.local.name;
|
|
492
492
|
for (let retainedExportName of retainedExportNames){
|
|
493
493
|
let dependencies = exportDependencies.get(retainedExportName);
|
|
@@ -499,14 +499,14 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
499
499
|
}
|
|
500
500
|
return !0;
|
|
501
501
|
}), 0 === node.specifiers.length) ? null : node).map((node)=>{
|
|
502
|
-
if (!
|
|
503
|
-
if (
|
|
504
|
-
if (
|
|
505
|
-
if (
|
|
502
|
+
if (!isExportDeclaration(node) || isExportAllDeclaration(node)) return node;
|
|
503
|
+
if (isExportDefaultDeclaration(node)) return isOmitted('default') ? null : node;
|
|
504
|
+
if (isVariableDeclaration(node.declaration)) return (node.declaration.declarations = node.declaration.declarations.filter((declarationNode)=>omittedExportedVariableDeclaratorsArray.every((declarator)=>!isNodesEquivalent(declarationNode, declarator))), 0 === node.declaration.declarations.length) ? null : node;
|
|
505
|
+
if (isFunctionDeclaration(node.declaration) || isClassDeclaration(node.declaration)) {
|
|
506
506
|
let declarationId = node.declaration.id;
|
|
507
507
|
return invariant(declarationId, 'Expected exported function or class declaration to have a name when not the default export'), isOmitted(declarationId.name) ? null : node;
|
|
508
508
|
}
|
|
509
|
-
if (
|
|
509
|
+
if (isExportNamedDeclaration(node)) return 0 === node.specifiers.length ? node : (node.specifiers = node.specifiers.filter((specifier)=>!isOmitted(getExportedName(specifier.exported))), 0 === node.specifiers.length) ? null : node;
|
|
510
510
|
throw Error('Unknown node type');
|
|
511
511
|
}).filter(Boolean), 0 !== ast.program.body.length) return generate(ast, generateOptions).code;
|
|
512
512
|
}))(code, routeChunkExportNames, {}, cache, cacheKey) : ((code, exportName, generateOptions = {}, cache, cacheKey)=>getOrSetFromCache(cache, `${cacheKey}::getChunkedExport::${exportName}::${JSON.stringify(generateOptions)}`, code, ()=>{
|
|
@@ -514,14 +514,14 @@ let routeChunkQueryStringPrefix = '?route-chunk=', routeChunkQueryStrings = {
|
|
|
514
514
|
let dependencies = getExportDependencies(code, cache, cacheKey).get(exportName);
|
|
515
515
|
invariant(dependencies, 'Expected export to have dependencies');
|
|
516
516
|
let topLevelStatementsArray = Array.from(dependencies.topLevelStatements), exportedVariableDeclaratorsArray = Array.from(dependencies.exportedVariableDeclarators), ast = codeToAst(code, cache, cacheKey);
|
|
517
|
-
return ast.program.body = ast.program.body.filter((node)=>topLevelStatementsArray.some((statement)=>
|
|
518
|
-
if (!
|
|
519
|
-
if (
|
|
520
|
-
if (
|
|
517
|
+
return ast.program.body = ast.program.body.filter((node)=>topLevelStatementsArray.some((statement)=>isNodesEquivalent(node, statement))).map((node)=>isImportDeclaration(node) ? 0 === dependencies.importedIdentifierNames.size ? null : (node.specifiers = node.specifiers.filter((specifier)=>dependencies.importedIdentifierNames.has(specifier.local.name)), invariant(node.specifiers.length > 0, 'Expected import statement to have used specifiers'), node) : node).map((node)=>{
|
|
518
|
+
if (!isExportDeclaration(node)) return node;
|
|
519
|
+
if (isExportAllDeclaration(node)) return null;
|
|
520
|
+
if (isExportDefaultDeclaration(node)) return 'default' === exportName ? node : null;
|
|
521
521
|
let { declaration } = node;
|
|
522
|
-
if (
|
|
523
|
-
if (
|
|
524
|
-
if (
|
|
522
|
+
if (isVariableDeclaration(declaration)) return (declaration.declarations = declaration.declarations.filter((declarationNode)=>exportedVariableDeclaratorsArray.some((declarator)=>isNodesEquivalent(declarationNode, declarator))), 0 === declaration.declarations.length) ? null : node;
|
|
523
|
+
if (isFunctionDeclaration(node.declaration) || isClassDeclaration(node.declaration)) return node.declaration.id?.name === exportName ? node : null;
|
|
524
|
+
if (isExportNamedDeclaration(node)) return 0 === node.specifiers.length || (node.specifiers = node.specifiers.filter((specifier)=>getExportedName(specifier.exported) === exportName), 0 === node.specifiers.length) ? null : node;
|
|
525
525
|
throw Error('Unknown export node type');
|
|
526
526
|
}).filter(Boolean), generate(ast, generateOptions).code;
|
|
527
527
|
}))(code, chunkName, {}, cache, cacheKey)) ?? null;
|
|
@@ -596,7 +596,7 @@ function lexer_parse(E, g = "@") {
|
|
|
596
596
|
}
|
|
597
597
|
let lexer_init = WebAssembly.compile((A1 = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGIgAbIAQgA0YiBBs2AgwgBSADNgIUIAVBADYCECAFIAI2AgQgBUEANgIgIAVBA0EBQQIgABsgBBs2AhwgBUEAKALQCSADRiICOgAYAkACQCACDQBBACgC1AkgA0cNAQtBAEEBOgCMCgsLXgEBf0EAKAL4CSIEQRBqQeQJIAQbQQAoAogKIgQ2AgBBACAENgL4CUEAIARBFGo2AogKQQBBAToAjAogBEEANgIQIAQgAzYCDCAEIAI2AgggBCABNgIEIAQgADYCAAsIAEEAKAKQC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AwACwtBACACNgKwChAlQQAPC0EAIAI2ArAKQd0AC0kBA39BACEDAkAgAkUNAAJAA0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=", "u" > typeof Buffer ? Buffer.from(A1, "base64") : Uint8Array.from(atob(A1), (A)=>A.charCodeAt(0)))).then(WebAssembly.instantiate).then(({ exports: A })=>{
|
|
598
598
|
lexer_C = A;
|
|
599
|
-
}), transformToEsm = async (code, resourcePath)=>(await transform(code, {
|
|
599
|
+
}), transformToEsm = async (code, resourcePath)=>(await __rspack_external_esbuild.transform(code, {
|
|
600
600
|
jsx: 'automatic',
|
|
601
601
|
format: 'esm',
|
|
602
602
|
platform: 'neutral',
|
|
@@ -630,6 +630,9 @@ let lexer_init = WebAssembly.compile((A1 = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/
|
|
|
630
630
|
return '.' === dir ? DEFAULT_MANIFEST_DIR : dir;
|
|
631
631
|
})(entryModulePath);
|
|
632
632
|
return `${dir}/manifest-${version}.js`;
|
|
633
|
+
}, getRouteEntryName = (route)=>{
|
|
634
|
+
let extensionIndex = route.file.lastIndexOf('.');
|
|
635
|
+
return extensionIndex >= 0 ? route.file.slice(0, extensionIndex) : route.file;
|
|
633
636
|
};
|
|
634
637
|
async function getReactRouterManifestForDev(routes, options, clientStats, context, assetPrefix = '/', routeChunkOptions) {
|
|
635
638
|
let result = {}, splitRouteModules = routeChunkOptions?.splitRouteModules ?? !1, enforceSplitRouteModules = 'enforce' === splitRouteModules, isBuild = routeChunkOptions?.isBuild ?? !1, routeChunkConfig = splitRouteModules && routeChunkOptions?.rootRouteFile ? {
|
|
@@ -638,22 +641,33 @@ async function getReactRouterManifestForDev(routes, options, clientStats, contex
|
|
|
638
641
|
rootRouteFile: routeChunkOptions.rootRouteFile
|
|
639
642
|
} : null, getAssetsForChunk = (chunkName)=>{
|
|
640
643
|
let assets = clientStats?.assetsByChunkName?.[chunkName];
|
|
641
|
-
|
|
644
|
+
if (!assets) return [
|
|
645
|
+
`${DEFAULT_MANIFEST_DIR}/${chunkName}.js`
|
|
646
|
+
];
|
|
647
|
+
let normalizedAssets = Array.isArray(assets) ? assets : [
|
|
642
648
|
assets
|
|
643
|
-
]
|
|
649
|
+
];
|
|
650
|
+
return normalizedAssets.some((asset)=>asset.endsWith('.js')) ? normalizedAssets : [
|
|
651
|
+
`${DEFAULT_MANIFEST_DIR}/${chunkName}.js`,
|
|
652
|
+
...normalizedAssets
|
|
653
|
+
];
|
|
644
654
|
}, getModulePathForChunk = (chunkName)=>{
|
|
645
655
|
let jsAssets = getAssetsForChunk(chunkName).filter((asset)=>asset.endsWith('.js'));
|
|
646
656
|
return jsAssets[0] ? combineURLs(assetPrefix, jsAssets[0]) : void 0;
|
|
647
657
|
};
|
|
648
658
|
for (let [key, route] of Object.entries(routes)){
|
|
649
|
-
let assets = getAssetsForChunk(
|
|
659
|
+
let routeEntryName = getRouteEntryName(route), assets = getAssetsForChunk(routeEntryName), jsAssets = assets.filter((asset)=>asset.endsWith('.js')) || [], cssAssets = assets.filter((asset)=>asset.endsWith('.css')) || [], routeFilePath = resolve(context, route.file), exports = new Set(), hasRouteChunkByExportName = {
|
|
650
660
|
clientAction: !1,
|
|
651
661
|
clientLoader: !1,
|
|
652
662
|
clientMiddleware: !1,
|
|
653
663
|
HydrateFallback: !1
|
|
654
664
|
};
|
|
655
665
|
try {
|
|
656
|
-
let source = await readFile(routeFilePath, 'utf8')
|
|
666
|
+
let source = await readFile(routeFilePath, 'utf8');
|
|
667
|
+
!isBuild && 0 === cssAssets.length && /\.(?:css|less|sass|scss)(?:\?[^'"`]+)?['"`]/.test(source) && (cssAssets = [
|
|
668
|
+
`${DEFAULT_MANIFEST_DIR.replace('/js', '/css')}/${routeEntryName}.css`
|
|
669
|
+
]);
|
|
670
|
+
let code = await transformToEsm(source, routeFilePath);
|
|
657
671
|
if (exports = new Set(await getExportNames(code)), isBuild && routeChunkConfig) {
|
|
658
672
|
let { hasRouteChunkByExportName: chunkInfo } = await detectRouteChunksIfEnabled(routeChunkOptions?.cache, routeChunkConfig, routeFilePath, code);
|
|
659
673
|
hasRouteChunkByExportName = chunkInfo;
|
|
@@ -693,7 +707,7 @@ async function getReactRouterManifestForDev(routes, options, clientStats, contex
|
|
|
693
707
|
css: cssAssets.map((asset)=>combineURLs(assetPrefix, asset))
|
|
694
708
|
};
|
|
695
709
|
}
|
|
696
|
-
let entryAssets =
|
|
710
|
+
let entryAssets = getAssetsForChunk('entry.client'), entryJsAssets = entryAssets.filter((asset)=>asset.endsWith('.js')), entryCssAssets = entryAssets.filter((asset)=>asset.endsWith('.css')), fingerprintedValues = {
|
|
697
711
|
entry: {
|
|
698
712
|
module: combineURLs(assetPrefix, entryJsAssets[0] || ''),
|
|
699
713
|
imports: entryJsAssets.map((asset)=>combineURLs(assetPrefix, asset)),
|
|
@@ -1220,9 +1234,32 @@ let redirectStatusCodes = new Set([
|
|
|
1220
1234
|
});
|
|
1221
1235
|
}
|
|
1222
1236
|
});
|
|
1223
|
-
let allowedActionOriginsForBuild = !1 === allowedActionOrigins ? void 0 : allowedActionOrigins,
|
|
1224
|
-
|
|
1225
|
-
|
|
1237
|
+
let allowedActionOriginsForBuild = !1 === allowedActionOrigins ? void 0 : allowedActionOrigins, vmodTempDir = `rspack-virtual-module-${process.pid}-${Math.random().toString(16).slice(2)}`;
|
|
1238
|
+
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig })=>{
|
|
1239
|
+
var publicPath;
|
|
1240
|
+
let bundleVirtualModules, bundleManifestModules, vmodPlugin = (publicPath = assetPrefix = normalizeAssetPrefix(config.output?.assetPrefix), bundleVirtualModules = Object.fromEntries(Object.entries(routesByServerBundleId).map(([bundleId, bundleRoutes])=>[
|
|
1241
|
+
`virtual/react-router/server-build-${bundleId}`,
|
|
1242
|
+
generateServerBuild(bundleRoutes, {
|
|
1243
|
+
entryServerPath: finalEntryServerPath,
|
|
1244
|
+
assetsBuildDirectory,
|
|
1245
|
+
basename,
|
|
1246
|
+
appDirectory,
|
|
1247
|
+
ssr,
|
|
1248
|
+
federation: options.federation,
|
|
1249
|
+
future,
|
|
1250
|
+
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1251
|
+
prerender: prerenderPaths,
|
|
1252
|
+
routeDiscovery,
|
|
1253
|
+
publicPath,
|
|
1254
|
+
serverManifestId: `virtual/react-router/server-manifest-${bundleId}`
|
|
1255
|
+
})
|
|
1256
|
+
])), bundleManifestModules = Object.fromEntries(Object.entries(routesByServerBundleId).filter(([, bundleRoutes])=>bundleRoutes && Object.keys(bundleRoutes).length > 0).map(([bundleId])=>[
|
|
1257
|
+
`virtual/react-router/server-manifest-${bundleId}`,
|
|
1258
|
+
'export default {};'
|
|
1259
|
+
])), new RspackVirtualModulePlugin({
|
|
1260
|
+
'virtual/react-router/browser-manifest': 'export default {};',
|
|
1261
|
+
'virtual/react-router/server-manifest': 'export default {};',
|
|
1262
|
+
'virtual/react-router/server-build': generateServerBuild(routes, {
|
|
1226
1263
|
entryServerPath: finalEntryServerPath,
|
|
1227
1264
|
assetsBuildDirectory,
|
|
1228
1265
|
basename,
|
|
@@ -1233,31 +1270,11 @@ let redirectStatusCodes = new Set([
|
|
|
1233
1270
|
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1234
1271
|
prerender: prerenderPaths,
|
|
1235
1272
|
routeDiscovery,
|
|
1236
|
-
publicPath
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
'export default {};'
|
|
1242
|
-
])), vmodTempDir = `rspack-virtual-module-${process.pid}-${Math.random().toString(16).slice(2)}`, vmodPlugin = new RspackVirtualModulePlugin({
|
|
1243
|
-
'virtual/react-router/browser-manifest': 'export default {};',
|
|
1244
|
-
'virtual/react-router/server-manifest': 'export default {};',
|
|
1245
|
-
'virtual/react-router/server-build': generateServerBuild(routes, {
|
|
1246
|
-
entryServerPath: finalEntryServerPath,
|
|
1247
|
-
assetsBuildDirectory,
|
|
1248
|
-
basename,
|
|
1249
|
-
appDirectory,
|
|
1250
|
-
ssr,
|
|
1251
|
-
federation: options.federation,
|
|
1252
|
-
future,
|
|
1253
|
-
allowedActionOrigins: allowedActionOriginsForBuild,
|
|
1254
|
-
prerender: prerenderPaths,
|
|
1255
|
-
routeDiscovery,
|
|
1256
|
-
publicPath: assetPrefix
|
|
1257
|
-
}),
|
|
1258
|
-
...bundleVirtualModules,
|
|
1259
|
-
...bundleManifestModules,
|
|
1260
|
-
'virtual/react-router/with-props': `
|
|
1273
|
+
publicPath
|
|
1274
|
+
}),
|
|
1275
|
+
...bundleVirtualModules,
|
|
1276
|
+
...bundleManifestModules,
|
|
1277
|
+
'virtual/react-router/with-props': `
|
|
1261
1278
|
import { createElement as h } from "react";
|
|
1262
1279
|
import { useActionData, useLoaderData, useMatches, useParams, useRouteError } from "react-router";
|
|
1263
1280
|
|
|
@@ -1294,10 +1311,7 @@ let redirectStatusCodes = new Set([
|
|
|
1294
1311
|
};
|
|
1295
1312
|
}
|
|
1296
1313
|
`
|
|
1297
|
-
|
|
1298
|
-
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig })=>{
|
|
1299
|
-
assetPrefix = normalizeAssetPrefix(config.output?.assetPrefix);
|
|
1300
|
-
let useAsyncNodeChunkLoading = options.federation && 'commonjs' === resolvedServerOutput, nodeChunkLoading = 'module' === resolvedServerOutput ? 'import' : useAsyncNodeChunkLoading ? 'async-node' : 'require', serverBuildFileBase = (serverBuildFile || 'index.js').replace(/\.js$/, ''), nodeEntries = {
|
|
1314
|
+
}, vmodTempDir)), useAsyncNodeChunkLoading = options.federation && 'commonjs' === resolvedServerOutput, nodeChunkLoading = 'module' === resolvedServerOutput ? 'import' : useAsyncNodeChunkLoading ? 'async-node' : 'require', serverBuildFileBase = (serverBuildFile || 'index.js').replace(/\.js$/, ''), nodeEntries = {
|
|
1301
1315
|
...hasServerApp ? {
|
|
1302
1316
|
'static/js/app': serverAppPath
|
|
1303
1317
|
} : {
|
|
@@ -1364,10 +1378,6 @@ let redirectStatusCodes = new Set([
|
|
|
1364
1378
|
tools: {
|
|
1365
1379
|
rspack: {
|
|
1366
1380
|
name: 'web',
|
|
1367
|
-
experiments: {
|
|
1368
|
-
topLevelAwait: !0,
|
|
1369
|
-
outputModule: !0
|
|
1370
|
-
},
|
|
1371
1381
|
...options.federation ? {
|
|
1372
1382
|
output: {
|
|
1373
1383
|
chunkLoading: 'import'
|
|
@@ -1411,12 +1421,6 @@ let redirectStatusCodes = new Set([
|
|
|
1411
1421
|
dependencies: [
|
|
1412
1422
|
'web'
|
|
1413
1423
|
],
|
|
1414
|
-
experiments: {
|
|
1415
|
-
outputModule: 'module' === resolvedServerOutput,
|
|
1416
|
-
...options.federation ? {
|
|
1417
|
-
asyncStartup: !0
|
|
1418
|
-
} : {}
|
|
1419
|
-
},
|
|
1420
1424
|
externalsType: resolvedServerOutput,
|
|
1421
1425
|
output: {
|
|
1422
1426
|
chunkFormat: resolvedServerOutput,
|
|
@@ -1786,7 +1790,7 @@ let redirectStatusCodes = new Set([
|
|
|
1786
1790
|
let declaration = path.get('declaration'), expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
|
|
1787
1791
|
if (expr) {
|
|
1788
1792
|
let uid = getHocUid(path, 'withComponentProps');
|
|
1789
|
-
declaration.replaceWith(
|
|
1793
|
+
declaration.replaceWith(callExpression(uid, [
|
|
1790
1794
|
expr
|
|
1791
1795
|
]));
|
|
1792
1796
|
}
|
|
@@ -1800,7 +1804,7 @@ let redirectStatusCodes = new Set([
|
|
|
1800
1804
|
let { name } = id.node;
|
|
1801
1805
|
if (!isNamedComponentExport(name)) return;
|
|
1802
1806
|
let uid = getHocUid(path, `with${name}Props`);
|
|
1803
|
-
init.replaceWith(
|
|
1807
|
+
init.replaceWith(callExpression(uid, [
|
|
1804
1808
|
expr
|
|
1805
1809
|
]));
|
|
1806
1810
|
});
|
|
@@ -1810,15 +1814,15 @@ let redirectStatusCodes = new Set([
|
|
|
1810
1814
|
let { name } = id;
|
|
1811
1815
|
if (!isNamedComponentExport(name)) return;
|
|
1812
1816
|
let uid = getHocUid(path, `with${name}Props`);
|
|
1813
|
-
decl.replaceWith(
|
|
1814
|
-
|
|
1817
|
+
decl.replaceWith(variableDeclaration('const', [
|
|
1818
|
+
types_variableDeclarator(types_identifier(name), callExpression(uid, [
|
|
1815
1819
|
toFunctionExpression(decl.node)
|
|
1816
1820
|
]))
|
|
1817
1821
|
]));
|
|
1818
1822
|
}
|
|
1819
1823
|
}
|
|
1820
1824
|
}
|
|
1821
|
-
}), hocs.length > 0 && ast.program.body.unshift(
|
|
1825
|
+
}), hocs.length > 0 && ast.program.body.unshift(importDeclaration(hocs.map(([name, identifier])=>importSpecifier(identifier, types_identifier(name))), stringLiteral('virtual/react-router/with-props'))), 'web' === args.environment.name && (scopeCrawled = !1, traverse(ast, {
|
|
1822
1826
|
Program (path) {
|
|
1823
1827
|
scopeCrawled || (path.scope.crawl(), scopeCrawled = !0);
|
|
1824
1828
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hydrateRoot } from "react-dom/client";
|
|
2
2
|
import { HydratedRouter } from "react-router/dom";
|
|
3
|
-
import
|
|
4
|
-
startTransition(()=>{
|
|
5
|
-
hydrateRoot(document, createElement(StrictMode, null, createElement(HydratedRouter, null)));
|
|
3
|
+
import * as __rspack_external_react from "react";
|
|
4
|
+
__rspack_external_react.startTransition(()=>{
|
|
5
|
+
hydrateRoot(document, __rspack_external_react.createElement(__rspack_external_react.StrictMode, null, __rspack_external_react.createElement(HydratedRouter, null)));
|
|
6
6
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
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
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get"), define(values, "value");
|
|
9
12
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
10
13
|
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
11
14
|
value: 'Module'
|
|
@@ -2,11 +2,11 @@ import { PassThrough } from "node:stream";
|
|
|
2
2
|
import { createReadableStreamFromReadable } from "@react-router/node";
|
|
3
3
|
import { isbot } from "isbot";
|
|
4
4
|
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { ServerRouter } from "react-router";
|
|
6
|
+
import * as __rspack_external_react from "react";
|
|
7
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 && isbot(userAgent) || routerContext.isSpaMode ? 'onAllReady' : 'onShellReady', { pipe, abort } = renderToPipeableStream(createElement(ServerRouter, {
|
|
9
|
+
let shellRendered = !1, statusCode = responseStatusCode, userAgent = request.headers.get('user-agent'), readyOption = userAgent && isbot(userAgent) || routerContext.isSpaMode ? 'onAllReady' : 'onShellReady', { pipe, abort } = renderToPipeableStream(__rspack_external_react.createElement(ServerRouter, {
|
|
10
10
|
context: routerContext,
|
|
11
11
|
url: request.url
|
|
12
12
|
}), {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React Router plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/rstackjs/rsbuild-plugin-react-router.git",
|
|
8
8
|
"directory": ""
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@babel/types": "^7.28.6",
|
|
56
56
|
"@react-router/node": "^7.13.0",
|
|
57
57
|
"@remix-run/node-fetch-server": "^0.13.0",
|
|
58
|
-
"@rspack/plugin-react-refresh": "^
|
|
58
|
+
"@rspack/plugin-react-refresh": "^2.0.2",
|
|
59
59
|
"babel-dead-code-elimination": "^1.0.12",
|
|
60
60
|
"esbuild": "^0.27.2",
|
|
61
61
|
"execa": "^9.6.1",
|
|
@@ -70,9 +70,10 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@changesets/cli": "^2.29.8",
|
|
72
72
|
"@react-router/dev": "^7.13.0",
|
|
73
|
-
"@rsbuild/core": "
|
|
74
|
-
"@rslib/core": "^0.
|
|
75
|
-
"@rspack/core": "
|
|
73
|
+
"@rsbuild/core": "2.0.15",
|
|
74
|
+
"@rslib/core": "^0.22.1",
|
|
75
|
+
"@rspack/core": "2.0.8",
|
|
76
|
+
"@swc/helpers": "^0.5.23",
|
|
76
77
|
"@rstest/core": "^0.8.1",
|
|
77
78
|
"@rstest/coverage-istanbul": "^0.2.0",
|
|
78
79
|
"@types/babel__core": "^7.20.5",
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
"@rsbuild/config": "1.0.1"
|
|
96
97
|
},
|
|
97
98
|
"peerDependencies": {
|
|
98
|
-
"@rsbuild/core": "^
|
|
99
|
+
"@rsbuild/core": "^2.0.0"
|
|
99
100
|
},
|
|
100
101
|
"publishConfig": {
|
|
101
102
|
"access": "public",
|
package/dist/906.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ServerRouter, createRequestHandler, matchRoutes } from "react-router";
|
package/dist/946.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { StrictMode, createElement, startTransition } from "react";
|
package/dist/rslib-runtime.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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__ };
|