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

149
Views
Rollup / Babel / CoreJS - "Require is not defined"

I'm trying to use Rollup.js to build some JS to be compatible with IE11. After a very frustrating couple of hours fiddling with various config options, I hit upon the following:

import resolve from "@rollup/plugin-node-resolve"
import { babel } from '@rollup/plugin-babel';

export default {
  input: "app/javascript/application.js",
  output: {
    file: "app/assets/builds/application.js",
    format: "es",
    inlineDynamicImports: true,
    sourcemap: true
  },
  plugins: [
    babel({
      presets: [
        [
          "@babel/preset-env", {
            "useBuiltIns": "usage",
            "debug": true,
            "corejs": "3"
          }
        ]
      ]
    }),
    resolve(),
  ]
}

Looking at the debug entries, it seems that my polyfills are getting added (yay?). However it seems that they're getting added with requires for some reason, as when I try to run the JS in my browser, I get:

Uncaught ReferenceError: require is not defined

The offending lines of code seem to be:

var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support');

var redefine$2 = require('../internals/redefine');

var toString$3 = require('../internals/object-to-string'); // `Object.prototype.toString` method
// https://tc39.es/ecma262/#sec-object.prototype.tostring

But I don't understand why this should be, surely if Babel is transpliling code for the browser, then require should be nowhere near my code? Please help, I'm tearing what little hair I have remaining out over this!

about 4 years ago · Juan Pablo Isaza
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!