-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Closed as not planned
Labels
Description
Describe the bug
I'm working on a PR for papaparse to support ESM.
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
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.0Used 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.