-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: handle named imports of builtin modules #8338
Conversation
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.
Awesome! The code looks good to me.
Nice! It should fix build time errors observed when running with Yarn PnP too. I'll update #6493 once this one is merged. |
Looks like some of the latest changes in main are affecting the PR now |
Tests should be good now. Thanks for making the updates while I was away! |
Description
Fix #3736
Fix #8203
Ref #3715 (comment) (fix no1)
Handle
import { join } from 'path'
in deps and source code. (named imports)In deps, wrap proxy with
Object.create
to workaround esbuild ES interop code.In source code, transform the import to
import pkg from 'path'; const { join } = pkg;
(es interop)Additional context
const { join } = require('path')
, it would error immediately asjoin
triggers the Proxy get trap on destructure. (ES import don't have this issue due to compiled esbuild code)Thanks @swandir for initial inspiration for the Proxy trick. Though it has evolved a lot since then.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).