bundle with esbuild fails because `yargs/yargs` does not have file extension
See original GitHub issuePossible 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:
$ echo 'import createYargs from "yargs/yargs";' | yarn esbuild --bundle --loader=js
> <stdin>:1:24: error: Do not know how to load path: node_modules/yargs/yargs
1 │ import createYargs from "yargs/yargs";
╵ ~~~~~~~~~~~~~
1 error
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Content Types - ESBuild
Modern bundlers contain an optimization called "scope hoisting" that merges all bundled files into a single file and renames variables to avoid name...
Read more >esbuild | Yarn - Package Manager
Certain packages contain files without an extension. For example, the yargs package contains the file yargs/yargs which has no extension.
Read more >esbuild not bundling files - javascript - Stack Overflow
I am trying to use esbuild to bundle and minify my files in an npm project. It is minimizing every file that I...
Read more >esbuild: Versions | Openbase
So for example an extensionless file in a "type": "module" package is now treated as ... constructor call so the resulting code doesn't...
Read more >Credits - Octopus Deploy
Package Authors and/or maintainers License
@amplitude/types Amplitude Inc MIT
@amplitude/ua‑parser‑js Faisal Salman MIT
@amplitude/utils Amplitude Inc MIT
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is becoming a fatal error with Node 17.x where the top-level project is Node.js ESM (not TypeScript).
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
type
,module
.This can be fixed as soon as TypeScript supports a
.mjs
extension.