@remix-run/node
Advanced tools
Comparing version 2.9.1 to 2.9.2-pre.0
# `@remix-run/node` | ||
## 2.9.2-pre.0 | ||
### Patch Changes | ||
- Typesafety for single-fetch: defineLoader, defineClientLoader, defineAction, defineClientAction ([#9372](https://github.com/remix-run/remix/pull/9372)) | ||
`defineLoader` and `defineAction` are helpers for authoring `loader`s and `action`s. | ||
They are identity functions; they don't modify your loader or action at runtime. | ||
Rather, they exist solely for typesafety by providing types for args and by ensuring valid return types. | ||
```ts | ||
export let 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 typesafety: | ||
```ts | ||
// this totally works! and typechecking is happy too! | ||
export let loader = () => { | ||
return { a: 1 }; | ||
}; | ||
``` | ||
This means that you can opt-in to `defineLoader` incrementally, one loader at a time. | ||
You can return custom responses via the `json`/`defer` utilities, but doing so will revert back to the old JSON-based typesafety mechanism: | ||
```ts | ||
let loader1 = () => { | ||
return { a: 1, b: new Date() }; | ||
}; | ||
let data1 = useLoaderData<typeof loader1>(); | ||
// ^? {a: number, b: Date} | ||
let loader2 = () => { | ||
return json({ a: 1, b: new Date() }); // this opts-out of turbo-stream | ||
}; | ||
let data2 = useLoaderData<typeof loader2>(); | ||
// ^? JsonifyObject<{a: number, b: Date}> which is really {a: number, b: string} | ||
``` | ||
You can also continue to return totally custom responses with `Response` though this continues to be outside of the typesystem since the built-in `Response` type is not generic | ||
- Updated dependencies: | ||
- `@remix-run/server-runtime@2.9.2-pre.0` | ||
## 2.9.1 | ||
@@ -4,0 +54,0 @@ |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -6,3 +6,3 @@ export { installGlobals } from "./globals"; | ||
export { createReadableStreamFromReadable, readableStreamToString, writeAsyncIterableToWritable, writeReadableStreamToWritable, } from "./stream"; | ||
export { createRequestHandler, createSession, defer, broadcastDevReady, logDevReady, isCookie, isSession, json, MaxPartSizeExceededError, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, } from "@remix-run/server-runtime"; | ||
export { createRequestHandler, createSession, unstable_defineLoader, unstable_defineClientLoader, unstable_defineAction, unstable_defineClientAction, defer, broadcastDevReady, logDevReady, isCookie, isSession, json, MaxPartSizeExceededError, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, } from "@remix-run/server-runtime"; | ||
export type { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, JsonFunction, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, HandleErrorFunction, PageLinkDescriptor, RequestHandler, SerializeFrom, ServerBuild, ServerEntryModule, ServerRuntimeMetaArgs as MetaArgs, ServerRuntimeMetaDescriptor as MetaDescriptor, ServerRuntimeMetaFunction as MetaFunction, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedDeferredData, TypedResponse, UnsignFunction, UploadHandler, UploadHandlerPart, } from "@remix-run/server-runtime"; |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -88,2 +88,18 @@ * Copyright (c) Remix Software Inc. | ||
}); | ||
Object.defineProperty(exports, 'unstable_defineAction', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.unstable_defineAction; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_defineClientAction', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.unstable_defineClientAction; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_defineClientLoader', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.unstable_defineClientLoader; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_defineLoader', { | ||
enumerable: true, | ||
get: function () { return serverRuntime.unstable_defineLoader; } | ||
}); | ||
Object.defineProperty(exports, 'unstable_parseMultipartFormData', { | ||
@@ -90,0 +106,0 @@ enumerable: true, |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/node v2.9.1 | ||
* @remix-run/node v2.9.2-pre.0 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
{ | ||
"name": "@remix-run/node", | ||
"version": "2.9.1", | ||
"version": "2.9.2-pre.0", | ||
"description": "Node.js platform abstractions for Remix", | ||
@@ -26,3 +26,3 @@ "bugs": { | ||
"undici": "^6.10.1", | ||
"@remix-run/server-runtime": "2.9.1" | ||
"@remix-run/server-runtime": "2.9.2-pre.0" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50205
813
2
+ Added@remix-run/router@1.16.1-pre.0(transitive)
+ Added@remix-run/server-runtime@2.9.2-pre.0(transitive)
- Removed@remix-run/router@1.16.0(transitive)
- Removed@remix-run/server-runtime@2.9.1(transitive)