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

Node built-ins cause error in pure ESM tooling due to incorrectly transpiled require calls. #68

Closed
scalvert opened this issue Apr 18, 2022 · 1 comment · Fixed by #69
Labels
bug Something isn't working

Comments

@scalvert
Copy link
Collaborator

scalvert commented Apr 18, 2022

I noticed this issue when updating to v5.x in a library that uses vitest, which itself uses esbuild. There's a known issue with esbuild where built-in Node APIs are transpiled to require calls vs. import statements for ESM targets. This causes an issue when consuming those transpiled libraries.

Error:
Screen Shot 2022-04-18 at 8 46 25 AM

The line in question:
Screen Shot 2022-04-18 at 8 47 27 AM

The conversion of this library to tsup, which itself uses esbuild + rollup to output the esm target output, also has manifested this issue. This library doesn't exhibit the issue itself even though it also uses vitest, but downstream consumers do, as they're using the published output, which contains the issue.

Folks at Netlify also experienced this, and they've created a PR to address it. Once that's merged we'll look to ensure the associated packages are subsequently updated once they find their way to the associated libraries.

@scalvert scalvert added the bug Something isn't working label Apr 18, 2022
@stefanpenner
Copy link
Owner

Thanks for keeping me in the loop and being proactive.

@scalvert scalvert changed the title Node built-ins cause error in pure ESM tooling due to unmigrated require calls. Node built-ins cause error in pure ESM tooling due to incorrectly transpiled require calls. Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants