Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
Can't make rollup bundle memfs package for browser; Getting "Uncaught ReferenceError: exports is not defined"

I was trying to compile memfs package for the browser. Webpack build is working just fine, but I want to bundle it with rollup and I constanlty getting "Uncaught ReferenceError: exports is not defined".

I've made repl.it example with my config

For someone who do not wanna use repl.it, here are my files:

// rollup.config.js

import resolve from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"
import nodePolyfills from "rollup-plugin-polyfill-node";

export default {
    input: 'index.js',
    output: {
        dir: "dist",
        format: 'esm',
    },
    plugins:[
        nodePolyfills(),
        resolve({
            preferBuiltins: false,
            browser: true,
        }),
        commonjs(),
    ],
}

File I am trying to process:

// index.js
import { fs } from "memfs";

let code = `
  console.log("hello, world!");
`;

fs.writeFileSync("./code", code);

console.log(fs.readFileSync("./code"));

I've tried many commonjs options and nothing worked for me. Maybe I am missing something?

Thanks =)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Okay, I've figured it out. I've had a wrong plugin order.

The right order is:

export default {
    // all previous settings
    plugins: [
        resolve({
            preferBuiltins: false,
            browser: true,
        }),
        commonjs(),
        nodePolyfills(),
    ]
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!