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

About __toESM How can I fix it other than downgrade #596

Open
zongzi531 opened this issue Mar 30, 2022 · 4 comments
Open

About __toESM How can I fix it other than downgrade #596

zongzi531 opened this issue Mar 30, 2022 · 4 comments

Comments

@zongzi531
Copy link

zongzi531 commented Mar 30, 2022

When I installed tsup@^5.6.0 and compiler format set cjs. my compiled file content is like:

var example = __toModule(require('example'))

example.abc()

but now, I used tsup@^5.11.12 and same compiler format. my compiled file content is like:

var example = __toESM(require('example'))

example.default.abc()

now, run this file will thorw error like: TypeError: Cannot read property 'abc' of undefined.

I saw evanw/esbuild#1897 this link and I fined esbuild version difference.

so, I downgrade to tsup@^5.6.0 fix this probrom. and what other solution can fix this?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@egoist
Copy link
Owner

egoist commented Apr 2, 2022

Which library is the example here? (a minimal repo would be helpful)

@zongzi531
Copy link
Author

Sorry, it is example repo https://github.com/zongzi531/tsup_issues_596

and, this code is:

var example = __toModule(require('example'))

example.abc() // example.default.abc() 

but run test.js will throw error TypeError: Cannot read property 'isImportDeclaration' of undefined

@epicmau5time
Copy link

Did you ever find a workaround?

@zongzi531
Copy link
Author

Did you ever find a workaround?

nope.

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

No branches or pull requests

3 participants