@remix-run/router 1.16.0-pre.0 → 1.16.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/CHANGELOG.md CHANGED
@@ -1,28 +1,20 @@
1
1
  # `@remix-run/router`
2
2
 
3
- ## 1.16.0-pre.0
3
+ ## 1.16.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
8
-
9
8
  - This option allows Data Router applications to take control over the approach for executing route loaders and actions
10
9
  - The default implementation is today's behavior, to fetch all loaders in parallel, but this option allows users to implement more advanced data flows including Remix single-fetch, middleware/context APIs, automatic loader caching, and more
11
-
10
+ - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377))
12
11
  - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098))
13
-
14
12
  - Currently, active loaders revalidate after any action, regardless of the result
15
13
  - With this flag enabled, actions that return/throw a 4xx/5xx response status will no longer automatically revalidate
16
14
  - This should reduce load on your server since it's rare that a 4xx/5xx should actually mutate any data
17
15
  - If you need to revalidate after a 4xx/5xx result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate`
18
16
  - `shouldRevalidate` now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data
19
-
20
- - - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377))
21
- - Added a new `skipLoaders` flag to `staticHandler.query` for calling only the action in Remix Single Fetch
22
- - Added 2 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098))
23
-
24
- - `loadRouteIds`: An optional array of route IDs to load if you wish to load a subset of the matched routes (useful for fine-grained revalidation)
25
- - `skipLoaderErrorBubbling`: Disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling
17
+ - Added a `skipLoaderErrorBubbling` flag to `staticHandler.query` to disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling ([#11098](https://github.com/remix-run/react-router/pull/11098))
26
18
 
27
19
  ## 1.15.3
28
20
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.16.0-pre.0
2
+ * @remix-run/router v1.16.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -3349,23 +3349,17 @@ function createStaticHandler(routes, opts) {
3349
3349
  * propagate that out and return the raw Response so the HTTP server can
3350
3350
  * return it directly.
3351
3351
  *
3352
- * - `opts.loadRouteIds` is an optional array of routeIds to run only a subset of
3353
- * loaders during a query() call
3354
3352
  * - `opts.requestContext` is an optional server context that will be passed
3355
3353
  * to actions/loaders in the `context` parameter
3356
3354
  * - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent
3357
3355
  * the bubbling of errors which allows single-fetch-type implementations
3358
3356
  * where the client will handle the bubbling and we may need to return data
3359
3357
  * for the handling route
3360
- * - `opts.skipLoaders` is an optional parameter that will prevent loaders
3361
- * from running after an action
3362
3358
  */
3363
3359
  async function query(request, _temp3) {
3364
3360
  let {
3365
- loadRouteIds,
3366
3361
  requestContext,
3367
3362
  skipLoaderErrorBubbling,
3368
- skipLoaders,
3369
3363
  unstable_dataStrategy
3370
3364
  } = _temp3 === void 0 ? {} : _temp3;
3371
3365
  let url = new URL(request.url);
@@ -3419,7 +3413,7 @@ function createStaticHandler(routes, opts) {
3419
3413
  activeDeferreds: null
3420
3414
  };
3421
3415
  }
3422
- let result = await queryImpl(request, location, matches, requestContext, unstable_dataStrategy || null, loadRouteIds || null, skipLoaderErrorBubbling === true, skipLoaders === true, null);
3416
+ let result = await queryImpl(request, location, matches, requestContext, unstable_dataStrategy || null, skipLoaderErrorBubbling === true, null);
3423
3417
  if (isResponse(result)) {
3424
3418
  return result;
3425
3419
  }
@@ -3491,7 +3485,7 @@ function createStaticHandler(routes, opts) {
3491
3485
  pathname: location.pathname
3492
3486
  });
3493
3487
  }
3494
- let result = await queryImpl(request, location, matches, requestContext, null, null, false, false, match);
3488
+ let result = await queryImpl(request, location, matches, requestContext, null, false, match);
3495
3489
  if (isResponse(result)) {
3496
3490
  return result;
3497
3491
  }
@@ -3518,14 +3512,14 @@ function createStaticHandler(routes, opts) {
3518
3512
  }
3519
3513
  return undefined;
3520
3514
  }
3521
- async function queryImpl(request, location, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, skipLoaders, routeMatch) {
3515
+ async function queryImpl(request, location, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch) {
3522
3516
  invariant(request.signal, "query()/queryRoute() requests must contain an AbortController signal");
3523
3517
  try {
3524
3518
  if (isMutationMethod(request.method.toLowerCase())) {
3525
- let result = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, skipLoaders, routeMatch != null);
3519
+ let result = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch != null);
3526
3520
  return result;
3527
3521
  }
3528
- let result = await loadRouteData(request, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, routeMatch);
3522
+ let result = await loadRouteData(request, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch);
3529
3523
  return isResponse(result) ? result : _extends({}, result, {
3530
3524
  actionData: null,
3531
3525
  actionHeaders: {}
@@ -3548,7 +3542,7 @@ function createStaticHandler(routes, opts) {
3548
3542
  throw e;
3549
3543
  }
3550
3544
  }
3551
- async function submit(request, matches, actionMatch, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, skipLoaders, isRouteRequest) {
3545
+ async function submit(request, matches, actionMatch, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, isRouteRequest) {
3552
3546
  let result;
3553
3547
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
3554
3548
  let error = getInternalRouterError(405, {
@@ -3626,51 +3620,18 @@ function createStaticHandler(routes, opts) {
3626
3620
  // Store off the pending error - we use it to determine which loaders
3627
3621
  // to call and will commit it when we complete the navigation
3628
3622
  let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
3629
- let statusCode = isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500;
3630
- let actionHeaders = _extends({}, result.headers ? {
3631
- [actionMatch.route.id]: result.headers
3632
- } : {});
3633
- if (skipLoaders) {
3634
- return {
3635
- matches,
3636
- loaderData: {},
3637
- actionData: {},
3638
- errors: {
3639
- [boundaryMatch.route.id]: result.error
3640
- },
3641
- statusCode,
3642
- loaderHeaders: {},
3643
- actionHeaders,
3644
- activeDeferreds: null
3645
- };
3646
- }
3647
- let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result]);
3623
+ let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result]);
3648
3624
 
3649
3625
  // action status codes take precedence over loader status codes
3650
3626
  return _extends({}, context, {
3651
- statusCode,
3627
+ statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500,
3652
3628
  actionData: null,
3653
- actionHeaders
3629
+ actionHeaders: _extends({}, result.headers ? {
3630
+ [actionMatch.route.id]: result.headers
3631
+ } : {})
3654
3632
  });
3655
3633
  }
3656
- let actionHeaders = result.headers ? {
3657
- [actionMatch.route.id]: result.headers
3658
- } : {};
3659
- if (skipLoaders) {
3660
- return {
3661
- matches,
3662
- loaderData: {},
3663
- actionData: {
3664
- [actionMatch.route.id]: result.data
3665
- },
3666
- errors: null,
3667
- statusCode: result.statusCode || 200,
3668
- loaderHeaders: {},
3669
- actionHeaders,
3670
- activeDeferreds: null
3671
- };
3672
- }
3673
- let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, null);
3634
+ let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, null);
3674
3635
  return _extends({}, context, {
3675
3636
  actionData: {
3676
3637
  [actionMatch.route.id]: result.data
@@ -3683,7 +3644,7 @@ function createStaticHandler(routes, opts) {
3683
3644
  } : {}
3684
3645
  });
3685
3646
  }
3686
- async function loadRouteData(request, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, routeMatch, pendingActionResult) {
3647
+ async function loadRouteData(request, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch, pendingActionResult) {
3687
3648
  let isRouteRequest = routeMatch != null;
3688
3649
 
3689
3650
  // Short circuit if we have no loaders to run (queryRoute())
@@ -3696,9 +3657,6 @@ function createStaticHandler(routes, opts) {
3696
3657
  }
3697
3658
  let requestMatches = routeMatch ? [routeMatch] : pendingActionResult && isErrorResult(pendingActionResult[1]) ? getLoaderMatchesUntilBoundary(matches, pendingActionResult[0]) : matches;
3698
3659
  let matchesToLoad = requestMatches.filter(m => m.route.loader || m.route.lazy);
3699
- if (loadRouteIds) {
3700
- matchesToLoad = matchesToLoad.filter(m => loadRouteIds.includes(m.route.id));
3701
- }
3702
3660
 
3703
3661
  // Short circuit if we have no loaders to run (query())
3704
3662
  if (matchesToLoad.length === 0) {