Skip to content

Commit

Permalink
Merge pull request #2790 from lpsinger/builtin-fetch
Browse files Browse the repository at this point in the history
Use builtin Web Fetch; polyfill not needed in Node.js >= 20
  • Loading branch information
dakota002 authored Dec 16, 2024
2 parents 1caff5f + 5290626 commit d5a2d0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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

0 comments on commit d5a2d0c

Please sign in to comment.