rsbuild-plugin-react-router 0.4.0 → 0.5.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/README.md +17 -35
- package/dist/{451.js → 511.js} +92 -1
- package/dist/build-output-transforms.d.ts +4 -3
- package/dist/dev-background-resources.d.ts +1 -3
- package/dist/federation.d.ts +2 -0
- package/dist/index.cjs +153 -335
- package/dist/index.js +129 -407
- package/dist/performance.d.ts +4 -1
- package/dist/route-module-transform-loader.d.ts +14 -0
- package/dist/route-module-transform-loader.js +44 -0
- package/dist/route-module-transform-rules.d.ts +14 -0
- package/dist/route-transform-tasks.d.ts +1 -0
- package/dist/types.d.ts +4 -5
- package/package.json +13 -14
- package/src/build-output-transforms.ts +28 -24
- package/src/dev-background-resources.ts +1 -16
- package/src/federation.ts +38 -0
- package/src/index.ts +38 -57
- package/src/performance.ts +11 -2
- package/src/route-module-transform-loader.ts +149 -0
- package/src/route-module-transform-rules.ts +115 -0
- package/src/route-transform-tasks.ts +5 -4
- package/src/types.ts +4 -5
- package/dist/parallel-route-transform-protocol.d.ts +0 -25
- package/dist/parallel-route-transform-worker.d.ts +0 -1
- package/dist/parallel-route-transform-worker.js +0 -38
- package/dist/parallel-route-transforms.d.ts +0 -29
- package/src/parallel-route-transform-protocol.ts +0 -35
- package/src/parallel-route-transform-worker.ts +0 -82
- package/src/parallel-route-transforms.ts +0 -458
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let globalStore, o, origin, bigint1e6, characters, charactersLength, O, quoteValue,
|
|
1
|
+
let globalStore, o, origin, bigint1e6, characters, charactersLength, O, quoteValue, options, options1, f;
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, realpathSync, watch, writeFileSync } from "node:fs";
|
|
3
3
|
import fs_extra from "fs-extra";
|
|
4
4
|
import { rspack } from "@rsbuild/core";
|
|
@@ -7,13 +7,13 @@ import { dirname, isAbsolute, join as external_pathe_join, relative, resolve as
|
|
|
7
7
|
import { availableParallelism, cpus } from "node:os";
|
|
8
8
|
import { createRequestHandler as external_react_router_createRequestHandler, matchRoutes } from "react-router";
|
|
9
9
|
import { access, mkdir, readdir, writeFile } from "node:fs/promises";
|
|
10
|
-
import { pathToFileURL, fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
10
|
+
import { fileURLToPath, pathToFileURL, fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import jsesc from "jsesc";
|
|
13
|
-
import { Worker } from "node:worker_threads";
|
|
14
13
|
import { createRequire } from "node:module";
|
|
15
14
|
import { dirname as external_node_path_dirname, isAbsolute as external_node_path_isAbsolute, relative as external_node_path_relative, resolve as external_node_path_resolve, sep as external_node_path_sep, dirname as __rspack_dirname } from "node:path";
|
|
16
|
-
import { createRouteId, HMR_PATCHABLE_ROUTE_FLAGS, SERVER_EXPORTS, combineURLs, JS_EXTENSIONS, executeRouteTransformTask,
|
|
15
|
+
import { createRouteId, HMR_PATCHABLE_ROUTE_FLAGS, SERVER_EXPORTS, combineURLs, JS_EXTENSIONS, executeRouteTransformTask, PLUGIN_NAME, generateWithProps, getRouteModuleAnalysis, createEmptyRouteChunkByExportName, findEntryFile, routeChunkExportNames, validateRouteChunks, CLIENT_EXPORTS, buildManifestChunkValidity, BUILD_CLIENT_ROUTE_QUERY_STRING, getRouteChunkEntryName, getRouteChunkModuleId, normalizeAssetPrefix, detectRouteChunksIfEnabled, roundMs, createBundlerRouteExportResolver, createReactRouterPerformanceProfiler } from "./511.js";
|
|
16
|
+
var description, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
17
17
|
let getAvailableCpuCount = ()=>'function' == typeof availableParallelism ? availableParallelism() : cpus().length, getDefaultConcurrency = (cpuCount = getAvailableCpuCount())=>Math.max(0, Math.floor(cpuCount) - 2), getCappedPluginConcurrency = (cap = 16)=>Math.max(1, Math.min(cap, getDefaultConcurrency() || 1)), createReactRouterHydrationModuleTest = (entryClientPath)=>{
|
|
18
18
|
let eagerPatterns = [
|
|
19
19
|
'virtual/react-router/browser-manifest',
|
|
@@ -269,7 +269,7 @@ function compareBoth(self, that) {
|
|
|
269
269
|
}
|
|
270
270
|
if (structuralRegionState.enabled) {
|
|
271
271
|
if (null === self || null === that) return !1;
|
|
272
|
-
if (Array.isArray(self) && Array.isArray(that)) return self.length === that.length && self.every((
|
|
272
|
+
if (Array.isArray(self) && Array.isArray(that)) return self.length === that.length && self.every((v, i)=>compareBoth(v, that[i]));
|
|
273
273
|
if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(that) === Object.prototype) {
|
|
274
274
|
let keysSelf = Object.keys(self), keysThat = Object.keys(that);
|
|
275
275
|
if (keysSelf.length === keysThat.length) {
|
|
@@ -834,14 +834,14 @@ let stack_make = (value, previous)=>({
|
|
|
834
834
|
value,
|
|
835
835
|
previous
|
|
836
836
|
});
|
|
837
|
-
function arrayUpdate(mutate, at,
|
|
837
|
+
function arrayUpdate(mutate, at, v, arr) {
|
|
838
838
|
let out = arr;
|
|
839
839
|
if (!mutate) {
|
|
840
840
|
let len = arr.length;
|
|
841
841
|
out = Array(len);
|
|
842
842
|
for(let i = 0; i < len; ++i)out[i] = arr[i];
|
|
843
843
|
}
|
|
844
|
-
return out[at] =
|
|
844
|
+
return out[at] = v, out;
|
|
845
845
|
}
|
|
846
846
|
function arraySpliceOut(mutate, at, arr) {
|
|
847
847
|
let newLen = arr.length - 1, i = 0, g = 0, out = arr;
|
|
@@ -853,8 +853,8 @@ function arraySpliceOut(mutate, at, arr) {
|
|
|
853
853
|
class EmptyNode {
|
|
854
854
|
_tag = "EmptyNode";
|
|
855
855
|
modify(edit, _shift, f, hash, key, size) {
|
|
856
|
-
let
|
|
857
|
-
return isNone(
|
|
856
|
+
let v = f(Option_none());
|
|
857
|
+
return isNone(v) ? new EmptyNode() : (++size.value, new LeafNode(edit, hash, key, v));
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
860
|
function isEmptyNode(a) {
|
|
@@ -874,11 +874,11 @@ class LeafNode {
|
|
|
874
874
|
}
|
|
875
875
|
modify(edit, shift, f, hash, key, size) {
|
|
876
876
|
if (equals(key, this.key)) {
|
|
877
|
-
let
|
|
878
|
-
return
|
|
877
|
+
let v = f(this.value);
|
|
878
|
+
return v === this.value ? this : isNone(v) ? (--size.value, new EmptyNode()) : canEditNode(this, edit) ? (this.value = v, this) : new LeafNode(edit, hash, key, v);
|
|
879
879
|
}
|
|
880
|
-
let
|
|
881
|
-
return isNone(
|
|
880
|
+
let v = f(Option_none());
|
|
881
|
+
return isNone(v) ? this : (++size.value, mergeLeaves(edit, shift, this.hash, this, hash, new LeafNode(edit, hash, key, v)));
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
class CollisionNode {
|
|
@@ -894,8 +894,8 @@ class CollisionNode {
|
|
|
894
894
|
let canEdit = canEditNode(this, edit), list = this.updateCollisionList(canEdit, edit, this.hash, this.children, f, key, size);
|
|
895
895
|
return list === this.children ? this : list.length > 1 ? new CollisionNode(edit, this.hash, list) : list[0];
|
|
896
896
|
}
|
|
897
|
-
let
|
|
898
|
-
return isNone(
|
|
897
|
+
let v = f(Option_none());
|
|
898
|
+
return isNone(v) ? this : (++size.value, mergeLeaves(edit, shift, this.hash, this, hash, new LeafNode(edit, hash, key, v)));
|
|
899
899
|
}
|
|
900
900
|
updateCollisionList(mutate, edit, hash, list, f, key, size) {
|
|
901
901
|
let len = list.length;
|
|
@@ -928,16 +928,16 @@ class IndexedNode {
|
|
|
928
928
|
let arr = [], bit = bitmap, count = 0;
|
|
929
929
|
for(let i = 0; bit; ++i)1 & bit && (arr[i] = subNodes[count++]), bit >>>= 1;
|
|
930
930
|
return arr[frag] = child, new ArrayNode(edit, count + 1, arr);
|
|
931
|
-
}(edit, frag, _newChild, mask, children) : new IndexedNode(edit, mask | bit, function(mutate, at,
|
|
931
|
+
}(edit, frag, _newChild, mask, children) : new IndexedNode(edit, mask | bit, function(mutate, at, v, arr) {
|
|
932
932
|
let len = arr.length;
|
|
933
933
|
if (mutate) {
|
|
934
934
|
let i = len;
|
|
935
935
|
for(; i >= at;)arr[i--] = arr[i];
|
|
936
|
-
return arr[at] =
|
|
936
|
+
return arr[at] = v, arr;
|
|
937
937
|
}
|
|
938
938
|
let i = 0, g = 0, out = Array(len + 1);
|
|
939
939
|
for(; i < at;)out[g++] = arr[i++];
|
|
940
|
-
for(out[at] =
|
|
940
|
+
for(out[at] = v; i < len;)out[++g] = arr[i++];
|
|
941
941
|
return out;
|
|
942
942
|
}(canEdit, indx, _newChild, children)) : this;
|
|
943
943
|
}
|
|
@@ -1010,9 +1010,9 @@ function mergeLeaves(edit, shift, h1, n1, h2, n2) {
|
|
|
1010
1010
|
let HashMapSymbolKey = "effect/HashMap", HashMapTypeId = Symbol.for(HashMapSymbolKey), HashMapProto = {
|
|
1011
1011
|
[HashMapTypeId]: HashMapTypeId,
|
|
1012
1012
|
[Symbol.iterator] () {
|
|
1013
|
-
return new HashMapIterator(this, (k,
|
|
1013
|
+
return new HashMapIterator(this, (k, v)=>[
|
|
1014
1014
|
k,
|
|
1015
|
-
|
|
1015
|
+
v
|
|
1016
1016
|
]);
|
|
1017
1017
|
},
|
|
1018
1018
|
[Hash_symbol] () {
|
|
@@ -3322,14 +3322,14 @@ let nativeTracer = {
|
|
|
3322
3322
|
shuffle(elements) {
|
|
3323
3323
|
return shuffleWith(elements, (n)=>this.nextIntBetween(0, n));
|
|
3324
3324
|
}
|
|
3325
|
-
}(Hash_hash(Math.random()))), context_add(configProviderTag, ((
|
|
3326
|
-
let
|
|
3325
|
+
}(Hash_hash(Math.random()))), context_add(configProviderTag, (()=>{
|
|
3326
|
+
let options, { pathDelim, seqDelim } = Object.assign({}, {
|
|
3327
3327
|
pathDelim: "_",
|
|
3328
3328
|
seqDelim: ","
|
|
3329
|
-
},
|
|
3329
|
+
}, void 0), getEnv = ()=>"u" > typeof process && "env" in process && "object" == typeof process.env ? process.env : {};
|
|
3330
3330
|
var flat = {
|
|
3331
3331
|
[FlatConfigProviderTypeId]: FlatConfigProviderTypeId,
|
|
3332
|
-
patch: (
|
|
3332
|
+
patch: (options = {
|
|
3333
3333
|
load: (path, primitive, split = !0)=>{
|
|
3334
3334
|
let pathString = Function_pipe(path, join(pathDelim)), current = getEnv();
|
|
3335
3335
|
return Function_pipe(pathString in current ? option_some(current[pathString]) : Option_none(), mapError(()=>MissingData(path, `Expected ${pathString} to exist in the process context`)), core_flatMap((value)=>{
|
|
@@ -3355,8 +3355,8 @@ let nativeTracer = {
|
|
|
3355
3355
|
}),
|
|
3356
3356
|
patch: pathPatch_empty
|
|
3357
3357
|
}).patch,
|
|
3358
|
-
load: (path, config, split = !0)=>
|
|
3359
|
-
enumerateChildren:
|
|
3358
|
+
load: (path, config, split = !0)=>options.load(path, config, split),
|
|
3359
|
+
enumerateChildren: options.enumerateChildren
|
|
3360
3360
|
};
|
|
3361
3361
|
return {
|
|
3362
3362
|
[ConfigProviderTypeId]: ConfigProviderTypeId,
|
|
@@ -4294,11 +4294,11 @@ let currentFiberURI = "effect/FiberCurrent", LoggerTypeId = Symbol.for("effect/L
|
|
|
4294
4294
|
let formatValue = (value)=>value.match(textOnly) ? value : quoteValue(value), format = (label, value)=>`${formatLabel(label)}=${formatValue(value)}`, append = (label, value)=>" " + format(label, value), out = format("timestamp", date.toISOString());
|
|
4295
4295
|
out += append("level", logLevel.label), out += append("fiber", threadName(fiberId));
|
|
4296
4296
|
let messages = ensure(message);
|
|
4297
|
-
for(let i = 0; i < messages.length; i++)out += append("message", toStringUnknown(messages[i],
|
|
4297
|
+
for(let i = 0; i < messages.length; i++)out += append("message", toStringUnknown(messages[i], void 0));
|
|
4298
4298
|
for (let span of ("Empty" !== cause._tag && (out += append("cause", pretty(cause, {
|
|
4299
4299
|
renderErrorCause: !0
|
|
4300
4300
|
}))), spans))out += " " + logSpan_render(date.getTime())(span);
|
|
4301
|
-
for (let [label, value] of annotations)out += append(label, toStringUnknown(value,
|
|
4301
|
+
for (let [label, value] of annotations)out += append(label, toStringUnknown(value, void 0));
|
|
4302
4302
|
return out;
|
|
4303
4303
|
}));
|
|
4304
4304
|
"object" == typeof process && null !== process && "object" == typeof process.stdout && null !== process.stdout && process.stdout.isTTY;
|
|
@@ -4654,11 +4654,11 @@ class MetricRegistryImpl {
|
|
|
4654
4654
|
if (null == value) {
|
|
4655
4655
|
let value1, gauge = (value1 = key.keyType.bigint ? BigInt(0) : 0, hook_make({
|
|
4656
4656
|
get: ()=>new GaugeState(value1),
|
|
4657
|
-
update: (
|
|
4658
|
-
value1 =
|
|
4657
|
+
update: (v)=>{
|
|
4658
|
+
value1 = v;
|
|
4659
4659
|
},
|
|
4660
|
-
modify: (
|
|
4661
|
-
value1 +=
|
|
4660
|
+
modify: (v)=>{
|
|
4661
|
+
value1 += v;
|
|
4662
4662
|
}
|
|
4663
4663
|
}));
|
|
4664
4664
|
Function_pipe(this.map, MutableHashMap_has(key)) || Function_pipe(this.map, MutableHashMap_set(key, gauge)), value = gauge;
|
|
@@ -4725,8 +4725,8 @@ class MetricRegistryImpl {
|
|
|
4725
4725
|
for(; i !== maxSize - 1;){
|
|
4726
4726
|
let item = values[i];
|
|
4727
4727
|
if (null != item) {
|
|
4728
|
-
let [t,
|
|
4729
|
-
Duration_greaterThanOrEqualTo(age, Duration_zero) && Duration_lessThanOrEqualTo(age, maxAge) && builder.push(
|
|
4728
|
+
let [t, v] = item, age = Duration_millis(now - t);
|
|
4729
|
+
Duration_greaterThanOrEqualTo(age, Duration_zero) && Duration_lessThanOrEqualTo(age, maxAge) && builder.push(v);
|
|
4730
4730
|
}
|
|
4731
4731
|
i += 1;
|
|
4732
4732
|
}
|
|
@@ -4990,11 +4990,7 @@ let track = sync(()=>new Track()), supervisor_none = GlobalValue_globalValue("ef
|
|
|
4990
4990
|
incremental: !0
|
|
4991
4991
|
}), fiberFailures = metric_counter("effect_fiber_failures", {
|
|
4992
4992
|
incremental: !0
|
|
4993
|
-
}), fiberLifetimes = metric_tagged(fromMetricKey((
|
|
4994
|
-
start: 0.5,
|
|
4995
|
-
factor: 2,
|
|
4996
|
-
count: 35
|
|
4997
|
-
}).count - 1, (i)=>options.start * Math.pow(options.factor, i)), unsafeFromArray, (iterable)=>new MetricBoundariesImpl(Function_pipe(iterable, Array_appendAll(Chunk_of(1 / 0)), Array_dedupe))), new MetricKeyImpl("effect_fiber_lifetimes", new class HistogramKeyType {
|
|
4993
|
+
}), fiberLifetimes = metric_tagged(fromMetricKey((description = void 0, new MetricKeyImpl("effect_fiber_lifetimes", new class HistogramKeyType {
|
|
4998
4994
|
boundaries;
|
|
4999
4995
|
[MetricKeyTypeTypeId] = metricKeyTypeVariance;
|
|
5000
4996
|
[HistogramKeyTypeTypeId] = HistogramKeyTypeTypeId;
|
|
@@ -5011,7 +5007,11 @@ let track = sync(()=>new Track()), supervisor_none = GlobalValue_globalValue("ef
|
|
|
5011
5007
|
pipe() {
|
|
5012
5008
|
return Pipeable_pipeArguments(this, arguments);
|
|
5013
5009
|
}
|
|
5014
|
-
}(
|
|
5010
|
+
}(Function_pipe(Array_makeBy((options = {
|
|
5011
|
+
start: 0.5,
|
|
5012
|
+
factor: 2,
|
|
5013
|
+
count: 35
|
|
5014
|
+
}).count - 1, (i)=>options.start * Math.pow(options.factor, i)), unsafeFromArray, (iterable)=>new MetricBoundariesImpl(Function_pipe(iterable, Array_appendAll(Chunk_of(1 / 0)), Array_dedupe)))), Option_fromNullable(description)))), "time_unit", "milliseconds"), EvaluationSignalContinue = "Continue", EvaluationSignalYieldNow = "Yield", runtimeFiberVariance = {
|
|
5015
5015
|
_E: (_)=>_,
|
|
5016
5016
|
_A: (_)=>_
|
|
5017
5017
|
}, fiberRuntime_absurd = (_)=>{
|
|
@@ -5398,18 +5398,9 @@ class FiberRuntime extends Effectable_Class {
|
|
|
5398
5398
|
}
|
|
5399
5399
|
Micro(op) {
|
|
5400
5400
|
return unsafeAsync((microResume)=>{
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
else {
|
|
5405
|
-
let abort = ()=>fiber.unsafeInterrupt();
|
|
5406
|
-
options.signal.addEventListener("abort", abort, {
|
|
5407
|
-
once: !0
|
|
5408
|
-
}), fiber.addObserver(()=>options.signal.removeEventListener("abort", abort));
|
|
5409
|
-
}
|
|
5410
|
-
return fiber;
|
|
5411
|
-
})(Micro_provideContext(op, this.currentContext));
|
|
5412
|
-
return fiber.addObserver((exit)=>{
|
|
5401
|
+
var effect;
|
|
5402
|
+
let fiber, resume = microResume, fiber1 = (effect = Micro_provideContext(op, this.currentContext), (fiber = new MicroFiberImpl(CurrentScheduler.context((void 0) ?? new MicroSchedulerDefault()))).evaluate(effect), fiber);
|
|
5403
|
+
return fiber1.addObserver((exit)=>{
|
|
5413
5404
|
if ("Success" === exit._tag) return resume(exitSucceed(exit.value));
|
|
5414
5405
|
switch(exit.cause._tag){
|
|
5415
5406
|
case "Interrupt":
|
|
@@ -5422,7 +5413,7 @@ class FiberRuntime extends Effectable_Class {
|
|
|
5422
5413
|
}), unsafeAsync((abortResume)=>{
|
|
5423
5414
|
resume = (_)=>{
|
|
5424
5415
|
abortResume(core_void_);
|
|
5425
|
-
},
|
|
5416
|
+
}, fiber1.unsafeInterrupt();
|
|
5426
5417
|
});
|
|
5427
5418
|
});
|
|
5428
5419
|
}
|
|
@@ -7574,218 +7565,18 @@ function isSourceMapEnabled(value) {
|
|
|
7574
7565
|
function getDevtoolFromRspackConfig(config) {
|
|
7575
7566
|
if (config && 'function' != typeof config && 'object' == typeof config) return config.devtool;
|
|
7576
7567
|
}
|
|
7577
|
-
|
|
7578
|
-
if (
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
7586
|
-
return descriptor.get ? descriptor.get.call(receiver) : descriptor.value;
|
|
7587
|
-
}
|
|
7588
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
7589
|
-
_check_private_redeclaration(obj, privateMap), privateMap.set(obj, value);
|
|
7590
|
-
}
|
|
7591
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
7592
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
7593
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
7594
|
-
else {
|
|
7595
|
-
if (!descriptor.writable) throw TypeError("attempted to set read only private field");
|
|
7596
|
-
descriptor.value = value;
|
|
7597
|
-
}
|
|
7598
|
-
return value;
|
|
7599
|
-
}
|
|
7600
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
7601
|
-
if (!privateSet.has(receiver)) throw TypeError("attempted to get private field on non-instance");
|
|
7602
|
-
return fn;
|
|
7603
|
-
}
|
|
7604
|
-
function _class_private_method_init(obj, privateSet) {
|
|
7605
|
-
_check_private_redeclaration(obj, privateSet), privateSet.add(obj);
|
|
7606
|
-
}
|
|
7607
|
-
function _define_property(obj, key, value) {
|
|
7608
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
7609
|
-
value: value,
|
|
7610
|
-
enumerable: !0,
|
|
7611
|
-
configurable: !0,
|
|
7612
|
-
writable: !0
|
|
7613
|
-
}) : obj[key] = value, obj;
|
|
7614
|
-
}
|
|
7615
|
-
class WorkerStartupError extends Error {
|
|
7616
|
-
constructor(message){
|
|
7617
|
-
super(message), this.name = 'WorkerStartupError';
|
|
7618
|
-
}
|
|
7619
|
-
}
|
|
7620
|
-
let createDefaultWorker = ()=>new Worker(new URL('./parallel-route-transform-worker.js', import.meta.url)), createWorkerStartupError = (error)=>{
|
|
7621
|
-
let normalized = normalizeEffectError(error), startupError = new WorkerStartupError(normalized.message);
|
|
7622
|
-
return startupError.stack = normalized.stack, startupError;
|
|
7623
|
-
}, rejectPendingTasks = (state, error)=>{
|
|
7624
|
-
for (let pending of state.pending.values())pending.reject(error);
|
|
7625
|
-
state.pending.clear();
|
|
7626
|
-
}, createInlineRouteTransformExecutor = (options)=>({
|
|
7627
|
-
run: (task)=>executeRouteTransformTask(task, options),
|
|
7628
|
-
prewarm: ()=>{},
|
|
7629
|
-
close: async ()=>{}
|
|
7630
|
-
});
|
|
7631
|
-
var _closed = new WeakMap(), _closePromise = new WeakMap(), _workersDisabled = new WeakMap(), _nextId = new WeakMap(), _nextRouteSourceWorkerIndex = new WeakMap(), _routeSourceWorkers = new WeakMap(), _workers = new WeakMap(), _prewarmScheduled = new WeakMap(), _prewarmWorkers = new WeakSet(), _disableWorkers = new WeakSet(), _createWorkerState = new WeakSet(), _getWorker = new WeakSet(), _runInWorker = new WeakSet(), _createWorkerRequestTask = new WeakSet(), _getWorkerIndex = new WeakSet(), _getRouteSourceWorkerIndex = new WeakSet();
|
|
7632
|
-
class ParallelRouteTransformExecutor {
|
|
7633
|
-
async run(task) {
|
|
7634
|
-
if (_class_private_field_get(this, _closed) || 'clientOnlyStub' === task.kind && task.resolveExportAllModule) return executeRouteTransformTask(task, this.options);
|
|
7635
|
-
try {
|
|
7636
|
-
return await _class_private_method_get(this, _runInWorker, runInWorker).call(this, task);
|
|
7637
|
-
} catch (error) {
|
|
7638
|
-
if (error instanceof WorkerStartupError) return executeRouteTransformTask(task, this.options);
|
|
7639
|
-
throw error;
|
|
7640
|
-
}
|
|
7641
|
-
}
|
|
7642
|
-
prewarm() {
|
|
7643
|
-
_class_private_field_get(this, _prewarmScheduled) || _class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled) || (_class_private_field_set(this, _prewarmScheduled, !0), _class_private_method_get(this, _prewarmWorkers, prewarmWorkers).call(this));
|
|
7644
|
-
}
|
|
7645
|
-
close() {
|
|
7646
|
-
if (_class_private_field_get(this, _closePromise)) return _class_private_field_get(this, _closePromise);
|
|
7647
|
-
_class_private_field_set(this, _closed, !0);
|
|
7648
|
-
let workers = (_class_private_field_get(this, _workers) ?? []).filter((state)=>!!state);
|
|
7649
|
-
return _class_private_field_set(this, _workers, []), _class_private_field_set(this, _closePromise, Promise.all(workers.map(async (state)=>{
|
|
7650
|
-
rejectPendingTasks(state, Error('Route transform worker closed.')), await state.worker.terminate();
|
|
7651
|
-
})).then(()=>void 0)), _class_private_field_get(this, _closePromise);
|
|
7652
|
-
}
|
|
7653
|
-
constructor(workerCount, options, balanceRouteModuleTransforms, createWorker){
|
|
7654
|
-
_class_private_method_init(this, _prewarmWorkers), _class_private_method_init(this, _disableWorkers), _class_private_method_init(this, _createWorkerState), _class_private_method_init(this, _getWorker), _class_private_method_init(this, _runInWorker), _class_private_method_init(this, _createWorkerRequestTask), _class_private_method_init(this, _getWorkerIndex), _class_private_method_init(this, _getRouteSourceWorkerIndex), _define_property(this, "workerCount", void 0), _define_property(this, "options", void 0), _define_property(this, "balanceRouteModuleTransforms", void 0), _define_property(this, "createWorker", void 0), _class_private_field_init(this, _closed, {
|
|
7655
|
-
writable: !0,
|
|
7656
|
-
value: void 0
|
|
7657
|
-
}), _class_private_field_init(this, _closePromise, {
|
|
7658
|
-
writable: !0,
|
|
7659
|
-
value: void 0
|
|
7660
|
-
}), _class_private_field_init(this, _workersDisabled, {
|
|
7661
|
-
writable: !0,
|
|
7662
|
-
value: void 0
|
|
7663
|
-
}), _class_private_field_init(this, _nextId, {
|
|
7664
|
-
writable: !0,
|
|
7665
|
-
value: void 0
|
|
7666
|
-
}), _class_private_field_init(this, _nextRouteSourceWorkerIndex, {
|
|
7667
|
-
writable: !0,
|
|
7668
|
-
value: void 0
|
|
7669
|
-
}), _class_private_field_init(this, _routeSourceWorkers, {
|
|
7670
|
-
writable: !0,
|
|
7671
|
-
value: void 0
|
|
7672
|
-
}), _class_private_field_init(this, _workers, {
|
|
7673
|
-
writable: !0,
|
|
7674
|
-
value: void 0
|
|
7675
|
-
}), _class_private_field_init(this, _prewarmScheduled, {
|
|
7676
|
-
writable: !0,
|
|
7677
|
-
value: void 0
|
|
7678
|
-
}), this.workerCount = workerCount, this.options = options, this.balanceRouteModuleTransforms = balanceRouteModuleTransforms, this.createWorker = createWorker, _class_private_field_set(this, _closed, !1), _class_private_field_set(this, _workersDisabled, !1), _class_private_field_set(this, _nextId, 1), _class_private_field_set(this, _nextRouteSourceWorkerIndex, 0), _class_private_field_set(this, _routeSourceWorkers, new Map()), _class_private_field_set(this, _prewarmScheduled, !1);
|
|
7679
|
-
}
|
|
7680
|
-
}
|
|
7681
|
-
async function prewarmWorkers() {
|
|
7682
|
-
try {
|
|
7683
|
-
for(let index = 0; index < this.workerCount; index += 1){
|
|
7684
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
7685
|
-
try {
|
|
7686
|
-
_class_private_method_get(this, _getWorker, getWorker).call(this, index);
|
|
7687
|
-
} catch (error) {
|
|
7688
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, createWorkerStartupError(error));
|
|
7689
|
-
return;
|
|
7690
|
-
}
|
|
7691
|
-
}
|
|
7692
|
-
} finally{
|
|
7693
|
-
_class_private_field_set(this, _prewarmScheduled, !1);
|
|
7694
|
-
}
|
|
7695
|
-
}
|
|
7696
|
-
function disableWorkers(error) {
|
|
7697
|
-
if (_class_private_field_get(this, _workersDisabled) || _class_private_field_get(this, _closed)) return;
|
|
7698
|
-
_class_private_field_set(this, _workersDisabled, !0);
|
|
7699
|
-
let workers = (_class_private_field_get(this, _workers) ?? []).filter((state)=>!!state);
|
|
7700
|
-
for (let state of (_class_private_field_set(this, _workers, []), workers))rejectPendingTasks(state, error), state.worker.terminate();
|
|
7701
|
-
}
|
|
7702
|
-
function createWorkerState() {
|
|
7703
|
-
let worker = this.createWorker(), state = {
|
|
7704
|
-
worker,
|
|
7705
|
-
pending: new Map(),
|
|
7706
|
-
sourceCache: new Map()
|
|
7707
|
-
};
|
|
7708
|
-
return worker.on('message', (response)=>{
|
|
7709
|
-
let pending = state.pending.get(response.id);
|
|
7710
|
-
if (pending) if (state.pending.delete(response.id), response.ok) pending.resolve(response.result);
|
|
7711
|
-
else {
|
|
7712
|
-
var error;
|
|
7713
|
-
let result;
|
|
7714
|
-
pending.reject(((result = Error((error = response.error).message)).name = error.name ?? 'Error', error.stack && (result.stack = error.stack), result));
|
|
7715
|
-
}
|
|
7716
|
-
}), worker.on('error', (error)=>{
|
|
7717
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, createWorkerStartupError(error));
|
|
7718
|
-
}), worker.on('exit', (code)=>{
|
|
7719
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
7720
|
-
let startupError = new WorkerStartupError(`Route transform worker exited with code ${code}.`);
|
|
7721
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, startupError);
|
|
7722
|
-
}), state;
|
|
7723
|
-
}
|
|
7724
|
-
function getWorker(index) {
|
|
7725
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
7726
|
-
_class_private_field_set(this, _workers, _class_private_field_get(this, _workers) ?? Array(this.workerCount));
|
|
7727
|
-
let existingWorker = _class_private_field_get(this, _workers)[index];
|
|
7728
|
-
if (existingWorker) return existingWorker;
|
|
7729
|
-
let worker = _class_private_method_get(this, _createWorkerState, createWorkerState).call(this);
|
|
7730
|
-
return _class_private_field_get(this, _workers)[index] = worker, worker;
|
|
7731
|
-
}
|
|
7732
|
-
function runInWorker(task) {
|
|
7733
|
-
let workerIndex = _class_private_method_get(this, _getWorkerIndex, getWorkerIndex).call(this, task, this.workerCount), state = _class_private_method_get(this, _getWorker, getWorker).call(this, workerIndex);
|
|
7734
|
-
if (!state) return executeRouteTransformTask(task, this.options);
|
|
7735
|
-
let id = function(receiver, privateMap) {
|
|
7736
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "update");
|
|
7737
|
-
if (descriptor.set) {
|
|
7738
|
-
if (!descriptor.get) throw TypeError("attempted to read set only private field");
|
|
7739
|
-
return "__destrWrapper" in descriptor || (descriptor.__destrWrapper = {
|
|
7740
|
-
set value (v){
|
|
7741
|
-
descriptor.set.call(receiver, v);
|
|
7742
|
-
},
|
|
7743
|
-
get value () {
|
|
7744
|
-
return descriptor.get.call(receiver);
|
|
7745
|
-
}
|
|
7746
|
-
}), descriptor.__destrWrapper;
|
|
7747
|
-
}
|
|
7748
|
-
if (!descriptor.writable) throw TypeError("attempted to set read only private field");
|
|
7749
|
-
return descriptor;
|
|
7750
|
-
}(this, _nextId).value++, sourceCacheKey = task.resourcePath, requestTask = _class_private_method_get(this, _createWorkerRequestTask, createWorkerRequestTask).call(this, state, task, sourceCacheKey);
|
|
7751
|
-
return new Promise((resolve, reject)=>{
|
|
7752
|
-
state.pending.set(id, {
|
|
7753
|
-
resolve,
|
|
7754
|
-
reject
|
|
7755
|
-
});
|
|
7756
|
-
try {
|
|
7757
|
-
state.worker.postMessage({
|
|
7758
|
-
id,
|
|
7759
|
-
task: requestTask,
|
|
7760
|
-
sourceCacheKey
|
|
7761
|
-
});
|
|
7762
|
-
} catch (error) {
|
|
7763
|
-
state.pending.delete(id), state.sourceCache.delete(sourceCacheKey), reject(normalizeEffectError(error));
|
|
7568
|
+
let routeModuleTransformLoaderPath = fileURLToPath(new URL('./route-module-transform-loader.js', import.meta.url)), getRouteModuleTransformParallel = (parallelRouteTransform)=>{
|
|
7569
|
+
if (void 0 !== parallelRouteTransform && !1 !== parallelRouteTransform) {
|
|
7570
|
+
if (!0 === parallelRouteTransform) return !0;
|
|
7571
|
+
if ('number' == typeof parallelRouteTransform) {
|
|
7572
|
+
if (!Number.isInteger(parallelRouteTransform) || parallelRouteTransform < 1) throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
7573
|
+
return {
|
|
7574
|
+
maxWorkers: parallelRouteTransform
|
|
7575
|
+
};
|
|
7764
7576
|
}
|
|
7765
|
-
|
|
7766
|
-
}
|
|
7767
|
-
function createWorkerRequestTask(state, task, sourceCacheKey) {
|
|
7768
|
-
if (state.sourceCache.get(sourceCacheKey) === task.code) {
|
|
7769
|
-
let { code: _code, ...cachedTask } = task;
|
|
7770
|
-
return cachedTask;
|
|
7577
|
+
throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
7771
7578
|
}
|
|
7772
|
-
|
|
7773
|
-
}
|
|
7774
|
-
function getWorkerIndex(task, workerCount) {
|
|
7775
|
-
let safeWorkerCount = Math.max(1, workerCount);
|
|
7776
|
-
return this.balanceRouteModuleTransforms && ('routeClientEntry' === task.kind || 'routeChunk' === task.kind || 'splitRouteExports' === task.kind) || this.balanceRouteModuleTransforms && 'routeModule' === task.kind && !('web' === task.environmentName && !task.ssr && task.isSpaMode) ? _class_private_method_get(this, _getRouteSourceWorkerIndex, getRouteSourceWorkerIndex).call(this, task.resourcePath, safeWorkerCount) : ((value)=>{
|
|
7777
|
-
let hash = 0;
|
|
7778
|
-
for(let index = 0; index < value.length; index += 1)hash = 31 * hash + value.charCodeAt(index) >>> 0;
|
|
7779
|
-
return hash;
|
|
7780
|
-
})(task.resourcePath) % safeWorkerCount;
|
|
7781
|
-
}
|
|
7782
|
-
function getRouteSourceWorkerIndex(resourcePath, safeWorkerCount) {
|
|
7783
|
-
let existingWorkerIndex = _class_private_field_get(this, _routeSourceWorkers).get(resourcePath);
|
|
7784
|
-
if (void 0 !== existingWorkerIndex) return _class_private_field_get(this, _routeSourceWorkers).delete(resourcePath), _class_private_field_get(this, _routeSourceWorkers).set(resourcePath, existingWorkerIndex), existingWorkerIndex % safeWorkerCount;
|
|
7785
|
-
let workerIndex = _class_private_field_get(this, _nextRouteSourceWorkerIndex) % safeWorkerCount;
|
|
7786
|
-
return _class_private_field_set(this, _nextRouteSourceWorkerIndex, _class_private_field_get(this, _nextRouteSourceWorkerIndex) + 1), setBoundedCacheEntry(_class_private_field_get(this, _routeSourceWorkers), resourcePath, workerIndex, 4096), workerIndex;
|
|
7787
|
-
}
|
|
7788
|
-
let ROUTE_DIRECTORY_SCAN_CONCURRENCY = getCappedPluginConcurrency(), defaultWatchDirectoryEntry = (directory, onChange, onError)=>{
|
|
7579
|
+
}, ROUTE_DIRECTORY_SCAN_CONCURRENCY = getCappedPluginConcurrency(), defaultWatchDirectoryEntry = (directory, onChange, onError)=>{
|
|
7789
7580
|
let watcher = watch(directory, onChange);
|
|
7790
7581
|
return watcher.on('error', onError), watcher;
|
|
7791
7582
|
}, ensureDevRestartMarker = async (restartMarkerPath)=>{
|
|
@@ -7915,7 +7706,7 @@ function resolvePackageJson(name, rootDirectory) {
|
|
|
7915
7706
|
return null;
|
|
7916
7707
|
}
|
|
7917
7708
|
}
|
|
7918
|
-
let
|
|
7709
|
+
let VIRTUAL_MODULE_PREFIX = 'virtual/react-router/', isLatestStartedCompilation = (identity, start)=>!identity || start?.status === 'started' && start.identity === identity, hasPendingCompilation = (pair)=>pair.latestWebStart?.status === 'pending' || pair.latestNodeStart?.status === 'pending', clearDevCompilerStart = (pair, side)=>{
|
|
7919
7710
|
pair[side] = void 0, pair.pendingAttempt = void 0;
|
|
7920
7711
|
}, snapshotDevChangedFiles = (compiler)=>compiler ? {
|
|
7921
7712
|
known: void 0 !== compiler.modifiedFiles || void 0 !== compiler.removedFiles,
|
|
@@ -8094,9 +7885,7 @@ let roundMs = (value)=>Math.round(10 * value) / 10, VIRTUAL_MODULE_PREFIX = 'vir
|
|
|
8094
7885
|
let errors = (await Promise.allSettled(closers.map((closer)=>closer()))).filter((result)=>'rejected' === result.status).map((result)=>normalizeEffectError(result.reason));
|
|
8095
7886
|
if (1 === errors.length) throw errors[0];
|
|
8096
7887
|
if (errors.length > 1) throw AggregateError(errors, message);
|
|
8097
|
-
}
|
|
8098
|
-
var src_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
8099
|
-
let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefaultConcurrency() })=>!isBuild && spareCoreCount >= 4, cssUrlAssetExtensions = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/, urlAssetResourceQuery = /^(?=.*(?:\?|&)url(?:&|$))(?!.*(?:\?|&)(?:raw|inline)(?:&|$))/, pluginReactRouter = (options = {})=>({
|
|
7888
|
+
}, shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefaultConcurrency() })=>!isBuild && spareCoreCount >= 4, cssUrlAssetExtensions = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/, urlAssetResourceQuery = /^(?=.*(?:\?|&)url(?:&|$))(?!.*(?:\?|&)(?:raw|inline)(?:&|$))/, pluginReactRouter = (options = {})=>({
|
|
8100
7889
|
name: PLUGIN_NAME,
|
|
8101
7890
|
async setup (api) {
|
|
8102
7891
|
let routeDiscovery, clientStats, reactRouterUserConfig, pluginOptions = {
|
|
@@ -8104,97 +7893,7 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8104
7893
|
lazyCompilation: !0,
|
|
8105
7894
|
serverOutput: 'module',
|
|
8106
7895
|
...options
|
|
8107
|
-
}, logPerformance = !0 === pluginOptions.logPerformance, setupStartMs = logPerformance ? performance.now() : 0, performanceProfiler = (
|
|
8108
|
-
let timingsByEnvironment = new Map(), recordDuration = (environment, operation, resource, startMs, endMs)=>{
|
|
8109
|
-
let timings, timing, duration = endMs - startMs, timing1 = ((timings = timingsByEnvironment.get(environment)) || (timings = new Map(), timingsByEnvironment.set(environment, timings)), (timing = timings.get(operation)) || (timing = {
|
|
8110
|
-
count: 0,
|
|
8111
|
-
totalMs: 0,
|
|
8112
|
-
maxMs: 0,
|
|
8113
|
-
slowest: [],
|
|
8114
|
-
intervals: []
|
|
8115
|
-
}, timings.set(operation, timing)), timing);
|
|
8116
|
-
timing1.count += 1, timing1.totalMs += duration, timing1.maxMs = Math.max(timing1.maxMs, duration), timing1.intervals.push({
|
|
8117
|
-
startMs,
|
|
8118
|
-
endMs
|
|
8119
|
-
}), ((slowest, entry)=>{
|
|
8120
|
-
if (5 === slowest.length && entry.durationMs <= slowest[slowest.length - 1].durationMs) return;
|
|
8121
|
-
let insertIndex = slowest.length;
|
|
8122
|
-
for(; insertIndex > 0 && entry.durationMs > slowest[insertIndex - 1].durationMs;)insertIndex -= 1;
|
|
8123
|
-
slowest.splice(insertIndex, 0, entry), slowest.length > 5 && slowest.pop();
|
|
8124
|
-
})(timing1.slowest, {
|
|
8125
|
-
durationMs: duration,
|
|
8126
|
-
resource
|
|
8127
|
-
});
|
|
8128
|
-
};
|
|
8129
|
-
return {
|
|
8130
|
-
record (environment, operation, resource, callback) {
|
|
8131
|
-
if (!enabled) try {
|
|
8132
|
-
return Promise.resolve(callback());
|
|
8133
|
-
} catch (error) {
|
|
8134
|
-
return Promise.reject(error);
|
|
8135
|
-
}
|
|
8136
|
-
let resolvedEnvironment = environment ?? 'unknown', start = performance.now();
|
|
8137
|
-
try {
|
|
8138
|
-
return callback().then((result)=>{
|
|
8139
|
-
let end = performance.now();
|
|
8140
|
-
return recordDuration(resolvedEnvironment, operation, resource, start, end), result;
|
|
8141
|
-
}, (error)=>{
|
|
8142
|
-
let end = performance.now();
|
|
8143
|
-
throw recordDuration(resolvedEnvironment, operation, resource, start, end), error;
|
|
8144
|
-
});
|
|
8145
|
-
} catch (error) {
|
|
8146
|
-
return recordDuration(resolvedEnvironment, operation, resource, start, performance.now()), Promise.reject(error);
|
|
8147
|
-
}
|
|
8148
|
-
},
|
|
8149
|
-
recordSync (environment, operation, resource, callback) {
|
|
8150
|
-
if (!enabled) return callback();
|
|
8151
|
-
let start = performance.now();
|
|
8152
|
-
try {
|
|
8153
|
-
return callback();
|
|
8154
|
-
} finally{
|
|
8155
|
-
recordDuration(environment ?? 'unknown', operation, resource, start, performance.now());
|
|
8156
|
-
}
|
|
8157
|
-
},
|
|
8158
|
-
flush (environment, details = {}) {
|
|
8159
|
-
if (!enabled) return;
|
|
8160
|
-
let resolvedEnvironment = environment ?? 'unknown', timings = timingsByEnvironment.get(resolvedEnvironment);
|
|
8161
|
-
if (!timings || 0 === timings.size) return;
|
|
8162
|
-
let operations = Object.fromEntries([
|
|
8163
|
-
...timings.entries()
|
|
8164
|
-
].map(([operation, timing])=>[
|
|
8165
|
-
operation,
|
|
8166
|
-
{
|
|
8167
|
-
count: timing.count,
|
|
8168
|
-
totalMs: roundMs(timing.totalMs),
|
|
8169
|
-
wallMs: ((intervals)=>{
|
|
8170
|
-
if (0 === intervals.length) return 0;
|
|
8171
|
-
let sortedIntervals = [
|
|
8172
|
-
...intervals
|
|
8173
|
-
].sort((a, b)=>a.startMs - b.startMs || a.endMs - b.endMs), mergedStart = sortedIntervals[0].startMs, mergedEnd = sortedIntervals[0].endMs, wallMs = 0;
|
|
8174
|
-
for (let interval of sortedIntervals.slice(1)){
|
|
8175
|
-
if (interval.startMs <= mergedEnd) {
|
|
8176
|
-
mergedEnd = Math.max(mergedEnd, interval.endMs);
|
|
8177
|
-
continue;
|
|
8178
|
-
}
|
|
8179
|
-
wallMs += mergedEnd - mergedStart, mergedStart = interval.startMs, mergedEnd = interval.endMs;
|
|
8180
|
-
}
|
|
8181
|
-
return roundMs(wallMs += mergedEnd - mergedStart);
|
|
8182
|
-
})(timing.intervals),
|
|
8183
|
-
maxMs: roundMs(timing.maxMs),
|
|
8184
|
-
slowest: timing.slowest.map((entry)=>({
|
|
8185
|
-
durationMs: roundMs(entry.durationMs),
|
|
8186
|
-
resource: entry.resource
|
|
8187
|
-
}))
|
|
8188
|
-
}
|
|
8189
|
-
])), report = {
|
|
8190
|
-
environment: resolvedEnvironment,
|
|
8191
|
-
...details,
|
|
8192
|
-
operations
|
|
8193
|
-
};
|
|
8194
|
-
log(`[react-router:performance] ${JSON.stringify(report)}`), timingsByEnvironment.delete(resolvedEnvironment);
|
|
8195
|
-
}
|
|
8196
|
-
};
|
|
8197
|
-
})({
|
|
7896
|
+
}, logPerformance = !0 === pluginOptions.logPerformance, setupStartMs = logPerformance ? performance.now() : 0, performanceProfiler = createReactRouterPerformanceProfiler({
|
|
8198
7897
|
enabled: logPerformance,
|
|
8199
7898
|
log: (message)=>api.logger.info(message)
|
|
8200
7899
|
}), nodeExternals = Array.from(new Set([
|
|
@@ -8460,7 +8159,7 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8460
8159
|
});
|
|
8461
8160
|
if (!validation.valid) throw Error(validation.message);
|
|
8462
8161
|
return validation.routeConfig;
|
|
8463
|
-
}, { value: routeConfig, watchPaths: routeConfigWatchPaths } = await importConfigWithWatchPaths(routesPath, importRouteConfig), entryClientPath = findEntryFile(external_pathe_resolve(appDirectory, 'entry.client')), entryServerPath = findEntryFile(external_pathe_resolve(appDirectory, 'entry.server')), serverAppPath = findEntryFile(external_pathe_resolve(appDirectory, '../server/index')), hasServerApp = existsSync(serverAppPath), devServerBuildEntryName = hasServerApp ? 'static/js/react-router-server-build' : 'static/js/app', templateDir = external_pathe_resolve(
|
|
8162
|
+
}, { value: routeConfig, watchPaths: routeConfigWatchPaths } = await importConfigWithWatchPaths(routesPath, importRouteConfig), entryClientPath = findEntryFile(external_pathe_resolve(appDirectory, 'entry.client')), entryServerPath = findEntryFile(external_pathe_resolve(appDirectory, 'entry.server')), serverAppPath = findEntryFile(external_pathe_resolve(appDirectory, '../server/index')), hasServerApp = existsSync(serverAppPath), devServerBuildEntryName = hasServerApp ? 'static/js/react-router-server-build' : 'static/js/app', templateDir = external_pathe_resolve(__rspack_import_meta_dirname__, 'templates'), templateClientPath = external_pathe_resolve(templateDir, 'entry.client.js'), templateServerPath = external_pathe_resolve(templateDir, 'entry.server.js'), finalEntryClientPath = existsSync(entryClientPath) ? entryClientPath : templateClientPath, finalEntryServerPath = existsSync(entryServerPath) ? entryServerPath : templateServerPath, getRootRoutePath = ()=>findEntryFile(external_pathe_resolve(appDirectory, 'root')), rootRoutePath = getRootRoutePath(), rootRouteFile = relative(appDirectory, rootRoutePath), routeTopology = (({ appDirectory, rootRouteFile, routeConfig, loadRouteConfig, getRootRoutePath })=>{
|
|
8464
8163
|
let createSnapshot = (routeFile, routeConfigEntries)=>{
|
|
8465
8164
|
let routes;
|
|
8466
8165
|
return new Set((Array.isArray(routes = [
|
|
@@ -8521,33 +8220,7 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8521
8220
|
});
|
|
8522
8221
|
let isBuild = 'build' === api.context.action, shouldDependOnWebCompiler = !shouldParallelizeEnvironmentBuilds({
|
|
8523
8222
|
isBuild
|
|
8524
|
-
}), isPrerenderEnabled = void 0 !== prerenderConfig && !1 !== prerenderConfig, isSpaMode = !ssr && !isPrerenderEnabled, routeCount = Object.keys(routes).length, routeChunkCache = new Map(),
|
|
8525
|
-
let options = {
|
|
8526
|
-
routeChunkCache
|
|
8527
|
-
};
|
|
8528
|
-
if (void 0 === parallelRouteTransform || !1 === parallelRouteTransform) return createInlineRouteTransformExecutor(options);
|
|
8529
|
-
let workerCount = ((parallelRouteTransform, isBuild)=>{
|
|
8530
|
-
if (!0 === parallelRouteTransform) return ((cpuCount, { isBuild = !1 } = {})=>{
|
|
8531
|
-
let resolvedCpuCount = cpuCount ?? getAvailableCpuCount();
|
|
8532
|
-
return !isBuild && resolvedCpuCount <= 4 ? 0 : Math.min(getDefaultConcurrency(resolvedCpuCount), 2);
|
|
8533
|
-
})(void 0, {
|
|
8534
|
-
isBuild
|
|
8535
|
-
});
|
|
8536
|
-
if (!Number.isInteger(parallelRouteTransform) || parallelRouteTransform < 1) throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
8537
|
-
return parallelRouteTransform;
|
|
8538
|
-
})(parallelRouteTransform, !!isBuild);
|
|
8539
|
-
return workerCount < 1 ? createInlineRouteTransformExecutor(options) : new ParallelRouteTransformExecutor(workerCount, options, !!splitRouteModules, createWorker);
|
|
8540
|
-
})({
|
|
8541
|
-
parallelRouteTransform,
|
|
8542
|
-
routeChunkCache,
|
|
8543
|
-
splitRouteModules,
|
|
8544
|
-
isBuild
|
|
8545
|
-
}, createDefaultWorker))({
|
|
8546
|
-
parallelRouteTransform: pluginOptions.parallelRouteTransform ?? routeCount >= 256,
|
|
8547
|
-
routeChunkCache,
|
|
8548
|
-
splitRouteModules: !!splitRouteModules,
|
|
8549
|
-
isBuild
|
|
8550
|
-
}), routeChunkOptions = {
|
|
8223
|
+
}), isPrerenderEnabled = void 0 !== prerenderConfig && !1 !== prerenderConfig, isSpaMode = !ssr && !isPrerenderEnabled, routeCount = Object.keys(routes).length, routeChunkCache = new Map(), useRouteModuleTransformLoader = void 0 !== getRouteModuleTransformParallel(pluginOptions.parallelRouteTransform), routeChunkOptions = {
|
|
8551
8224
|
splitRouteModules,
|
|
8552
8225
|
rootRouteFile,
|
|
8553
8226
|
isBuild,
|
|
@@ -8571,7 +8244,7 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8571
8244
|
routeConfigWatchPaths,
|
|
8572
8245
|
routeRestartMarkerPath,
|
|
8573
8246
|
onRouteTopologyChange: pluginOptions.onRouteTopologyChange
|
|
8574
|
-
}), devBackgroundResources = (({ api, isBuild, lazyCompilationPrewarm,
|
|
8247
|
+
}), devBackgroundResources = (({ api, isBuild, lazyCompilationPrewarm, routeRestartMarkerPath, watchDirectory, getRouteTopology, initialRouteTopology, onRouteTopologyChange })=>{
|
|
8575
8248
|
let closeActiveRouteTopologyWatcher, routeTopologyWatcherClosed = !1, reportRouteTopologyWatcherError = (error)=>{
|
|
8576
8249
|
api.logger.warn(`[${PLUGIN_NAME}] Failed to watch route topology changes: ${String(normalizeEffectError(error))}`);
|
|
8577
8250
|
}, routeTopologyWatcherTask = createDelayedPluginTask({
|
|
@@ -8640,17 +8313,16 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8640
8313
|
lazyCompilationPrewarmController?.setServerOrigin(`http://localhost:${port}`), lazyCompilationPrewarmController?.schedule();
|
|
8641
8314
|
}), api.onAfterDevCompile(()=>{
|
|
8642
8315
|
routeTopologyWatcherClosed || closeActiveRouteTopologyWatcher || routeTopologyWatcherTask.schedule(), lazyCompilationPrewarmController?.schedule();
|
|
8643
|
-
})
|
|
8316
|
+
}));
|
|
8644
8317
|
let closeRouteTopologyWatcher = async ()=>{
|
|
8645
8318
|
routeTopologyWatcherClosed = !0, await runPluginEffect(routeTopologyWatcherTask.cancelEffect()), await closeActiveRouteTopologyWatcher?.(), closeActiveRouteTopologyWatcher = void 0;
|
|
8646
8319
|
}, closeLazyCompilationPrewarm = async ()=>{
|
|
8647
8320
|
await runPluginEffect(lazyCompilationPrewarmController?.cancelEffect() ?? core_void_);
|
|
8648
|
-
}
|
|
8321
|
+
};
|
|
8649
8322
|
return api.onCloseDevServer(()=>closeAll('[rsbuild-plugin-react-router] Failed to close dev server resources.', [
|
|
8650
8323
|
closeRouteTopologyWatcher,
|
|
8651
|
-
closeLazyCompilationPrewarm
|
|
8652
|
-
|
|
8653
|
-
])), api.onCloseBuild(closeRouteTransformExecutor), {
|
|
8324
|
+
closeLazyCompilationPrewarm
|
|
8325
|
+
])), {
|
|
8654
8326
|
setManifest (manifest) {
|
|
8655
8327
|
lazyCompilationPrewarmController?.setManifest(manifest);
|
|
8656
8328
|
}
|
|
@@ -8659,7 +8331,6 @@ let shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefault
|
|
|
8659
8331
|
api,
|
|
8660
8332
|
isBuild,
|
|
8661
8333
|
lazyCompilationPrewarm: pluginOptions.unstableLazyCompilationPrewarm,
|
|
8662
|
-
routeTransformExecutor,
|
|
8663
8334
|
routeRestartMarkerPath,
|
|
8664
8335
|
watchDirectory,
|
|
8665
8336
|
getRouteTopology: routeTopology.getRouteTopology,
|
|
@@ -9693,7 +9364,6 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
9693
9364
|
assetPrefix: config.output?.assetPrefix || '/'
|
|
9694
9365
|
},
|
|
9695
9366
|
dev: {
|
|
9696
|
-
writeToDisk: !0,
|
|
9697
9367
|
...void 0 === guardedLazyCompilation ? {} : {
|
|
9698
9368
|
lazyCompilation: guardedLazyCompilation
|
|
9699
9369
|
},
|
|
@@ -9849,17 +9519,66 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
9849
9519
|
}), api.modifyEnvironmentConfig(async (config, { name, mergeEnvironmentConfig })=>'web' !== name && 'node' !== name ? config : mergeEnvironmentConfig(config, {
|
|
9850
9520
|
tools: {
|
|
9851
9521
|
rspack: (rspackConfig)=>{
|
|
9852
|
-
|
|
9522
|
+
let environmentDevHmrEnabled = 'web' === name && !isBuild && void 0 !== devHmrRefreshRuntimePath && 'development' === config.mode && config.dev?.hmr !== !1 && readRuleSetSwcRefresh(rspackConfig.module?.rules);
|
|
9523
|
+
if (useRouteModuleTransformLoader && ((rspackConfig, { environmentName, ssr, isBuild, isSpaMode, rootRoutePath, devHmr, logPerformance, routeByFilePath, parallelRouteTransform })=>{
|
|
9524
|
+
var options;
|
|
9525
|
+
let parallel, routeModuleTransformUse = (options = {
|
|
9526
|
+
environmentName,
|
|
9527
|
+
performanceScopeId: [
|
|
9528
|
+
environmentName,
|
|
9529
|
+
isBuild ? 'build' : 'dev',
|
|
9530
|
+
ssr ? 'ssr' : 'spa',
|
|
9531
|
+
rootRoutePath ?? 'rootless'
|
|
9532
|
+
].join(':'),
|
|
9533
|
+
logPerformance,
|
|
9534
|
+
ssr,
|
|
9535
|
+
isBuild,
|
|
9536
|
+
isSpaMode,
|
|
9537
|
+
rootRoutePath,
|
|
9538
|
+
devHmr
|
|
9539
|
+
}, {
|
|
9540
|
+
loader: routeModuleTransformLoaderPath,
|
|
9541
|
+
options,
|
|
9542
|
+
...(parallel = getRouteModuleTransformParallel(parallelRouteTransform)) ? {
|
|
9543
|
+
parallel
|
|
9544
|
+
} : {}
|
|
9545
|
+
});
|
|
9546
|
+
rspackConfig.module ??= {}, rspackConfig.module.rules ??= [], rspackConfig.module.rules.push({
|
|
9547
|
+
resourceQuery: /\?react-router-route/,
|
|
9548
|
+
enforce: 'post',
|
|
9549
|
+
use: [
|
|
9550
|
+
routeModuleTransformUse
|
|
9551
|
+
]
|
|
9552
|
+
}, {
|
|
9553
|
+
test: (path)=>routeByFilePath.has(path),
|
|
9554
|
+
resourceQuery: {
|
|
9555
|
+
not: /__react-router-build-client-route|react-router-route|route-chunk=/
|
|
9556
|
+
},
|
|
9557
|
+
enforce: 'post',
|
|
9558
|
+
use: [
|
|
9559
|
+
routeModuleTransformUse
|
|
9560
|
+
]
|
|
9561
|
+
});
|
|
9562
|
+
})(rspackConfig, {
|
|
9563
|
+
environmentName: name,
|
|
9564
|
+
ssr,
|
|
9565
|
+
isBuild,
|
|
9566
|
+
isSpaMode,
|
|
9567
|
+
rootRoutePath,
|
|
9568
|
+
devHmr: environmentDevHmrEnabled,
|
|
9569
|
+
logPerformance,
|
|
9570
|
+
routeByFilePath,
|
|
9571
|
+
parallelRouteTransform: pluginOptions.parallelRouteTransform
|
|
9572
|
+
}), pluginOptions.federation && ((rspackConfig)=>{
|
|
9853
9573
|
if (rspackConfig?.plugins?.length) for (let plugin of rspackConfig.plugins){
|
|
9854
|
-
if (!plugin || 'object' != typeof plugin || 'ModuleFederationPlugin' !== plugin.name) continue;
|
|
9574
|
+
if (!plugin || 'object' != typeof plugin || 'ModuleFederationPlugin' !== plugin.name && 'RspackModuleFederationPlugin' !== plugin.name) continue;
|
|
9855
9575
|
let pluginOptions = plugin._options ?? plugin.options;
|
|
9856
9576
|
pluginOptions && (pluginOptions.experiments = {
|
|
9857
9577
|
...pluginOptions.experiments,
|
|
9858
9578
|
asyncStartup: !0
|
|
9859
9579
|
});
|
|
9860
9580
|
}
|
|
9861
|
-
})(rspackConfig), 'web' === name
|
|
9862
|
-
if ('node' === name) {
|
|
9581
|
+
})(rspackConfig), 'web' === name && (devHmrEnabled = environmentDevHmrEnabled) && devHdrSignal?.ensure(), 'node' === name) {
|
|
9863
9582
|
let output = rspackConfig.output;
|
|
9864
9583
|
if (output) {
|
|
9865
9584
|
let library = output.library, libraryOptions = library && 'object' == typeof library && !Array.isArray(library) ? library : {};
|
|
@@ -9969,8 +9688,8 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
9969
9688
|
isBuild || devRuntime.captureWeb(compilation, manifestsByEntryName);
|
|
9970
9689
|
});
|
|
9971
9690
|
}
|
|
9972
|
-
}), (({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions,
|
|
9973
|
-
let transformRouteModule = async (args)=>performanceProfiler.record(args.environment?.name, 'route:module', args.resource, async ()=>
|
|
9691
|
+
}), (({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions, routeTransformRunner, routeByFilePath, routeChunkConfig, isBuild, splitRouteModules, useRouteModuleTransformApi, ssr, isSpaMode, rootRoutePath, isDevHmrEnabled = ()=>!1 })=>{
|
|
9692
|
+
let transformRouteModule = async (args)=>performanceProfiler.record(args.environment?.name, 'route:module', args.resource, async ()=>routeTransformRunner({
|
|
9974
9693
|
kind: 'routeModule',
|
|
9975
9694
|
code: args.code,
|
|
9976
9695
|
resource: args.resource,
|
|
@@ -10005,7 +9724,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10005
9724
|
};
|
|
10006
9725
|
})), api.transform({
|
|
10007
9726
|
resourceQuery: /__react-router-build-client-route/
|
|
10008
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:client-entry', args.resource, async ()=>
|
|
9727
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:client-entry', args.resource, async ()=>routeTransformRunner({
|
|
10009
9728
|
kind: 'routeClientEntry',
|
|
10010
9729
|
code: args.code,
|
|
10011
9730
|
resourcePath: args.resourcePath,
|
|
@@ -10019,7 +9738,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10019
9738
|
environments: [
|
|
10020
9739
|
'web'
|
|
10021
9740
|
]
|
|
10022
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:chunk', args.resource, async ()=>
|
|
9741
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:chunk', args.resource, async ()=>routeTransformRunner({
|
|
10023
9742
|
kind: 'routeChunk',
|
|
10024
9743
|
code: args.code,
|
|
10025
9744
|
resource: args.resource,
|
|
@@ -10034,7 +9753,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10034
9753
|
environments: [
|
|
10035
9754
|
'web'
|
|
10036
9755
|
]
|
|
10037
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:split-exports', args.resource, async ()=>
|
|
9756
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:split-exports', args.resource, async ()=>routeTransformRunner({
|
|
10038
9757
|
kind: 'splitRouteExports',
|
|
10039
9758
|
code: args.code,
|
|
10040
9759
|
resourcePath: args.resourcePath,
|
|
@@ -10052,12 +9771,12 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10052
9771
|
environments: [
|
|
10053
9772
|
'node'
|
|
10054
9773
|
]
|
|
10055
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'module:client-only-stub', args.resource, async ()=>
|
|
9774
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'module:client-only-stub', args.resource, async ()=>routeTransformRunner({
|
|
10056
9775
|
kind: 'clientOnlyStub',
|
|
10057
9776
|
code: args.code,
|
|
10058
9777
|
resourcePath: args.resourcePath,
|
|
10059
9778
|
resolveExportAllModule: 'function' == typeof args.resolve ? createBundlerRouteExportResolver(args.resolve) : void 0
|
|
10060
|
-
}))), api.transform({
|
|
9779
|
+
}))), useRouteModuleTransformApi && (api.transform({
|
|
10061
9780
|
resourceQuery: /\?react-router-route/,
|
|
10062
9781
|
order: 'post'
|
|
10063
9782
|
}, transformRouteModule), api.transform({
|
|
@@ -10066,7 +9785,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10066
9785
|
not: /__react-router-build-client-route|react-router-route|route-chunk=/
|
|
10067
9786
|
},
|
|
10068
9787
|
order: 'post'
|
|
10069
|
-
}, transformRouteModule);
|
|
9788
|
+
}, transformRouteModule));
|
|
10070
9789
|
})({
|
|
10071
9790
|
api,
|
|
10072
9791
|
resolvedServerOutput,
|
|
@@ -10079,7 +9798,9 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10079
9798
|
appDirectory,
|
|
10080
9799
|
getAssetPrefix: ()=>assetPrefix,
|
|
10081
9800
|
routeChunkOptions,
|
|
10082
|
-
|
|
9801
|
+
routeTransformRunner: (task)=>executeRouteTransformTask(task, {
|
|
9802
|
+
routeChunkCache
|
|
9803
|
+
}),
|
|
10083
9804
|
routeByFilePath,
|
|
10084
9805
|
routeChunkConfig: {
|
|
10085
9806
|
splitRouteModules,
|
|
@@ -10088,6 +9809,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
10088
9809
|
},
|
|
10089
9810
|
isBuild,
|
|
10090
9811
|
splitRouteModules: !!splitRouteModules,
|
|
9812
|
+
useRouteModuleTransformApi: !useRouteModuleTransformLoader,
|
|
10091
9813
|
ssr,
|
|
10092
9814
|
isSpaMode,
|
|
10093
9815
|
rootRoutePath,
|