@remix-run/router 0.0.0-experimental-acfea932 → 0.0.0-experimental-2272fa73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router.cjs.js +10 -10
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +10 -10
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +10 -10
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
- package/router.ts +11 -15
- package/utils.ts +2 -3
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-2272fa73
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -4133,7 +4133,7 @@ async function loadLazyRouteModule(route, mapRouteProperties, manifest) {
|
|
|
4133
4133
|
|
|
4134
4134
|
// Default implementation of `dataStrategy` which fetches all loaders in parallel
|
|
4135
4135
|
function defaultDataStrategy(opts) {
|
|
4136
|
-
return Promise.all(opts.matches.map(m => m.
|
|
4136
|
+
return Promise.all(opts.matches.map(m => m.resolve()));
|
|
4137
4137
|
}
|
|
4138
4138
|
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, manifest, mapRouteProperties, requestContext) {
|
|
4139
4139
|
let routeIdsToLoad = matchesToLoad.reduce((acc, m) => acc.add(m.route.id), new Set());
|
|
@@ -4144,14 +4144,14 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
4144
4144
|
// back out below.
|
|
4145
4145
|
let results = await dataStrategyImpl({
|
|
4146
4146
|
matches: matches.map(match => {
|
|
4147
|
-
let
|
|
4148
|
-
// `
|
|
4147
|
+
let shouldLoad = routeIdsToLoad.has(match.route.id);
|
|
4148
|
+
// `resolve` encapsulates the route.lazy, executing the
|
|
4149
4149
|
// loader/action, and mapping return values/thrown errors to a
|
|
4150
4150
|
// HandlerResult. Users can pass a callback to take fine-grained control
|
|
4151
4151
|
// over the execution of the loader/action
|
|
4152
|
-
let
|
|
4152
|
+
let resolve = handlerOverride => {
|
|
4153
4153
|
loadedMatches.add(match.route.id);
|
|
4154
|
-
return
|
|
4154
|
+
return shouldLoad ? callLoaderOrAction(type, request, match, manifest, mapRouteProperties, handlerOverride, requestContext) :
|
|
4155
4155
|
// TODO: What's the best thing to do here - return an empty "success" result?
|
|
4156
4156
|
// Or return a success result with the current route loader/action data?
|
|
4157
4157
|
// We strip these results out if the route didn't need to be revalidated in
|
|
@@ -4163,8 +4163,8 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
4163
4163
|
});
|
|
4164
4164
|
};
|
|
4165
4165
|
return _extends({}, match, {
|
|
4166
|
-
|
|
4167
|
-
|
|
4166
|
+
shouldLoad,
|
|
4167
|
+
resolve
|
|
4168
4168
|
});
|
|
4169
4169
|
}),
|
|
4170
4170
|
request,
|
|
@@ -4175,7 +4175,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
4175
4175
|
// ensures a route is fully loaded
|
|
4176
4176
|
// Throw if any loadRoute implementations not called since they are what
|
|
4177
4177
|
// ensure a route is fully loaded
|
|
4178
|
-
matches.forEach(m => invariant(loadedMatches.has(m.route.id), "`match.
|
|
4178
|
+
matches.forEach(m => invariant(loadedMatches.has(m.route.id), "`match.resolve()` was not called for route id \"" + m.route.id + "\". " + "You must call `match.resolve()` on every match passed to " + "`dataStrategy` to ensure all routes are properly loaded."));
|
|
4179
4179
|
|
|
4180
4180
|
// Filter out any middleware-only matches for which we didn't need to run handlers
|
|
4181
4181
|
return results.filter((_, i) => routeIdsToLoad.has(matches[i].route.id));
|
|
@@ -4217,7 +4217,7 @@ async function callLoaderOrAction(type, request, match, manifest, mapRouteProper
|
|
|
4217
4217
|
runHandler(handler).catch(e => {
|
|
4218
4218
|
handlerError = e;
|
|
4219
4219
|
}), loadLazyRouteModule(match.route, mapRouteProperties, manifest)]);
|
|
4220
|
-
if (handlerError) {
|
|
4220
|
+
if (handlerError !== undefined) {
|
|
4221
4221
|
throw handlerError;
|
|
4222
4222
|
}
|
|
4223
4223
|
result = values[0];
|