You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, I have also noticed that tsup struggles with CJS modules that have a default export (exports.default=...).
Namely I've had issues with axios (axios/axios#6591) and @react-hook/resize-observer. When my bundle ends up loading their CJS version, the .default export is not used, causing errors such as index.mjs:315 Uncaught (in promise) TypeError: axios__WEBPACK_IMPORTED_MODULE_0__.create is not a function (should be axios__WEBPACK_IMPORTED_MODULE_0__.default.create).
I am not sure whether this can be controlled with tsup settings, but the only workaround I found was to bundle the problematic packages using this:
Note that axios has other issues, and you also need to patch their exports in package.json to avoid referencing node modules... (axios/axios#5495), but that's another story...
I am importing a module with an esModule export like below.
I import the module in my typscript code.
This gets transpiled to the following when I run
tsup
Now when I use
SomeNpmModule
, it is no longerSomeNpmModule
, but{ default: SomeNpmModule }
.How can I prevent this from happening.
Ideally tsup should generate the following code when using a default import, but it doesn't.
tsup.config.ts
tsconfig.json
Upvote & Fund
The text was updated successfully, but these errors were encountered: