rsbuild-plugin-react-router 0.4.1 → 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 -334
- package/dist/index.js +129 -406
- 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 -56
- 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.cjs
CHANGED
|
@@ -114,6 +114,15 @@ const core_namespaceObject = require("@rsbuild/core"), external_jiti_namespaceOb
|
|
|
114
114
|
...options,
|
|
115
115
|
test: (module)=>!isReactRouterHydrationModule(module) && matchesLazyCompilationTest(userTest, module)
|
|
116
116
|
};
|
|
117
|
+
}, ensureFederationAsyncStartup = (rspackConfig)=>{
|
|
118
|
+
if (rspackConfig?.plugins?.length) for (let plugin of rspackConfig.plugins){
|
|
119
|
+
if (!plugin || 'object' != typeof plugin || 'ModuleFederationPlugin' !== plugin.name && 'RspackModuleFederationPlugin' !== plugin.name) continue;
|
|
120
|
+
let pluginOptions = plugin._options ?? plugin.options;
|
|
121
|
+
pluginOptions && (pluginOptions.experiments = {
|
|
122
|
+
...pluginOptions.experiments,
|
|
123
|
+
asyncStartup: !0
|
|
124
|
+
});
|
|
125
|
+
}
|
|
117
126
|
}, createDevServerMiddleware = (dependencies)=>{
|
|
118
127
|
let listenerPromise, getListener = ()=>listenerPromise ??= (async ()=>{
|
|
119
128
|
let createRequestHandler = dependencies.createRequestHandler ?? (await import("react-router")).createRequestHandler, createRequestListener = dependencies.createRequestListener ?? (await import("@remix-run/node-fetch-server")).createRequestListener, requestHandler = createRequestHandler(dependencies.loadBuild, 'development');
|
|
@@ -942,7 +951,7 @@ function compareBoth(self, that) {
|
|
|
942
951
|
}
|
|
943
952
|
if (structuralRegionState.enabled) {
|
|
944
953
|
if (null === self || null === that) return !1;
|
|
945
|
-
if (Array.isArray(self) && Array.isArray(that)) return self.length === that.length && self.every((
|
|
954
|
+
if (Array.isArray(self) && Array.isArray(that)) return self.length === that.length && self.every((v, i)=>compareBoth(v, that[i]));
|
|
946
955
|
if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(that) === Object.prototype) {
|
|
947
956
|
let keysSelf = Object.keys(self), keysThat = Object.keys(that);
|
|
948
957
|
if (keysSelf.length === keysThat.length) {
|
|
@@ -983,30 +992,30 @@ function formatPropertyKey(name) {
|
|
|
983
992
|
return Predicate.isString(name) ? JSON.stringify(name) : String(name);
|
|
984
993
|
}
|
|
985
994
|
function formatUnknown(input, options) {
|
|
986
|
-
let space = options?.space ?? 0, seen = new WeakSet(), gap = space ? Predicate.isNumber(space) ? " ".repeat(space) : space : "", wrap = (
|
|
987
|
-
let ctor =
|
|
995
|
+
let space = options?.space ?? 0, seen = new WeakSet(), gap = space ? Predicate.isNumber(space) ? " ".repeat(space) : space : "", wrap = (v, body)=>{
|
|
996
|
+
let ctor = v?.constructor;
|
|
988
997
|
return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body;
|
|
989
998
|
};
|
|
990
|
-
return function go(
|
|
991
|
-
if (Array.isArray(
|
|
999
|
+
return function go(v, d = 0) {
|
|
1000
|
+
if (Array.isArray(v)) {
|
|
992
1001
|
let d1, d2;
|
|
993
|
-
if (seen.has(
|
|
994
|
-
if (seen.add(
|
|
995
|
-
let inner =
|
|
1002
|
+
if (seen.has(v)) return CIRCULAR;
|
|
1003
|
+
if (seen.add(v), !gap || v.length <= 1) return `[${v.map((x)=>go(x, d)).join(",")}]`;
|
|
1004
|
+
let inner = v.map((x)=>go(x, d + 1)).join(",\n" + (d1 = d + 1, gap.repeat(d1)));
|
|
996
1005
|
return `[\n${d2 = d + 1, gap.repeat(d2)}${inner}\n${gap.repeat(d)}]`;
|
|
997
1006
|
}
|
|
998
|
-
if (Predicate.isDate(
|
|
999
|
-
if (!options?.ignoreToString && Predicate.hasProperty(
|
|
1000
|
-
let s = safeToString(
|
|
1001
|
-
return
|
|
1002
|
-
}
|
|
1003
|
-
if (Predicate.isString(
|
|
1004
|
-
if (Predicate.isNumber(
|
|
1005
|
-
if (Predicate.isBigInt(
|
|
1006
|
-
if (
|
|
1007
|
-
if (Predicate.isObject(
|
|
1008
|
-
if (seen.has(
|
|
1009
|
-
seen.add(
|
|
1007
|
+
if (Predicate.isDate(v)) return Inspectable_formatDate(v);
|
|
1008
|
+
if (!options?.ignoreToString && Predicate.hasProperty(v, "toString") && Predicate.isFunction(v.toString) && v.toString !== Object.prototype.toString && v.toString !== Array.prototype.toString) {
|
|
1009
|
+
let s = safeToString(v);
|
|
1010
|
+
return v instanceof Error && v.cause ? `${s} (cause: ${go(v.cause, d)})` : s;
|
|
1011
|
+
}
|
|
1012
|
+
if (Predicate.isString(v)) return JSON.stringify(v);
|
|
1013
|
+
if (Predicate.isNumber(v) || null == v || Predicate.isBoolean(v) || Predicate.isSymbol(v)) return String(v);
|
|
1014
|
+
if (Predicate.isBigInt(v)) return String(v) + "n";
|
|
1015
|
+
if (v instanceof Set || v instanceof Map) return seen.has(v) ? CIRCULAR : (seen.add(v), `${v.constructor.name}(${go(Array.from(v), d)})`);
|
|
1016
|
+
if (Predicate.isObject(v)) {
|
|
1017
|
+
if (seen.has(v)) return CIRCULAR;
|
|
1018
|
+
seen.add(v);
|
|
1010
1019
|
let keys = ((o)=>{
|
|
1011
1020
|
try {
|
|
1012
1021
|
return Reflect.ownKeys(o);
|
|
@@ -1015,18 +1024,18 @@ function formatUnknown(input, options) {
|
|
|
1015
1024
|
"[ownKeys threw]"
|
|
1016
1025
|
];
|
|
1017
1026
|
}
|
|
1018
|
-
})(
|
|
1027
|
+
})(v);
|
|
1019
1028
|
if (!gap || keys.length <= 1) {
|
|
1020
|
-
let body = `{${keys.map((k)=>`${formatPropertyKey(k)}:${go(
|
|
1021
|
-
return wrap(
|
|
1029
|
+
let body = `{${keys.map((k)=>`${formatPropertyKey(k)}:${go(v[k], d)}`).join(",")}}`;
|
|
1030
|
+
return wrap(v, body);
|
|
1022
1031
|
}
|
|
1023
1032
|
let body = `{\n${keys.map((k)=>{
|
|
1024
1033
|
let d1;
|
|
1025
|
-
return `${d1 = d + 1, gap.repeat(d1)}${formatPropertyKey(k)}: ${go(
|
|
1034
|
+
return `${d1 = d + 1, gap.repeat(d1)}${formatPropertyKey(k)}: ${go(v[k], d + 1)}`;
|
|
1026
1035
|
}).join(",\n")}\n${gap.repeat(d)}}`;
|
|
1027
|
-
return wrap(
|
|
1036
|
+
return wrap(v, body);
|
|
1028
1037
|
}
|
|
1029
|
-
return String(
|
|
1038
|
+
return String(v);
|
|
1030
1039
|
}(input, 0);
|
|
1031
1040
|
}
|
|
1032
1041
|
const Inspectable_format = (x)=>JSON.stringify(x, null, 2), BaseProto = null;
|
|
@@ -1965,14 +1974,14 @@ const stack_make = (value, previous)=>({
|
|
|
1965
1974
|
value,
|
|
1966
1975
|
previous
|
|
1967
1976
|
});
|
|
1968
|
-
function arrayUpdate(mutate, at,
|
|
1977
|
+
function arrayUpdate(mutate, at, v, arr) {
|
|
1969
1978
|
let out = arr;
|
|
1970
1979
|
if (!mutate) {
|
|
1971
1980
|
let len = arr.length;
|
|
1972
1981
|
out = Array(len);
|
|
1973
1982
|
for(let i = 0; i < len; ++i)out[i] = arr[i];
|
|
1974
1983
|
}
|
|
1975
|
-
return out[at] =
|
|
1984
|
+
return out[at] = v, out;
|
|
1976
1985
|
}
|
|
1977
1986
|
function arraySpliceOut(mutate, at, arr) {
|
|
1978
1987
|
let newLen = arr.length - 1, i = 0, g = 0, out = arr;
|
|
@@ -1981,23 +1990,23 @@ function arraySpliceOut(mutate, at, arr) {
|
|
|
1981
1990
|
for(++i; i <= newLen;)out[g++] = arr[i++];
|
|
1982
1991
|
return mutate && (out.length = newLen), out;
|
|
1983
1992
|
}
|
|
1984
|
-
function arraySpliceIn(mutate, at,
|
|
1993
|
+
function arraySpliceIn(mutate, at, v, arr) {
|
|
1985
1994
|
let len = arr.length;
|
|
1986
1995
|
if (mutate) {
|
|
1987
1996
|
let i = len;
|
|
1988
1997
|
for(; i >= at;)arr[i--] = arr[i];
|
|
1989
|
-
return arr[at] =
|
|
1998
|
+
return arr[at] = v, arr;
|
|
1990
1999
|
}
|
|
1991
2000
|
let i = 0, g = 0, out = Array(len + 1);
|
|
1992
2001
|
for(; i < at;)out[g++] = arr[i++];
|
|
1993
|
-
for(out[at] =
|
|
2002
|
+
for(out[at] = v; i < len;)out[++g] = arr[i++];
|
|
1994
2003
|
return out;
|
|
1995
2004
|
}
|
|
1996
2005
|
class EmptyNode {
|
|
1997
2006
|
_tag = "EmptyNode";
|
|
1998
2007
|
modify(edit, _shift, f, hash, key, size) {
|
|
1999
|
-
let
|
|
2000
|
-
return isNone(
|
|
2008
|
+
let v = f(Option_none());
|
|
2009
|
+
return isNone(v) ? new EmptyNode() : (++size.value, new LeafNode(edit, hash, key, v));
|
|
2001
2010
|
}
|
|
2002
2011
|
}
|
|
2003
2012
|
function isEmptyNode(a) {
|
|
@@ -2020,11 +2029,11 @@ class LeafNode {
|
|
|
2020
2029
|
}
|
|
2021
2030
|
modify(edit, shift, f, hash, key, size) {
|
|
2022
2031
|
if (equals(key, this.key)) {
|
|
2023
|
-
let
|
|
2024
|
-
return
|
|
2032
|
+
let v = f(this.value);
|
|
2033
|
+
return v === this.value ? this : isNone(v) ? (--size.value, new EmptyNode()) : canEditNode(this, edit) ? (this.value = v, this) : new LeafNode(edit, hash, key, v);
|
|
2025
2034
|
}
|
|
2026
|
-
let
|
|
2027
|
-
return isNone(
|
|
2035
|
+
let v = f(Option_none());
|
|
2036
|
+
return isNone(v) ? this : (++size.value, mergeLeaves(edit, shift, this.hash, this, hash, new LeafNode(edit, hash, key, v)));
|
|
2028
2037
|
}
|
|
2029
2038
|
}
|
|
2030
2039
|
class CollisionNode {
|
|
@@ -2040,8 +2049,8 @@ class CollisionNode {
|
|
|
2040
2049
|
let canEdit = canEditNode(this, edit), list = this.updateCollisionList(canEdit, edit, this.hash, this.children, f, key, size);
|
|
2041
2050
|
return list === this.children ? this : list.length > 1 ? new CollisionNode(edit, this.hash, list) : list[0];
|
|
2042
2051
|
}
|
|
2043
|
-
let
|
|
2044
|
-
return isNone(
|
|
2052
|
+
let v = f(Option_none());
|
|
2053
|
+
return isNone(v) ? this : (++size.value, mergeLeaves(edit, shift, this.hash, this, hash, new LeafNode(edit, hash, key, v)));
|
|
2045
2054
|
}
|
|
2046
2055
|
updateCollisionList(mutate, edit, hash, list, f, key, size) {
|
|
2047
2056
|
let len = list.length;
|
|
@@ -2147,9 +2156,9 @@ function mergeLeaves(edit, shift, h1, n1, h2, n2) {
|
|
|
2147
2156
|
const HashMapSymbolKey = "effect/HashMap", HashMapTypeId = Symbol.for(HashMapSymbolKey), HashMapProto = {
|
|
2148
2157
|
[HashMapTypeId]: HashMapTypeId,
|
|
2149
2158
|
[Symbol.iterator] () {
|
|
2150
|
-
return new HashMapIterator(this, (k,
|
|
2159
|
+
return new HashMapIterator(this, (k, v)=>[
|
|
2151
2160
|
k,
|
|
2152
|
-
|
|
2161
|
+
v
|
|
2153
2162
|
]);
|
|
2154
2163
|
},
|
|
2155
2164
|
[Hash_symbol] () {
|
|
@@ -2296,7 +2305,7 @@ const applyCont = (cont)=>cont ? visitLazyChildren(cont[0], cont[1], cont[2], co
|
|
|
2296
2305
|
return Function_pipe(self, setTree(newRoot, size.value));
|
|
2297
2306
|
}), hashMap_modify = Function_dual(3, (self, key, f)=>modifyAt(self, key, Option_map(f))), hashMap_union = Function_dual(2, (self, that)=>{
|
|
2298
2307
|
let result = beginMutation(self);
|
|
2299
|
-
return hashMap_forEach(that, (
|
|
2308
|
+
return hashMap_forEach(that, (v, k)=>hashMap_set(result, k, v)), endMutation(result);
|
|
2300
2309
|
}), hashMap_remove = Function_dual(2, (self, key)=>modifyAt(self, key, Option_none)), removeMany = Function_dual(2, (self, keys)=>hashMap_mutate(self, (map)=>{
|
|
2301
2310
|
for (let key of keys)hashMap_remove(key)(map);
|
|
2302
2311
|
})), hashMap_map = Function_dual(2, (self, f)=>hashMap_reduce(self, internal_hashMap_empty(), (map, value, key)=>hashMap_set(map, key, f(value, key)))), hashMap_flatMap = Function_dual(2, (self, f)=>hashMap_reduce(self, internal_hashMap_empty(), (zero, value, key)=>hashMap_mutate(zero, (map)=>hashMap_forEach(f(value, key), (value, key)=>hashMap_set(map, key, value))))), hashMap_forEach = Function_dual(2, (self, f)=>hashMap_reduce(self, void 0, (_, value, key)=>f(value, key))), hashMap_reduce = Function_dual(3, (self, zero, f)=>{
|
|
@@ -3482,7 +3491,7 @@ const HashMap_TypeId = HashMapTypeId, HashMap_isHashMap = isHashMap, HashMap_emp
|
|
|
3482
3491
|
return Hash_cached(this, Hash_array(this));
|
|
3483
3492
|
},
|
|
3484
3493
|
[Equal_symbol] (that) {
|
|
3485
|
-
return !!Array.isArray(that) && this.length === that.length && this.every((
|
|
3494
|
+
return !!Array.isArray(that) && this.length === that.length && this.every((v, i)=>equals(v, that[i]));
|
|
3486
3495
|
}
|
|
3487
3496
|
}), data_Structural = function() {
|
|
3488
3497
|
function Structural(args) {
|
|
@@ -4512,9 +4521,9 @@ const isEffect = (u)=>Predicate_hasProperty(u, core_EffectTypeId), withFiberRunt
|
|
|
4512
4521
|
])), fiberRefDelete = (self)=>withFiberRuntime((state)=>(state.unsafeDeleteFiberRef(self), core_void_)), fiberRefReset = (self)=>fiberRefSet(self, self.initial), fiberRefModify = Function_dual(2, (self, f)=>withFiberRuntime((state)=>{
|
|
4513
4522
|
let [b, a] = f(state.getFiberRef(self));
|
|
4514
4523
|
return state.setFiberRef(self, a), succeed(b);
|
|
4515
|
-
})), fiberRefModifySome = (self, def, f)=>fiberRefModify(self, (
|
|
4524
|
+
})), fiberRefModifySome = (self, def, f)=>fiberRefModify(self, (v)=>Option.getOrElse(f(v), ()=>[
|
|
4516
4525
|
def,
|
|
4517
|
-
|
|
4526
|
+
v
|
|
4518
4527
|
])), fiberRefUpdate = null, fiberRefUpdateSome = null, fiberRefUpdateAndGet = null, fiberRefUpdateSomeAndGet = null, RequestResolverSymbolKey = "effect/RequestResolver", RequestResolverTypeId = Symbol.for("effect/RequestResolver"), requestResolverVariance = {
|
|
4519
4528
|
_A: (_)=>_,
|
|
4520
4529
|
_R: (_)=>_
|
|
@@ -6908,7 +6917,7 @@ const label_make = (key, value)=>new MetricLabelImpl(key, value), isMetricLabel
|
|
|
6908
6917
|
])))), tagMetrics = Function_dual((args)=>isEffect(args[0]), function() {
|
|
6909
6918
|
return labelMetrics(arguments[0], "string" == typeof arguments[1] ? [
|
|
6910
6919
|
label_make(arguments[1], arguments[2])
|
|
6911
|
-
] : Object.entries(arguments[1]).map(([k,
|
|
6920
|
+
] : Object.entries(arguments[1]).map(([k, v])=>label_make(k, v)));
|
|
6912
6921
|
}), labelMetrics = Function_dual(2, (self, labels)=>fiberRefLocallyWith(self, currentMetricLabels, (old)=>Array_union(old, labels))), takeUntil = Function_dual(2, (elements, predicate)=>core_suspend(()=>{
|
|
6913
6922
|
let next, iterator = elements[Symbol.iterator](), builder = [], effect1 = succeed(!1), i = 0;
|
|
6914
6923
|
for(; (next = iterator.next()) && !next.done;){
|
|
@@ -7033,7 +7042,7 @@ const label_make = (key, value)=>new MetricLabelImpl(key, value), isMetricLabel
|
|
|
7033
7042
|
...toReadonlyArray(linksFromEnv.value),
|
|
7034
7043
|
...options.links ?? []
|
|
7035
7044
|
] : toReadonlyArray(linksFromEnv.value) : options.links ?? Array_empty();
|
|
7036
|
-
span = tracer1.span(name, parent, options.context ?? internal_context_empty(), links, timingEnabled ? clock.unsafeCurrentTimeNanos() : core_effect_bigint0, options.kind ?? "internal", options), "Some" === annotationsFromEnv._tag && hashMap_forEach(annotationsFromEnv.value, (value, key)=>span.attribute(key, value)), void 0 !== options.attributes && Object.entries(options.attributes).forEach(([k,
|
|
7045
|
+
span = tracer1.span(name, parent, options.context ?? internal_context_empty(), links, timingEnabled ? clock.unsafeCurrentTimeNanos() : core_effect_bigint0, options.kind ?? "internal", options), "Some" === annotationsFromEnv._tag && hashMap_forEach(annotationsFromEnv.value, (value, key)=>span.attribute(key, value)), void 0 !== options.attributes && Object.entries(options.attributes).forEach(([k, v])=>span.attribute(k, v));
|
|
7037
7046
|
}
|
|
7038
7047
|
return "function" == typeof options.captureStackTrace && spanToTrace.set(span, options.captureStackTrace), span;
|
|
7039
7048
|
}, makeSpan = (name, options)=>(options = addSpanStackTrace(options), withFiberRuntime((fiber)=>succeed(unsafeMakeSpan(fiber, name, options)))), spanAnnotations = fiberRefGet(currentTracerSpanAnnotations), spanLinks = fiberRefGet(currentTracerSpanLinks), endSpan = (span, exit, clock, timingEnabled)=>sync(()=>{
|
|
@@ -7239,7 +7248,7 @@ const fiberScope_unsafeMake = (fiber)=>new Local(fiber.id(), fiber), globalScope
|
|
|
7239
7248
|
return out;
|
|
7240
7249
|
}, escapeDoubleQuotes = (s)=>`"${s.replace(/\\([\s\S])|(")/g, "\\$1$2")}"`, stringLogger = makeLogger(logger_format(escapeDoubleQuotes)), logfmtLogger = makeLogger(logger_format(JSON.stringify, 0)), structuredLogger = makeLogger(({ annotations, cause, date, fiberId, logLevel, message, spans })=>{
|
|
7241
7250
|
let now = date.getTime(), annotationsObj = {}, spansObj = {};
|
|
7242
|
-
if (hashMap_size(annotations) > 0) for (let [k,
|
|
7251
|
+
if (hashMap_size(annotations) > 0) for (let [k, v] of annotations)annotationsObj[k] = structuredMessage(v);
|
|
7243
7252
|
if (isCons(spans)) for (let span of spans)spansObj[span.label] = now - span.startTime;
|
|
7244
7253
|
let messageArr = ensure(message);
|
|
7245
7254
|
return {
|
|
@@ -7703,11 +7712,11 @@ const state_counter = (count)=>new CounterState(count), state_frequency = (occur
|
|
|
7703
7712
|
let value = startAt;
|
|
7704
7713
|
return hook_make({
|
|
7705
7714
|
get: ()=>state_gauge(value),
|
|
7706
|
-
update: (
|
|
7707
|
-
value =
|
|
7715
|
+
update: (v)=>{
|
|
7716
|
+
value = v;
|
|
7708
7717
|
},
|
|
7709
|
-
modify: (
|
|
7710
|
-
value +=
|
|
7718
|
+
modify: (v)=>{
|
|
7719
|
+
value += v;
|
|
7711
7720
|
}
|
|
7712
7721
|
});
|
|
7713
7722
|
}, hook_histogram = (key)=>{
|
|
@@ -7759,8 +7768,8 @@ const state_counter = (count)=>new CounterState(count), state_frequency = (occur
|
|
|
7759
7768
|
for(; i !== maxSize - 1;){
|
|
7760
7769
|
let item = values[i];
|
|
7761
7770
|
if (null != item) {
|
|
7762
|
-
let [t,
|
|
7763
|
-
Duration_greaterThanOrEqualTo(age, Duration_zero) && Duration_lessThanOrEqualTo(age, maxAge) && builder.push(
|
|
7771
|
+
let [t, v] = item, age = Duration_millis(now - t);
|
|
7772
|
+
Duration_greaterThanOrEqualTo(age, Duration_zero) && Duration_lessThanOrEqualTo(age, maxAge) && builder.push(v);
|
|
7764
7773
|
}
|
|
7765
7774
|
i += 1;
|
|
7766
7775
|
}
|
|
@@ -8187,7 +8196,7 @@ const unsafeTrack = ()=>new Track(), track = sync(unsafeTrack), supervisor_fromE
|
|
|
8187
8196
|
diff: supervisor_patch_diff
|
|
8188
8197
|
}), fiberStarted = ((name, options)=>fromMetricKey(key_counter(name, options)))("effect_fiber_started", {
|
|
8189
8198
|
incremental: !0
|
|
8190
|
-
}), fiberActive = ((name
|
|
8199
|
+
}), fiberActive = ((name)=>fromMetricKey(key_counter(name, void 0)))("effect_fiber_active"), fiberSuccesses = ((name, options)=>fromMetricKey(key_counter(name, options)))("effect_fiber_successes", {
|
|
8191
8200
|
incremental: !0
|
|
8192
8201
|
}), fiberFailures = ((name, options)=>fromMetricKey(key_counter(name, options)))("effect_fiber_failures", {
|
|
8193
8202
|
incremental: !0
|
|
@@ -12116,8 +12125,8 @@ function warnOnClientSourceMaps(normalized, warn, clientEnvName = 'web') {
|
|
|
12116
12125
|
let sourceMapSetting = getClientSourceMapSetting(normalized, clientEnvName), devtoolSetting = getClientDevtoolSetting(normalized, clientEnvName);
|
|
12117
12126
|
(isSourceMapEnabled(sourceMapSetting) || isDevtoolSourceMap(devtoolSetting)) && warn("\n WARNING: Source maps are enabled in production\n This makes your server code publicly visible in the browser.\n This is highly discouraged! If you insist, ensure that you are using\n environment variables for secrets and not hard-coding them in your source code.\n");
|
|
12118
12127
|
}
|
|
12119
|
-
const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions,
|
|
12120
|
-
let transformRouteModule = async (args)=>performanceProfiler.record(args.environment?.name, 'route:module', args.resource, async ()=>
|
|
12128
|
+
const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceProfiler, getLatestServerManifest, getLatestServerManifestByBundleId, routes, pluginOptions, getClientStats, appDirectory, getAssetPrefix, routeChunkOptions, routeTransformRunner, routeByFilePath, routeChunkConfig, isBuild, splitRouteModules, useRouteModuleTransformApi, ssr, isSpaMode, rootRoutePath, isDevHmrEnabled = ()=>!1 })=>{
|
|
12129
|
+
let transformRouteModule = async (args)=>performanceProfiler.record(args.environment?.name, 'route:module', args.resource, async ()=>routeTransformRunner({
|
|
12121
12130
|
kind: 'routeModule',
|
|
12122
12131
|
code: args.code,
|
|
12123
12132
|
resource: args.resource,
|
|
@@ -12152,7 +12161,7 @@ const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceP
|
|
|
12152
12161
|
};
|
|
12153
12162
|
})), api.transform({
|
|
12154
12163
|
resourceQuery: /__react-router-build-client-route/
|
|
12155
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:client-entry', args.resource, async ()=>
|
|
12164
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:client-entry', args.resource, async ()=>routeTransformRunner({
|
|
12156
12165
|
kind: 'routeClientEntry',
|
|
12157
12166
|
code: args.code,
|
|
12158
12167
|
resourcePath: args.resourcePath,
|
|
@@ -12166,7 +12175,7 @@ const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceP
|
|
|
12166
12175
|
environments: [
|
|
12167
12176
|
'web'
|
|
12168
12177
|
]
|
|
12169
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:chunk', args.resource, async ()=>
|
|
12178
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:chunk', args.resource, async ()=>routeTransformRunner({
|
|
12170
12179
|
kind: 'routeChunk',
|
|
12171
12180
|
code: args.code,
|
|
12172
12181
|
resource: args.resource,
|
|
@@ -12181,7 +12190,7 @@ const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceP
|
|
|
12181
12190
|
environments: [
|
|
12182
12191
|
'web'
|
|
12183
12192
|
]
|
|
12184
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:split-exports', args.resource, async ()=>
|
|
12193
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'route:split-exports', args.resource, async ()=>routeTransformRunner({
|
|
12185
12194
|
kind: 'splitRouteExports',
|
|
12186
12195
|
code: args.code,
|
|
12187
12196
|
resourcePath: args.resourcePath,
|
|
@@ -12199,12 +12208,12 @@ const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceP
|
|
|
12199
12208
|
environments: [
|
|
12200
12209
|
'node'
|
|
12201
12210
|
]
|
|
12202
|
-
}, async (args)=>performanceProfiler.record(args.environment?.name, 'module:client-only-stub', args.resource, async ()=>
|
|
12211
|
+
}, async (args)=>performanceProfiler.record(args.environment?.name, 'module:client-only-stub', args.resource, async ()=>routeTransformRunner({
|
|
12203
12212
|
kind: 'clientOnlyStub',
|
|
12204
12213
|
code: args.code,
|
|
12205
12214
|
resourcePath: args.resourcePath,
|
|
12206
12215
|
resolveExportAllModule: 'function' == typeof args.resolve ? createBundlerRouteExportResolver(args.resolve) : void 0
|
|
12207
|
-
}))), api.transform({
|
|
12216
|
+
}))), useRouteModuleTransformApi && (api.transform({
|
|
12208
12217
|
resourceQuery: /\?react-router-route/,
|
|
12209
12218
|
order: 'post'
|
|
12210
12219
|
}, transformRouteModule), api.transform({
|
|
@@ -12213,8 +12222,60 @@ const registerBuildOutputTransforms = ({ api, resolvedServerOutput, performanceP
|
|
|
12213
12222
|
not: /__react-router-build-client-route|react-router-route|route-chunk=/
|
|
12214
12223
|
},
|
|
12215
12224
|
order: 'post'
|
|
12216
|
-
}, transformRouteModule);
|
|
12217
|
-
},
|
|
12225
|
+
}, transformRouteModule));
|
|
12226
|
+
}, routeModuleTransformLoaderPath = (0, external_node_url_namespaceObject.fileURLToPath)(new URL('./route-module-transform-loader.js', __rslib_import_meta_url__)), getRouteModuleTransformParallel = (parallelRouteTransform)=>{
|
|
12227
|
+
if (void 0 !== parallelRouteTransform && !1 !== parallelRouteTransform) {
|
|
12228
|
+
if (!0 === parallelRouteTransform) return !0;
|
|
12229
|
+
if ('number' == typeof parallelRouteTransform) {
|
|
12230
|
+
if (!Number.isInteger(parallelRouteTransform) || parallelRouteTransform < 1) throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
12231
|
+
return {
|
|
12232
|
+
maxWorkers: parallelRouteTransform
|
|
12233
|
+
};
|
|
12234
|
+
}
|
|
12235
|
+
throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
12236
|
+
}
|
|
12237
|
+
}, shouldUseRouteModuleTransformLoader = (parallelRouteTransform)=>void 0 !== getRouteModuleTransformParallel(parallelRouteTransform), createRouteModuleTransformUse = (options, parallelRouteTransform)=>{
|
|
12238
|
+
let parallel = getRouteModuleTransformParallel(parallelRouteTransform);
|
|
12239
|
+
return {
|
|
12240
|
+
loader: routeModuleTransformLoaderPath,
|
|
12241
|
+
options,
|
|
12242
|
+
...parallel ? {
|
|
12243
|
+
parallel
|
|
12244
|
+
} : {}
|
|
12245
|
+
};
|
|
12246
|
+
}, registerRouteModuleTransformRules = (rspackConfig, { environmentName, ssr, isBuild, isSpaMode, rootRoutePath, devHmr, logPerformance, routeByFilePath, parallelRouteTransform })=>{
|
|
12247
|
+
let routeModuleTransformUse = createRouteModuleTransformUse({
|
|
12248
|
+
environmentName,
|
|
12249
|
+
performanceScopeId: [
|
|
12250
|
+
environmentName,
|
|
12251
|
+
isBuild ? 'build' : 'dev',
|
|
12252
|
+
ssr ? 'ssr' : 'spa',
|
|
12253
|
+
rootRoutePath ?? 'rootless'
|
|
12254
|
+
].join(':'),
|
|
12255
|
+
logPerformance,
|
|
12256
|
+
ssr,
|
|
12257
|
+
isBuild,
|
|
12258
|
+
isSpaMode,
|
|
12259
|
+
rootRoutePath,
|
|
12260
|
+
devHmr
|
|
12261
|
+
}, parallelRouteTransform);
|
|
12262
|
+
rspackConfig.module ??= {}, rspackConfig.module.rules ??= [], rspackConfig.module.rules.push({
|
|
12263
|
+
resourceQuery: /\?react-router-route/,
|
|
12264
|
+
enforce: 'post',
|
|
12265
|
+
use: [
|
|
12266
|
+
routeModuleTransformUse
|
|
12267
|
+
]
|
|
12268
|
+
}, {
|
|
12269
|
+
test: (path)=>routeByFilePath.has(path),
|
|
12270
|
+
resourceQuery: {
|
|
12271
|
+
not: /__react-router-build-client-route|react-router-route|route-chunk=/
|
|
12272
|
+
},
|
|
12273
|
+
enforce: 'post',
|
|
12274
|
+
use: [
|
|
12275
|
+
routeModuleTransformUse
|
|
12276
|
+
]
|
|
12277
|
+
});
|
|
12278
|
+
}, yuku_parse = (code, options = {})=>{
|
|
12218
12279
|
let result = (0, external_yuku_parser_namespaceObject.parse)(code, {
|
|
12219
12280
|
...options,
|
|
12220
12281
|
sourceType: options.sourceType ?? 'module',
|
|
@@ -12473,247 +12534,7 @@ if (import.meta.webpackHot) {
|
|
|
12473
12534
|
case 'routeModule':
|
|
12474
12535
|
return route_transform_tasks_transformRouteModule(task);
|
|
12475
12536
|
}
|
|
12476
|
-
}
|
|
12477
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
12478
|
-
if (privateCollection.has(obj)) throw TypeError("Cannot initialize the same private elements twice on an object");
|
|
12479
|
-
}
|
|
12480
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
12481
|
-
return descriptor.get ? descriptor.get.call(receiver) : descriptor.value;
|
|
12482
|
-
}
|
|
12483
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
12484
|
-
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
12485
|
-
else {
|
|
12486
|
-
if (!descriptor.writable) throw TypeError("attempted to set read only private field");
|
|
12487
|
-
descriptor.value = value;
|
|
12488
|
-
}
|
|
12489
|
-
}
|
|
12490
|
-
function _class_apply_descriptor_update(receiver, descriptor) {
|
|
12491
|
-
if (descriptor.set) {
|
|
12492
|
-
if (!descriptor.get) throw TypeError("attempted to read set only private field");
|
|
12493
|
-
return "__destrWrapper" in descriptor || (descriptor.__destrWrapper = {
|
|
12494
|
-
set value (v){
|
|
12495
|
-
descriptor.set.call(receiver, v);
|
|
12496
|
-
},
|
|
12497
|
-
get value () {
|
|
12498
|
-
return descriptor.get.call(receiver);
|
|
12499
|
-
}
|
|
12500
|
-
}), descriptor.__destrWrapper;
|
|
12501
|
-
}
|
|
12502
|
-
if (!descriptor.writable) throw TypeError("attempted to set read only private field");
|
|
12503
|
-
return descriptor;
|
|
12504
|
-
}
|
|
12505
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
12506
|
-
if (!privateMap.has(receiver)) throw TypeError("attempted to " + action + " private field on non-instance");
|
|
12507
|
-
return privateMap.get(receiver);
|
|
12508
|
-
}
|
|
12509
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
12510
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
12511
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
12512
|
-
}
|
|
12513
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
12514
|
-
_check_private_redeclaration(obj, privateMap), privateMap.set(obj, value);
|
|
12515
|
-
}
|
|
12516
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
12517
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
12518
|
-
return _class_apply_descriptor_set(receiver, descriptor, value), value;
|
|
12519
|
-
}
|
|
12520
|
-
function _class_private_field_update(receiver, privateMap) {
|
|
12521
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "update");
|
|
12522
|
-
return _class_apply_descriptor_update(receiver, descriptor);
|
|
12523
|
-
}
|
|
12524
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
12525
|
-
if (!privateSet.has(receiver)) throw TypeError("attempted to get private field on non-instance");
|
|
12526
|
-
return fn;
|
|
12527
|
-
}
|
|
12528
|
-
function _class_private_method_init(obj, privateSet) {
|
|
12529
|
-
_check_private_redeclaration(obj, privateSet), privateSet.add(obj);
|
|
12530
|
-
}
|
|
12531
|
-
function _define_property(obj, key, value) {
|
|
12532
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
12533
|
-
value: value,
|
|
12534
|
-
enumerable: !0,
|
|
12535
|
-
configurable: !0,
|
|
12536
|
-
writable: !0
|
|
12537
|
-
}) : obj[key] = value, obj;
|
|
12538
|
-
}
|
|
12539
|
-
class WorkerStartupError extends Error {
|
|
12540
|
-
constructor(message){
|
|
12541
|
-
super(message), this.name = 'WorkerStartupError';
|
|
12542
|
-
}
|
|
12543
|
-
}
|
|
12544
|
-
const MAX_WORKER_SOURCE_CACHE_ENTRIES = 2048, MAX_ROUTE_SOURCE_WORKER_ENTRIES = 4096, AUTO_PARALLEL_ROUTE_THRESHOLD = 256, DEFAULT_WORKER_COUNT_LIMIT = 2, SMALL_MACHINE_CPU_COUNT = 4, getDefaultWorkerCount = (cpuCount, { isBuild = !1 } = {})=>{
|
|
12545
|
-
let resolvedCpuCount = cpuCount ?? getAvailableCpuCount();
|
|
12546
|
-
return !isBuild && resolvedCpuCount <= 4 ? 0 : Math.min(getDefaultConcurrency(resolvedCpuCount), 2);
|
|
12547
|
-
}, shouldParallelizeRouteTransforms = (routeCount)=>routeCount >= 256, getConfiguredWorkerCount = (parallelRouteTransform, isBuild)=>{
|
|
12548
|
-
if (!0 === parallelRouteTransform) return getDefaultWorkerCount(void 0, {
|
|
12549
|
-
isBuild
|
|
12550
|
-
});
|
|
12551
|
-
if (!Number.isInteger(parallelRouteTransform) || parallelRouteTransform < 1) throw Error('[react-router] parallelRouteTransform must be true, false, or a positive integer.');
|
|
12552
|
-
return parallelRouteTransform;
|
|
12553
|
-
}, hashString = (value)=>{
|
|
12554
|
-
let hash = 0;
|
|
12555
|
-
for(let index = 0; index < value.length; index += 1)hash = 31 * hash + value.charCodeAt(index) >>> 0;
|
|
12556
|
-
return hash;
|
|
12557
|
-
}, deserializeWorkerError = (error)=>{
|
|
12558
|
-
let result = Error(error.message);
|
|
12559
|
-
return result.name = error.name ?? 'Error', error.stack && (result.stack = error.stack), result;
|
|
12560
|
-
}, createWorkerUrl = ()=>new URL('./parallel-route-transform-worker.js', __rslib_import_meta_url__), createDefaultWorker = ()=>new external_node_worker_threads_namespaceObject.Worker(createWorkerUrl()), isWorkerStartupError = (error)=>error instanceof WorkerStartupError, createWorkerStartupError = (error)=>{
|
|
12561
|
-
let normalized = normalizeEffectError(error), startupError = new WorkerStartupError(normalized.message);
|
|
12562
|
-
return startupError.stack = normalized.stack, startupError;
|
|
12563
|
-
}, rejectPendingTasks = (state, error)=>{
|
|
12564
|
-
for (let pending of state.pending.values())pending.reject(error);
|
|
12565
|
-
state.pending.clear();
|
|
12566
|
-
}, createInlineRouteTransformExecutor = (options)=>({
|
|
12567
|
-
run: (task)=>executeRouteTransformTask(task, options),
|
|
12568
|
-
prewarm: ()=>{},
|
|
12569
|
-
close: async ()=>{}
|
|
12570
|
-
});
|
|
12571
|
-
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();
|
|
12572
|
-
class ParallelRouteTransformExecutor {
|
|
12573
|
-
async run(task) {
|
|
12574
|
-
if (_class_private_field_get(this, _closed) || 'clientOnlyStub' === task.kind && task.resolveExportAllModule) return executeRouteTransformTask(task, this.options);
|
|
12575
|
-
try {
|
|
12576
|
-
return await _class_private_method_get(this, _runInWorker, runInWorker).call(this, task);
|
|
12577
|
-
} catch (error) {
|
|
12578
|
-
if (error instanceof WorkerStartupError) return executeRouteTransformTask(task, this.options);
|
|
12579
|
-
throw error;
|
|
12580
|
-
}
|
|
12581
|
-
}
|
|
12582
|
-
prewarm() {
|
|
12583
|
-
_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));
|
|
12584
|
-
}
|
|
12585
|
-
close() {
|
|
12586
|
-
if (_class_private_field_get(this, _closePromise)) return _class_private_field_get(this, _closePromise);
|
|
12587
|
-
_class_private_field_set(this, _closed, !0);
|
|
12588
|
-
let workers = (_class_private_field_get(this, _workers) ?? []).filter((state)=>!!state);
|
|
12589
|
-
return _class_private_field_set(this, _workers, []), _class_private_field_set(this, _closePromise, Promise.all(workers.map(async (state)=>{
|
|
12590
|
-
rejectPendingTasks(state, Error('Route transform worker closed.')), await state.worker.terminate();
|
|
12591
|
-
})).then(()=>void 0)), _class_private_field_get(this, _closePromise);
|
|
12592
|
-
}
|
|
12593
|
-
constructor(workerCount, options, balanceRouteModuleTransforms, createWorker){
|
|
12594
|
-
_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, {
|
|
12595
|
-
writable: !0,
|
|
12596
|
-
value: void 0
|
|
12597
|
-
}), _class_private_field_init(this, _closePromise, {
|
|
12598
|
-
writable: !0,
|
|
12599
|
-
value: void 0
|
|
12600
|
-
}), _class_private_field_init(this, _workersDisabled, {
|
|
12601
|
-
writable: !0,
|
|
12602
|
-
value: void 0
|
|
12603
|
-
}), _class_private_field_init(this, _nextId, {
|
|
12604
|
-
writable: !0,
|
|
12605
|
-
value: void 0
|
|
12606
|
-
}), _class_private_field_init(this, _nextRouteSourceWorkerIndex, {
|
|
12607
|
-
writable: !0,
|
|
12608
|
-
value: void 0
|
|
12609
|
-
}), _class_private_field_init(this, _routeSourceWorkers, {
|
|
12610
|
-
writable: !0,
|
|
12611
|
-
value: void 0
|
|
12612
|
-
}), _class_private_field_init(this, _workers, {
|
|
12613
|
-
writable: !0,
|
|
12614
|
-
value: void 0
|
|
12615
|
-
}), _class_private_field_init(this, _prewarmScheduled, {
|
|
12616
|
-
writable: !0,
|
|
12617
|
-
value: void 0
|
|
12618
|
-
}), 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);
|
|
12619
|
-
}
|
|
12620
|
-
}
|
|
12621
|
-
async function prewarmWorkers() {
|
|
12622
|
-
try {
|
|
12623
|
-
for(let index = 0; index < this.workerCount; index += 1){
|
|
12624
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
12625
|
-
try {
|
|
12626
|
-
_class_private_method_get(this, _getWorker, getWorker).call(this, index);
|
|
12627
|
-
} catch (error) {
|
|
12628
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, createWorkerStartupError(error));
|
|
12629
|
-
return;
|
|
12630
|
-
}
|
|
12631
|
-
}
|
|
12632
|
-
} finally{
|
|
12633
|
-
_class_private_field_set(this, _prewarmScheduled, !1);
|
|
12634
|
-
}
|
|
12635
|
-
}
|
|
12636
|
-
function disableWorkers(error) {
|
|
12637
|
-
if (_class_private_field_get(this, _workersDisabled) || _class_private_field_get(this, _closed)) return;
|
|
12638
|
-
_class_private_field_set(this, _workersDisabled, !0);
|
|
12639
|
-
let workers = (_class_private_field_get(this, _workers) ?? []).filter((state)=>!!state);
|
|
12640
|
-
for (let state of (_class_private_field_set(this, _workers, []), workers))rejectPendingTasks(state, error), state.worker.terminate();
|
|
12641
|
-
}
|
|
12642
|
-
function createWorkerState() {
|
|
12643
|
-
let worker = this.createWorker(), state = {
|
|
12644
|
-
worker,
|
|
12645
|
-
pending: new Map(),
|
|
12646
|
-
sourceCache: new Map()
|
|
12647
|
-
};
|
|
12648
|
-
return worker.on('message', (response)=>{
|
|
12649
|
-
let pending = state.pending.get(response.id);
|
|
12650
|
-
pending && (state.pending.delete(response.id), response.ok ? pending.resolve(response.result) : pending.reject(deserializeWorkerError(response.error)));
|
|
12651
|
-
}), worker.on('error', (error)=>{
|
|
12652
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, createWorkerStartupError(error));
|
|
12653
|
-
}), worker.on('exit', (code)=>{
|
|
12654
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
12655
|
-
let startupError = new WorkerStartupError(`Route transform worker exited with code ${code}.`);
|
|
12656
|
-
_class_private_method_get(this, _disableWorkers, disableWorkers).call(this, startupError);
|
|
12657
|
-
}), state;
|
|
12658
|
-
}
|
|
12659
|
-
function getWorker(index) {
|
|
12660
|
-
if (_class_private_field_get(this, _closed) || _class_private_field_get(this, _workersDisabled)) return;
|
|
12661
|
-
_class_private_field_set(this, _workers, _class_private_field_get(this, _workers) ?? Array(this.workerCount));
|
|
12662
|
-
let existingWorker = _class_private_field_get(this, _workers)[index];
|
|
12663
|
-
if (existingWorker) return existingWorker;
|
|
12664
|
-
let worker = _class_private_method_get(this, _createWorkerState, createWorkerState).call(this);
|
|
12665
|
-
return _class_private_field_get(this, _workers)[index] = worker, worker;
|
|
12666
|
-
}
|
|
12667
|
-
function runInWorker(task) {
|
|
12668
|
-
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);
|
|
12669
|
-
if (!state) return executeRouteTransformTask(task, this.options);
|
|
12670
|
-
let id = _class_private_field_update(this, _nextId).value++, sourceCacheKey = task.resourcePath, requestTask = _class_private_method_get(this, _createWorkerRequestTask, createWorkerRequestTask).call(this, state, task, sourceCacheKey);
|
|
12671
|
-
return new Promise((resolve, reject)=>{
|
|
12672
|
-
state.pending.set(id, {
|
|
12673
|
-
resolve,
|
|
12674
|
-
reject
|
|
12675
|
-
});
|
|
12676
|
-
try {
|
|
12677
|
-
state.worker.postMessage({
|
|
12678
|
-
id,
|
|
12679
|
-
task: requestTask,
|
|
12680
|
-
sourceCacheKey
|
|
12681
|
-
});
|
|
12682
|
-
} catch (error) {
|
|
12683
|
-
state.pending.delete(id), state.sourceCache.delete(sourceCacheKey), reject(normalizeEffectError(error));
|
|
12684
|
-
}
|
|
12685
|
-
});
|
|
12686
|
-
}
|
|
12687
|
-
function createWorkerRequestTask(state, task, sourceCacheKey) {
|
|
12688
|
-
if (state.sourceCache.get(sourceCacheKey) === task.code) {
|
|
12689
|
-
let { code: _code, ...cachedTask } = task;
|
|
12690
|
-
return cachedTask;
|
|
12691
|
-
}
|
|
12692
|
-
return setBoundedCacheEntry(state.sourceCache, sourceCacheKey, task.code, 2048), task;
|
|
12693
|
-
}
|
|
12694
|
-
function getWorkerIndex(task, workerCount) {
|
|
12695
|
-
let safeWorkerCount = Math.max(1, workerCount);
|
|
12696
|
-
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) : hashString(task.resourcePath) % safeWorkerCount;
|
|
12697
|
-
}
|
|
12698
|
-
function getRouteSourceWorkerIndex(resourcePath, safeWorkerCount) {
|
|
12699
|
-
let existingWorkerIndex = _class_private_field_get(this, _routeSourceWorkers).get(resourcePath);
|
|
12700
|
-
if (void 0 !== existingWorkerIndex) return _class_private_field_get(this, _routeSourceWorkers).delete(resourcePath), _class_private_field_get(this, _routeSourceWorkers).set(resourcePath, existingWorkerIndex), existingWorkerIndex % safeWorkerCount;
|
|
12701
|
-
let workerIndex = _class_private_field_get(this, _nextRouteSourceWorkerIndex) % safeWorkerCount;
|
|
12702
|
-
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;
|
|
12703
|
-
}
|
|
12704
|
-
const createRouteTransformExecutor = ({ parallelRouteTransform, routeChunkCache, splitRouteModules, isBuild } = {})=>createRouteTransformExecutorWithWorkerFactory({
|
|
12705
|
-
parallelRouteTransform,
|
|
12706
|
-
routeChunkCache,
|
|
12707
|
-
splitRouteModules,
|
|
12708
|
-
isBuild
|
|
12709
|
-
}, createDefaultWorker), createRouteTransformExecutorWithWorkerFactory = ({ parallelRouteTransform, routeChunkCache, splitRouteModules, isBuild } = {}, createWorker)=>{
|
|
12710
|
-
let options = {
|
|
12711
|
-
routeChunkCache
|
|
12712
|
-
};
|
|
12713
|
-
if (void 0 === parallelRouteTransform || !1 === parallelRouteTransform) return createInlineRouteTransformExecutor(options);
|
|
12714
|
-
let workerCount = getConfiguredWorkerCount(parallelRouteTransform, !!isBuild);
|
|
12715
|
-
return workerCount < 1 ? createInlineRouteTransformExecutor(options) : new ParallelRouteTransformExecutor(workerCount, options, !!splitRouteModules, createWorker);
|
|
12716
|
-
}, createRouteTransformExecutorForTesting = (options, createWorker)=>createRouteTransformExecutorWithWorkerFactory(options, createWorker), ROUTE_RESTART_MARKER_ASSET = '.react-router/route-watch', INITIAL_RESTART_MARKER_CONTENT = 'react-router-route-watch', ROUTE_TOPOLOGY_RESCAN_DEBOUNCE_MS = 100, ROUTE_DIRECTORY_SCAN_CONCURRENCY = getCappedPluginConcurrency(), defaultWatchDirectoryEntry = (directory, onChange, onError)=>{
|
|
12537
|
+
}, ROUTE_RESTART_MARKER_ASSET = '.react-router/route-watch', INITIAL_RESTART_MARKER_CONTENT = 'react-router-route-watch', ROUTE_TOPOLOGY_RESCAN_DEBOUNCE_MS = 100, ROUTE_DIRECTORY_SCAN_CONCURRENCY = getCappedPluginConcurrency(), defaultWatchDirectoryEntry = (directory, onChange, onError)=>{
|
|
12717
12538
|
let watcher = (0, external_node_fs_namespaceObject.watch)(directory, onChange);
|
|
12718
12539
|
return watcher.on('error', onError), watcher;
|
|
12719
12540
|
}, mergeWatchFiles = (existing, additions)=>existing ? [
|
|
@@ -13014,7 +12835,7 @@ const MAX_SLOWEST_ENTRIES = 5, insertSlowestEntry = (slowest, entry)=>{
|
|
|
13014
12835
|
let insertIndex = slowest.length;
|
|
13015
12836
|
for(; insertIndex > 0 && entry.durationMs > slowest[insertIndex - 1].durationMs;)insertIndex -= 1;
|
|
13016
12837
|
slowest.splice(insertIndex, 0, entry), slowest.length > 5 && slowest.pop();
|
|
13017
|
-
}, roundMs = (value)=>Math.round(10 * value) / 10, createReactRouterPerformanceProfiler = ({ enabled, log })=>{
|
|
12838
|
+
}, roundMs = (value)=>Math.round(10 * value) / 10, formatReactRouterPerformanceReport = (report)=>`[react-router:performance] ${JSON.stringify(report)}`, createReactRouterPerformanceProfiler = ({ enabled, log })=>{
|
|
13018
12839
|
let timingsByEnvironment = new Map(), recordDuration = (environment, operation, resource, startMs, endMs)=>{
|
|
13019
12840
|
let timings, timing, duration = endMs - startMs, timing1 = ((timings = timingsByEnvironment.get(environment)) || (timings = new Map(), timingsByEnvironment.set(environment, timings)), (timing = timings.get(operation)) || (timing = {
|
|
13020
12841
|
count: 0,
|
|
@@ -13091,12 +12912,12 @@ const MAX_SLOWEST_ENTRIES = 5, insertSlowestEntry = (slowest, entry)=>{
|
|
|
13091
12912
|
resource: entry.resource
|
|
13092
12913
|
}))
|
|
13093
12914
|
}
|
|
13094
|
-
]))
|
|
12915
|
+
]));
|
|
12916
|
+
log(formatReactRouterPerformanceReport({
|
|
13095
12917
|
environment: resolvedEnvironment,
|
|
13096
12918
|
...details,
|
|
13097
12919
|
operations
|
|
13098
|
-
};
|
|
13099
|
-
log(`[react-router:performance] ${JSON.stringify(report)}`), timingsByEnvironment.delete(resolvedEnvironment);
|
|
12920
|
+
})), timingsByEnvironment.delete(resolvedEnvironment);
|
|
13100
12921
|
}
|
|
13101
12922
|
};
|
|
13102
12923
|
}, VIRTUAL_MODULE_PREFIX = 'virtual/react-router/', getVirtualModuleFilePath = (moduleId)=>{
|
|
@@ -14193,7 +14014,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14193
14014
|
let errors = (await Promise.allSettled(closers.map((closer)=>closer()))).filter((result)=>'rejected' === result.status).map((result)=>normalizeEffectError(result.reason));
|
|
14194
14015
|
if (1 === errors.length) throw errors[0];
|
|
14195
14016
|
if (errors.length > 1) throw AggregateError(errors, message);
|
|
14196
|
-
}, registerReactRouterDevBackgroundResources = ({ api, isBuild, lazyCompilationPrewarm,
|
|
14017
|
+
}, registerReactRouterDevBackgroundResources = ({ api, isBuild, lazyCompilationPrewarm, routeRestartMarkerPath, watchDirectory, getRouteTopology, initialRouteTopology, onRouteTopologyChange })=>{
|
|
14197
14018
|
let closeActiveRouteTopologyWatcher, routeTopologyWatcherClosed = !1, reportRouteTopologyWatcherError = (error)=>{
|
|
14198
14019
|
api.logger.warn(`[${PLUGIN_NAME}] Failed to watch route topology changes: ${String(normalizeEffectError(error))}`);
|
|
14199
14020
|
}, routeTopologyWatcherTask = createDelayedPluginTask({
|
|
@@ -14221,31 +14042,21 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14221
14042
|
lazyCompilationPrewarmController?.setServerOrigin(`http://localhost:${port}`), lazyCompilationPrewarmController?.schedule();
|
|
14222
14043
|
}), api.onAfterDevCompile(()=>{
|
|
14223
14044
|
routeTopologyWatcherClosed || closeActiveRouteTopologyWatcher || routeTopologyWatcherTask.schedule(), lazyCompilationPrewarmController?.schedule();
|
|
14224
|
-
})
|
|
14045
|
+
}));
|
|
14225
14046
|
let closeRouteTopologyWatcher = async ()=>{
|
|
14226
14047
|
routeTopologyWatcherClosed = !0, await runPluginEffect(routeTopologyWatcherTask.cancelEffect()), await closeActiveRouteTopologyWatcher?.(), closeActiveRouteTopologyWatcher = void 0;
|
|
14227
14048
|
}, closeLazyCompilationPrewarm = async ()=>{
|
|
14228
14049
|
await runPluginEffect(lazyCompilationPrewarmController?.cancelEffect() ?? core_void_);
|
|
14229
|
-
}
|
|
14050
|
+
};
|
|
14230
14051
|
return api.onCloseDevServer(()=>closeAll('[rsbuild-plugin-react-router] Failed to close dev server resources.', [
|
|
14231
14052
|
closeRouteTopologyWatcher,
|
|
14232
|
-
closeLazyCompilationPrewarm
|
|
14233
|
-
|
|
14234
|
-
])), api.onCloseBuild(closeRouteTransformExecutor), {
|
|
14053
|
+
closeLazyCompilationPrewarm
|
|
14054
|
+
])), {
|
|
14235
14055
|
setManifest (manifest) {
|
|
14236
14056
|
lazyCompilationPrewarmController?.setManifest(manifest);
|
|
14237
14057
|
}
|
|
14238
14058
|
};
|
|
14239
|
-
}, MIN_PARALLEL_ENVIRONMENT_BUILD_SPARE_CORES = 4, shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefaultConcurrency() })=>!isBuild && spareCoreCount >= 4,
|
|
14240
|
-
if (rspackConfig?.plugins?.length) for (let plugin of rspackConfig.plugins){
|
|
14241
|
-
if (!plugin || 'object' != typeof plugin || 'ModuleFederationPlugin' !== plugin.name) continue;
|
|
14242
|
-
let pluginOptions = plugin._options ?? plugin.options;
|
|
14243
|
-
pluginOptions && (pluginOptions.experiments = {
|
|
14244
|
-
...pluginOptions.experiments,
|
|
14245
|
-
asyncStartup: !0
|
|
14246
|
-
});
|
|
14247
|
-
}
|
|
14248
|
-
}, cssUrlAssetExtensions = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/, urlAssetResourceQuery = /^(?=.*(?:\?|&)url(?:&|$))(?!.*(?:\?|&)(?:raw|inline)(?:&|$))/, pluginReactRouter = (options = {})=>({
|
|
14059
|
+
}, MIN_PARALLEL_ENVIRONMENT_BUILD_SPARE_CORES = 4, shouldParallelizeEnvironmentBuilds = ({ isBuild, spareCoreCount = getDefaultConcurrency() })=>!isBuild && spareCoreCount >= 4, cssUrlAssetExtensions = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/, urlAssetResourceQuery = /^(?=.*(?:\?|&)url(?:&|$))(?!.*(?:\?|&)(?:raw|inline)(?:&|$))/, pluginReactRouter = (options = {})=>({
|
|
14249
14060
|
name: PLUGIN_NAME,
|
|
14250
14061
|
async setup (api) {
|
|
14251
14062
|
let routeDiscovery, clientStats, pluginOptions = {
|
|
@@ -14349,12 +14160,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14349
14160
|
});
|
|
14350
14161
|
let isBuild = 'build' === api.context.action, shouldDependOnWebCompiler = !shouldParallelizeEnvironmentBuilds({
|
|
14351
14162
|
isBuild
|
|
14352
|
-
}), isPrerenderEnabled = void 0 !== prerenderConfig && !1 !== prerenderConfig, isSpaMode = !ssr && !isPrerenderEnabled, routeCount = Object.keys(routes).length, routeChunkCache = new Map(),
|
|
14353
|
-
parallelRouteTransform: pluginOptions.parallelRouteTransform ?? routeCount >= 256,
|
|
14354
|
-
routeChunkCache,
|
|
14355
|
-
splitRouteModules: !!splitRouteModules,
|
|
14356
|
-
isBuild
|
|
14357
|
-
}), routeChunkOptions = {
|
|
14163
|
+
}), isPrerenderEnabled = void 0 !== prerenderConfig && !1 !== prerenderConfig, isSpaMode = !ssr && !isPrerenderEnabled, routeCount = Object.keys(routes).length, routeChunkCache = new Map(), useRouteModuleTransformLoader = void 0 !== getRouteModuleTransformParallel(pluginOptions.parallelRouteTransform), routeChunkOptions = {
|
|
14358
14164
|
splitRouteModules,
|
|
14359
14165
|
rootRouteFile,
|
|
14360
14166
|
isBuild,
|
|
@@ -14368,7 +14174,6 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14368
14174
|
api,
|
|
14369
14175
|
isBuild,
|
|
14370
14176
|
lazyCompilationPrewarm: pluginOptions.unstableLazyCompilationPrewarm,
|
|
14371
|
-
routeTransformExecutor,
|
|
14372
14177
|
routeRestartMarkerPath,
|
|
14373
14178
|
watchDirectory,
|
|
14374
14179
|
getRouteTopology: routeTopology.getRouteTopology,
|
|
@@ -14663,7 +14468,18 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14663
14468
|
}), api.modifyEnvironmentConfig(async (config, { name, mergeEnvironmentConfig })=>'web' !== name && 'node' !== name ? config : mergeEnvironmentConfig(config, {
|
|
14664
14469
|
tools: {
|
|
14665
14470
|
rspack: (rspackConfig)=>{
|
|
14666
|
-
|
|
14471
|
+
let environmentDevHmrEnabled = 'web' === name && !isBuild && void 0 !== devHmrRefreshRuntimePath && 'development' === config.mode && config.dev?.hmr !== !1 && isRspackSwcReactRefreshEnabled(rspackConfig);
|
|
14472
|
+
if (useRouteModuleTransformLoader && registerRouteModuleTransformRules(rspackConfig, {
|
|
14473
|
+
environmentName: name,
|
|
14474
|
+
ssr,
|
|
14475
|
+
isBuild,
|
|
14476
|
+
isSpaMode,
|
|
14477
|
+
rootRoutePath,
|
|
14478
|
+
devHmr: environmentDevHmrEnabled,
|
|
14479
|
+
logPerformance,
|
|
14480
|
+
routeByFilePath,
|
|
14481
|
+
parallelRouteTransform: pluginOptions.parallelRouteTransform
|
|
14482
|
+
}), pluginOptions.federation && ensureFederationAsyncStartup(rspackConfig), 'web' === name && (devHmrEnabled = environmentDevHmrEnabled) && devHdrSignal?.ensure(), 'node' === name) {
|
|
14667
14483
|
let output = rspackConfig.output;
|
|
14668
14484
|
if (output) {
|
|
14669
14485
|
let library = output.library, libraryOptions = library && 'object' == typeof library && !Array.isArray(library) ? library : {};
|
|
@@ -14719,7 +14535,9 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14719
14535
|
appDirectory,
|
|
14720
14536
|
getAssetPrefix: ()=>assetPrefix,
|
|
14721
14537
|
routeChunkOptions,
|
|
14722
|
-
|
|
14538
|
+
routeTransformRunner: (task)=>executeRouteTransformTask(task, {
|
|
14539
|
+
routeChunkCache
|
|
14540
|
+
}),
|
|
14723
14541
|
routeByFilePath,
|
|
14724
14542
|
routeChunkConfig: {
|
|
14725
14543
|
splitRouteModules,
|
|
@@ -14728,6 +14546,7 @@ if (typeof window !== 'undefined' && import.meta.webpackHot) {
|
|
|
14728
14546
|
},
|
|
14729
14547
|
isBuild,
|
|
14730
14548
|
splitRouteModules: !!splitRouteModules,
|
|
14549
|
+
useRouteModuleTransformApi: !useRouteModuleTransformLoader,
|
|
14731
14550
|
ssr,
|
|
14732
14551
|
isSpaMode,
|
|
14733
14552
|
rootRoutePath,
|