Skip to content
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

vite3 does not respect browser field in dependeicies' package.json using yarn pnp in dev mode #9092

Closed
7 tasks done
smeng9 opened this issue Jul 13, 2022 · 1 comment
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@smeng9
Copy link
Contributor

smeng9 commented Jul 13, 2022

Describe the bug

I tried to introduce a dependency that has a browser field resolve to false in package.json

I am using yarn PnP mode and the package name is object-inspect.

However, during import in development the page throws error in browser console

Uncaught Error: Module "./util.inspect" has been externalized for browser compatibility. Cannot access "./util.inspect.custom" in client code.
get util.inspect:9
js index.js:69
__require chunk-RSJERJUL.js:3
object-inspect:1

Reproduction

Clone the following

https://github.com/smeng9/vite-browser-field

Or

  1. Create a black project in yarn pnp mode using react template from vite3
  2. Add object-inspect as dependency using $ yarn add object-inspect
  3. Add import inspect from "object-inspect" in src/App.jsx
  4. run yarn dev and the browser console will produce error

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
    Memory: 2.18 GB / 7.22 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.0.0 - /usr/bin/node
    Yarn: 3.2.1 - /usr/bin/yarn
    npm: 8.6.0 - /usr/bin/npm
  Browsers:
    Firefox: 102.0.1

Used Package Manager

yarn

Logs

Only the running $ yarn dev has the problem, running $ yarn build && yarn preview does not have any problem

Throws error? $ yarn dev $ yarn build
Yarn linker PnP Yes No
Yarn linker node-modules No No

Validations

@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Jul 14, 2022
@sapphi-red
Copy link
Member

sapphi-red commented Jul 14, 2022

Duplicate of #7576. (The reason is same: #7599)

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants