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

package.json "browser" field used on the server side #12253

Closed
7 tasks done
btakita opened this issue Mar 1, 2023 · 2 comments
Closed
7 tasks done

package.json "browser" field used on the server side #12253

btakita opened this issue Mar 1, 2023 · 2 comments

Comments

@btakita
Copy link

btakita commented Mar 1, 2023

Describe the bug

I'm working on a PR for papaparse to support ESM.

mholt/PapaParse#978

Part of the solution is to add package.json into the esm directory:

{
	"main": "./index.mjs",
	"browser": "./index.browser.mjs"
}

When I run this using vite, by way of astro.js, the following error occurs:

/@fs/home/brian/work/portfoliome/censible-core/vendor/PapaParse/papaparse.js:920
                var Duplex = require('stream').Duplex;
                             ^

ReferenceError: require is not defined
    at new DuplexStreamStreamer (/@fs/home/brian/work/portfoliome/censible-core/vendor/PapaParse/papaparse.js:920:16)

The problem is the "browser" export is used instead of the "main" export on the server side.

Reproduction

mholt/PapaParse#978

Steps to reproduce

Use commit 12d09d54f6e79f05eabb5fb61f0de582ff63f511 as a dependency to a vite server side project or an astro.js project.

System Info

System:
    OS: Linux 6.1 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 36.83 GB / 62.71 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.config/nvm/versions/node/v18.14.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.3.1 - ~/.config/nvm/versions/node/v18.14.0/bin/npm
  Browsers:
    Brave Browser: 110.1.48.164
    Chromium: 110.0.5481.100
    Firefox: 110.0

Used Package Manager

npm

Logs

/@fs/home/brian/work/portfoliome/censible-core/vendor/PapaParse/papaparse.js:920
                var Duplex = require('stream').Duplex;
                             ^

ReferenceError: require is not defined
    at new DuplexStreamStreamer (/@fs/home/brian/work/portfoliome/censible-core/vendor/PapaParse/papaparse.js:920:16)

Validations

btakita added a commit to btakita/PapaParse that referenced this issue Mar 1, 2023
@bluwy
Copy link
Member

bluwy commented Mar 2, 2023

Can you provide a repro via https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-vanilla? npm create vite-extra@latest --template ssr-vanilla. The reproduction links to a PR which we have to replicate manually.

@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Hello @btakita. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants