Error when having type: module in package.json
Jinjiang opened this issue · 1 comments
Jinjiang commented
Reproduction: https://github.com/Jinjiang/reproductions/tree/vite-node-polyfill-20240214
pnpm install
pnpm build
error log:
error during build:
RollupError: "existsSync" is not exported by "node_modules/.pnpm/node-stdlib-browser@1.2.0/node_modules/node-stdlib-browser/esm/mock/empty.js", imported by "src/index.ts".
...
if works if you remove "type": "module"
from package.json
Jinjiang commented
Update: changing
import { existsSync, readFileSync } from 'fs'
into
import fs from 'fs'
const { existsSync, readFileSync } = fs
works. Only named exports don't.