@remix-run/node
Advanced tools
Changelog
v2.9.2
Date: 2024-05-10
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.
@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)@remix-run/cloudflare
@remix-run/cloudflare-pages
@remix-run/cloudflare-workers
@remix-run/css-bundle
@remix-run/deno
@remix-run/dev
@remix-run/eslint-config
@remix-run/express
@remix-run/node
@remix-run/react
@remix-run/serve
@remix-run/server-runtime
@remix-run/testing
Full Changelog: v2.9.1...v2.9.2