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
Browser field regression #66
Comments
I think a better way to frame this issue is that we'd like to use the For example, we might |
I think I'm affected by this same issue, as downgrading from 3.4.0 to 3.0.0 made my I'm struggling to understand just what you mean about Would love to hear from maintainers about what we can do to resolve this. |
What I mean by it not being a real file is that in my case there is no file in the module in question named
Node module resolution does not know anything about the |
The discussion stopped at Sep, 29. Can be closed now? |
It's still a problem for us. |
I might have a similar or same problem? When only |
re: @mecurc if you're interested in moving this along, it turns out I have a PR that attempts to fix this problem: rollup/rollup-plugin-node-resolve#179. I forgot I had that! I'd love to get a review on it, if anyone in this thread is interested. |
It looks like I have a similar case for the dependency that has a browser override. Example, that does not work https://github.com/melgenek/uuid-typescript-rollup |
I got the same issue with isomorphic-ws, this package makes sence only if browser field is used in resolving. |
Almost a year later, I look back and realize I understand your use case @skeggse 😄 It would be really helpful for library authors for this to get fixed. I would like to encourage the maintainers to please take a look at rollup/rollup-plugin-node-resolve#179. |
@melgenek I think that issue is not related. It appears to be due to the typescript plugin resolving ids it shouldn't. With rollup-plugin-typescript2, I don't see such issues. |
@StreetStrider can you provide a repro if your isomorphic-ws issue? It seems to work fine for me. |
@bterlson will do. |
@bterlson I've tracked the case. It occurs when I use all three mainFields: The doc says:
However, not only presense, but order is significant too. |
If you specify mainFields: [ 'module', 'main'] then browser field is automatically prepended. |
@TrySound ok, but docs say that this mechanisms are alternative to each other:
It seemes that docs are not in sync with actual code. |
@StreetStrider would you like to submit a PR for updating the docs? |
@shellscape, will do. |
* node-resolve: improve doc related to mainFields Fixes rollup#66 More clear doc related to mainFields priority and distinct options for browser, module, jsnext and main. Rework markup to distinguish values of mainFields and corresponding values in package.json. * Update packages/node-resolve/README.md Simplify valid values Co-Authored-By: Andrew Powell <shellscape@users.noreply.github.com> * node-resolve: remove type info on deprec options Remove Type/Default info on deprecated properties: jsnext, module and main. * Update packages/node-resolve/README.md Co-Authored-By: Andrew Powell <shellscape@users.noreply.github.com> * Update packages/node-resolve/README.md Co-Authored-By: Andrew Powell <shellscape@users.noreply.github.com> Co-authored-by: Andrew Powell <shellscape@users.noreply.github.com>
rollup/rollup-plugin-node-resolve#127 introduced changes that broke our particular use of
pkg.browser
. We have packages that have a single import when used from node, but separate imports when used in browser modules.For instance, let's say we have a
utils
module:Which we use in two ways:
Because
string/index.js
isn't a real file,resolve
fails to find it, andresolveId
gives a falsyresolved
. In3.0.0
, this was different, as it took theid
utils/string
and tried to resolve it with a few different paths, includingutils/string/index.js
. It looked that key up in thebrowser
object, and gotdist/browser/string/index.js
, which exited, so all was well.I realize this may not be a use-case you want to support (I'm curious to know what tweaks you'd make to the structure of the
utils
package to achieve the import goals), but it was supported in3.0.0
. To me, this makes rollup/rollup-plugin-node-resolve#127 a major rev, and3.0.1
a backwards-incompatible change.Not trying to call anybody out on this - it's a super weird use-case; just pointing out that the use-case exists, and wondering if it's something we want to support vs a use-case that shouldn't be supported in the first place.
The text was updated successfully, but these errors were encountered: