Socket
Socket
Sign inDemoInstall

@remix-run/server-runtime

Package Overview
Dependencies
8
Maintainers
2
Versions
929
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install
2345
93Next

0.0.0-nightly-6eb6acf3f-20240511

Diff

mjackson
published 2.9.2 •

Changelog

Source

v2.9.2

Date: 2024-05-10

What's Changed

Updated Type-Safety for Single Fetch

In 2.9.2 we've enhanced the type-safety when opting into the future.unstable_singleFetch feature. Previously, we added the response stub to LoaderFunctionArgs and used type overrides for inference on useLoaderData, etc., but we found that it wasn't quite enough.

With this release we're introducing new functions to assist the type-inference when using single fetch - defineLoader/defineAction and their client-side counterparts defineClientLoader and nd defineClientAction. These are identity functions; they don't modify your loader or action at runtime. Rather, they exist solely for type-safety by providing types for args and by ensuring valid return types.

export const loader = defineLoader(({ request }) => {
  //                                ^? Request
  return { a: 1, b: () => 2 };
  //           ^ type error: `b` is not serializable
});

Note that defineLoader and defineAction are not technically necessary for defining loaders and actions if you aren't concerned with type-safety:

// this totally works! and typechecking is happy too!
export const loader = () => {
  return { a: 1 };
};

This means that you can opt-in to defineLoader incrementally, one loader at a time.

Please see the Single Fetch docs for more information.

Patch Changes

  • @remix-run/dev - Vite: Fix dest already exists error when running remix vite:build (#9305)
  • @remix-run/dev - Vite: Fix issue resolving critical CSS during development when route files are located outside of the app directory (#9194)
  • @remix-run/dev - Vite: Remove @remix-run/node from Vite plugin's optimizeDeps.include list since it was unnecessary and resulted in Vite warnings when not depending on this package (#9287)
  • @remix-run/dev - Vite: Clean up redundant ?client-route=1 imports in development (#9395)
  • @remix-run/dev - Vite: Ensure Babel config files are not referenced when applying the react-refresh Babel transform within the Remix Vite plugin (#9241)
  • @remix-run/react - Type-safety for single-fetch: defineLoader, defineClientLoader, defineAction, defineClientAction (#9372)
  • @remix-run/react - Single Fetch: Add undefined to useActionData type override (#9322)
  • @remix-run/react - Single Fetch: Allow a nonce to be set on single fetch stream transfer inline scripts via <RemixServer> (#9364)
  • @remix-run/server-runtime - Single Fetch: Don't log thrown response stubs via handleError (#9369)
  • @remix-run/server-runtime - Single Fetch: Automatically wrap resource route naked object returns in json() for back-compat in v2 (and log deprecation warning) (#9349)
  • @remix-run/server-runtime - Single Fetch: Pass response stub to resource route handlers (#9349)

Updated Dependencies

Changes by Package

Full Changelog: v2.9.1...v2.9.2

mjackson
published 2.9.2-pre.2 •

mjackson
published 0.0.0-nightly-a4c6f935e-20240510 •

mjackson
published 2.9.2-pre.1 •

mjackson
published 2.9.2-pre.0 •

mjackson
published 0.0.0-experimental-394b09463 •

mjackson
published 0.0.0-nightly-45c755219-20240509 •

mjackson
published 0.0.0-nightly-feb25eb42-20240508 •

mjackson
published 0.0.0-nightly-142f47be5-20240507 •

2345
93Next
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc