-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[[ Question ]] Mapping in browser field doesn't affect dependencies #1324
Comments
Can you provide a sample project that demonstrates the problem? |
Hello @evanw and thank you for answering this. This is the project I'm trying to migrate to esbuild. In the WIP commit you can see my efforts to move it to esbuild creating the config files in the You can visualize the issue I'm talking about by running either You will see the errors in the command output and how they ask to use |
I'm getting the same issue trying to use: "browser": {
"path": "path-browserify"
} in my
|
I can't get this to work with any of the bundlers (Browserify, Parcel, Rollup, or Webpack). Here's what I tried:
It's possible that I have set this up incorrectly. If so, please let me know how to adjust this test case such that it works. But under the assumption that there is no bundler that supports this, esbuild shouldn't support this either. If you still want to use esbuild, you can substitute |
Hello @evanw, thank you for taking the time to look into this. I can't tell you if your setup is correct to mimic my use case, I'm not that good. The only thing I can tell you is the project I'm trying to port to esbuild is already using Browserify to bundle the same files I'm trying to bundle as you can see in the master branch. And these are the only Browserify configuration options that is using: "browserify": {
"transform": [
[
"sveltify",
{
"extensions": [
".svelte"
],
"svelte": {
"dev": false
}
}
],
[
"scssify"
]
]
} The project is bundling the files directly with scripts like this: "build:addon": "browserify src/main.js -o dist/bundle.js", I really don't understand what is going on. |
I think what's happening is that Browserify has built-in behavior to substitute One thing you could try to debug further is specifying another mapping other than the one built into Browserify. For example, instead of
I appreciate you providing a repository that reproduces the issue. However, it has a lot of dependencies and I wasn't able to install some of them. So I made a minimal test case to try to get to the root of the issue. |
I'm back @evanw. Sorry for the delay but it has been a very difficult last month for me. I created a small repo to illustrate what is going on with Browserify and esbuild when there are deep dependencies using Node's APIs. I hope it helps to figure out what Browserify is doing. IMO this is essential for esbuild if we want the tool to bundle applications for browser-only usage (UMD files). Repo: patchfox-esbuild |
Bump |
This was very helpful and insightful, thank you for the very descriptive demo. I went ahead and extended on your suggestion of using resolve callbacks. Could you take a look at this minimal repo to see if that's in line with what you had in mind? @davegomez Thank you |
I will also say that while bundling the dependencies with ESBuild that way worked just fine, along with replacing certain dependencies of my dependencies, the dependency that required all that manipulation wasn't very functional with |
I'm going to close this as I believe esbuild is working as intended here. The |
I'm trying to replace Browserify in a project I'm working on.
The project bundles many dependencies originally written for Node.js, so they are full of usages of Node's APIs.
Setting the field browser in my project's package.json file maps the modules correctly, but it doesn't work for the dependencies that I also need to bundle.
Is there a way to do this with esbuild, or am I stuck with Browserify?
The text was updated successfully, but these errors were encountered: