Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: esm imports with node: prefix on esbuild (#802)
* chore: add reproduction for esbuild and node-prefixed imports * fix: mark node:-prefixed modules as external for esbuild * chore: move builtin-logic into its own plugin * chore: run nodebuiltin plugin first Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
- Loading branch information
1 parent
9c6d107
commit 199f6ed
Showing
4 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Plugin } from '@netlify/esbuild' | ||
|
||
const getNodeBuiltinPlugin = (): Plugin => ({ | ||
name: 'builtin-modules', | ||
setup(build) { | ||
build.onResolve({ filter: /^node:/ }, () => ({ external: true })) | ||
}, | ||
}) | ||
|
||
export { getNodeBuiltinPlugin } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import console from 'node:console' | ||
|
||
export const handler = () => { | ||
console.log('hello world') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
199f6ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏱ Benchmark results
largeDepsEsbuild: 7.4s
largeDepsNft: 47.3s
largeDepsZisi: 1m 1.6s