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

allow to disable esm shim? #468

Open
himself65 opened this issue Mar 1, 2024 · 4 comments
Open

allow to disable esm shim? #468

himself65 opened this issue Mar 1, 2024 · 4 comments

Comments

@himself65
Copy link
Contributor

bundleConfig.format === 'esm' && esmShim(),

@himself65
Copy link
Contributor Author

There are some reasons, for example, there is a TS file that is

const fetch = globalThis.fetch === 'undefined' ? require('node-fetch') : fetch

I won't have node:module because this package might be published to the browser. I just want to do some environment check here

@huozhi
Copy link
Owner

huozhi commented Mar 3, 2024

If you disable the esm shim then the bundled code will be incorrect? How the require is supposed to be handled.

I feel like you should just do polyfill on server side chunks or exports if that can solve your case.

@himself65
Copy link
Contributor Author

himself65 commented Mar 4, 2024

For example Im writing the polyfill code in a function it will both emit to cjs and esm. And in this case require function shouldn’t cause a side effect

@huozhi
Copy link
Owner

huozhi commented Mar 9, 2024

It would cause other error if you don't shim require call, probably should consider dynamic import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants