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
bundle with esbuild fails because yargs/yargs
does not have file extension
#2014
Comments
Keeping this file without an extension is a hack necessary to prevent yargs from treating the file as ESM, since for the benefit of TypeScript, the package.json is of This can be fixed as soon as TypeScript supports a |
We can probably devise a solution all the same, such as moving that file into |
Do you have a link to the issues or PRs where this decision was discussed? |
@cspotcode no, this design grew organically while trying to support both CJS and ESM in the same module. The approach is discussed, without much detail, here. Open to other approaches as long as all existing tests continue working, and we verify functionality on all supported Node runtimes. |
you can work around this if you're compiling with babel by having one config for the mjs and one for the cjs and using something like:
Understand you can't really do that with typescript at the moment, but a workaround like that, while still using tsc with --emitDeclarationsOnly would solve the problem. |
This is becoming a fatal error with Node 17.x where the top-level project is Node.js ESM (not TypeScript).
|
In the next major I'll look at dropping the |
For me This worked! |
Hello! |
I believe there are a couple workaround in this thread now, also @hongaar's update was merged and released. |
I'm using puppeteer and I have this error:
It fails on this line:
Any idea on how to fix this? Some relevant files: tsconfig.json
|
You have a different problem @LuisAzeved than this issue is about. Would you please open a new issue, and include how you are including yargs in your code. (The example line you gave is useful but looks like it is from the transpiled code.) Also asked on Stack Overflow with some additional context: https://stackoverflow.com/questions/77635667/cannot-use-puppeteer-because-it-fails-loading-yargs-yargs-dependency |
@LuisAzeved did you manage to fix your issue? |
Possible duplicate of #1929 but I'm not sure because that ticket is too vague.
esbuild determines content types based on file extension. esbuild docs
But yargs/yargs does not have a file extension.
This raises an error:
The text was updated successfully, but these errors were encountered: