-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
consider supporting the "browser" field of package.json #5455
Comments
I don't think there is anything yarn can do with this. Could you resolve some of the "ignore a module" seems to be the only use-case of the |
That is what I'm doing currently and it seems to be working for now, but that solution is very brittle because AFAICT, I'd love to be able to flatten everything, but that just isn't how the server side javascript world operates and unfortunately, dev dependencies like webpack heavily resist being flattened. Currently, webpack pulls in 21 libs that must be manually overridden and any one of those overrides could break functionality. Frankly, it's ok if my dev tools require multiple lib copies. It's really only the dependencies that I'm delivering to my users (aka prod dependencies) that should be flattened. I'm happy to let my dev dependencies use as many versions of libs as they want/need. I suspect many javascript developers are in the same boat, but yarn doesn't directly support this use case. Even if you can resolve safely, AFAICT, putting something into IMO the default behavior of |
Ah, I just found the related discussion in #3254 The "resolutions" field still always gets applied. I'd also need something like
would allow the |
That feature has been requested in a more general way already #4611 |
yarn aside, I struggled with this a bit when Bower started leaning toward "we aren't going to support this any more" and I had to start moving toward npm or yarn instead. I wasn't sure how to have non-flattened dev deps and flattened web deps (and I never solved that). If you are using webpack, then I think having multiple versions of a web dependency will actually work. It should be resolving packages like node.js would, so an Keep in mind that npm wasn't designed for web packages. IMO they shouldn't even be in the npm registry. Bower was good for managing those. It's unfortunate that they are deprecating it. Since you found 2 other issues that are semi-related to this, do you want to keep this issue open or do you mind if we close it? |
This is fine to close. I just wanted to make you guys aware of this use case. Namely: isomorphic packages pulling in large conditional dependencies that are not necessary when the library is being used as a web package. It's just frustrating that the humans know about this large dependency subtree that can/should be excluded from the package resolution process, but we have no way to convey this to the tooling. Having some way to mark these packages for exclusion (whether its via the browser field, or the resolution field, or something else) would ease some of the pain of using npm for this thing it wasn't initially designed for. Fortunately, it looks like flattening is being discussed/addressed in a more comprehensive way over at package-community/discussions#2 |
Improving the situation for frontend applications in general would be great. A lot of the discussion in package-community/discussions#2 generalizes to all frontend applications, even if they are not using polymer. |
I'm sure you were correct at the time of writing but just mentioning as I stumbled on this thread that |
UP! I want to import in a web project a module built with tsdx, that has a browser and a Node version. Yarn ignores the |
Do you want to request a feature or report a bug?
feature
What is the current behavior?
yarn totally ignores the browser field in package.json
spec: https://github.com/defunctzombie/package-browser-field-spec
current support: https://github.com/stereobooster/package.json#browser
If the current behavior is a bug, please provide the steps to reproduce.
N/A
What is the expected behavior?
Ideally, I could let yarn know that I am building a project specifically for the browser (with a new
--browser
flag or something like that). When this flag is used, yarn would make use of this field when resolving dependencies. Specifically, I'm interested in the ignore a module hint. The motivation for this request is coming from firebase/firebase-js-sdk#546 (comment).Obviously, since yarn works on a package level, it could not possibly do anything about the file level hints in this field, but module ignores (and possibly the module replacements) seem very doable.
Please mention your node.js, yarn and operating system version.
node: v8.9.4
yarn: 1.5.1
os: linux 4.15.7
The text was updated successfully, but these errors were encountered: