-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
esbuild selecting incorrect files when bundling #2420
Comments
You can use |
How can I pipe the output of verbose to a file? It seems to attach itself to the terminal regardless of any pipe or std redirect. I don't see the root cause under log level debug, but verbose pushes so fast I can't possibly see anything, and my history just dies immediately. I can't |
Log output goes to stderr. |
Was just about to come mention that. |
So it looks like it has to do with the main field in the package.json telling it to use the node versions instead of the browser versions. It found the Am I meant to change the order of things somewhere? |
{
"main": "dist/d3.node.js",
"module": "index.js",
...
} Nothing appears to provide any browser-specific files. This is a problem with the package, not with esbuild. Package authors should not be using
{
"main": "./node-cjs.js",
"module": "./node-esm.js",
"browser": {
"./node-cjs.js": "./browser-cjs.js",
"./node-esm.js": "./browser-esm.js"
}
} If you want to, you can attempt to work around this problematic package by configuring e.g. In any case, I'm closing this issue because it looks like esbuild is working as intended. |
Thanks very much for your help, and for the incredibly fast build product - it's insane. Edit for those who come after: This solution is not a good path forward. The bundle compiles, and passes type checking just fine, but produces errors that are not known until runtime. Even in the best of circumstances, having errors be hidden until later in the pipeline is unacceptable as a compromise. I have a couple of options for moving forward:
|
For those that come after me, know that the regex engine used by esbuild is not the JS regex parser, but the GoLang regex parser. This means that it does not support negative lookahead structures. So if like me you want to rewrite |
I'm not sure I'll be able to fully articulate the issue here, and I can't produce a minimal failure case.
I have a 1st party dependency which then itself depends on d3 to produce bar charts. I can verify that the dependencies are present in the node_modules directory all fine. But when I build the application with a platform of browser, esbuild complains that the library xmlhttprequest cannot find fs, http, https, or child-process. The source of the file requiring xmlhttprequest is coming from d3-request.node.js.
The issue is that file is supposed to only be for node projects and should not be imported into browser projects. Browser projects should import d3-request.js instead.
My first party library is importing from just d3 and grabbing what it needs from the forwarded exports found there, which also never refer to the .node variants.
My question then is how can I stop esbuild from importing the node variants of these libraries?
The text was updated successfully, but these errors were encountered: