-
Notifications
You must be signed in to change notification settings - Fork 39
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 CJS to expose the default export with require(...)
instead of require(...).default
#239
Comments
I checked with unsetting |
I'm wondering why this is still an issue a year later! Forcing CJS imports to use the |
@uncenter it's a much harder problem than you might expect. TypeScript does not provide a way (to my knowledge) to transform an esm default export to a |
Sorry I didn't mean to come off rudely. I was just surprised that there wasn't any activity on the issue :) I don't know an exact solution but this isn't a problem in every bundler so I'm guessing there must be a workaround. |
Hi, I've been trying to migrate the TinyColor library to use Deno and cross compile to Node (CJS and ESM). It's all working fine (bgrins/TinyColor#241), except for one problem:
The generated CJS exports the object on
default
when requiring (https://github.com/bgrins/TinyColor/blob/bcfcd1d49181a45fab2dd1858ef22890adba1809/npm/script/mod.js#L50) such that to access it I need to dovar tinycolor = require("tinycolor2").default
whereas the current behavior and external API works likevar tinycolor = require("tinycolor2");
. I don't want to change the existing API as the library is used by a lot of people - is there a way to change the output from dnt to match the current behavior?My best guess was that it's the
esModuleInterop
option at https://github.com/denoland/dnt/blob/main/mod.ts#L348 which is causing this behavior, but the generated test output also expects to pull the object out of.default
so maybe there would need to be more changes as well.The text was updated successfully, but these errors were encountered: