Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use builtin Web Fetch; polyfill not needed in Node.js >= 20 #2790

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ const esmOnlyModules = [
/^vfile/,
]

// These packages should never be bundled.
const neverBundledModules = [
// Included in AWS Lambda base image
/@?aws-sdk(?:\/|$)/,
// Used to polyfill Web Fetch; not needed for Node.js >= 20
'undici',
'@remix-run/web-fetch',
]

/** @type {import('@remix-run/dev').AppConfig} */
export default {
mdx: {
Expand Down Expand Up @@ -80,7 +89,15 @@ export default {
serverModuleFormat: 'cjs',
serverDependenciesToBundle: [
...esmOnlyModules,
...(isProduction ? [/^(?!@?aws-sdk(\/|$))/] : []),
...(isProduction
? [
new RegExp(
`^(?!${neverBundledModules
.map((item) => (item instanceof RegExp ? item.source : item))
.join('|')})`
),
]
: []),
],
future: { v3_relativeSplatPath: true },
}
2 changes: 0 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { type RequestHandler, createRequestHandler } from '@remix-run/architect'
import * as build from '@remix-run/dev/server-build'
import { installGlobals } from '@remix-run/node'
import { type APIGatewayProxyStructuredResultV2 } from 'aws-lambda'
import sourceMapSupport from 'source-map-support'

sourceMapSupport.install()
installGlobals({ nativeFetch: true })

const remixHandler = createRequestHandler({
build,
Expand Down
Loading