-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Runtime errors if compiled with "esModuleInterop": false
#88
Comments
Double-checked, these two are not equivalent since we're overriding module.exports = is;
- module.exports.default = is;
+ exports.default = is; oops Edit: wrong
The output is the same (its CJS export is - exports.default = is;
module.exports = is;
+ exports.default = is;
- module.exports.default = is; The export should probably be updated to use |
The point of If you disable that option, you can’t expect to use CJS modules with |
That is true :) The issue here is that |
Thanks for the fix folks! |
It causes problems when used in reusable packages... See: - sindresorhus/is#88 (comment) - sindresorhus/p-queue#73 - microsoft/TypeScript#27293
Thanks for the lovely library! With version
0.17.0
, we noticed that our tests suddenly weren't passing:googleapis/nodejs-pubsub#591
Using TypeScript, everything compiles fine - then we'd get this at runtime:
I have a minimal repo here:
https://github.com/JustinBeckwith/is-broke
Just clone,
npm install
, andnpm start
to see the error. One thing to note - we do not haveesModuleInterop
enabled in our tsconfig. If I set that totrue
- everything does seem to work.We found that setting
esModuleInterop
in our modules could have downstream effects for other users (like this case), so we keep it off. I noticed that your base leveltsconfig
enables both synthetic default imports and es module interop:https://github.com/sindresorhus/tsconfig/blob/master/tsconfig.json#L9
TL;DR: I think the answer here is to disable
esModuleInterop
as a default configuration for your TypeScript modules. Could be wrong 🤷♂The text was updated successfully, but these errors were encountered: