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

94
Views
How to generate single ES5 bundle file from ES6 project using browserify

I am trying to use react-vis library in my project. In their readme file, they have asked to import library by adding following lines in non-node environment:

If you're working in a non-node environment, you can also directly include the bundle and compiled style using basic html tags.

<link rel="stylesheet" href="https://unpkg.com/react-vis/dist/style.css">
<script type="text/javascript" src="https://unpkg.com/react-vis/dist/dist.min.js"></script>

The global reactVis object will now be available for you to play around.

When I did that, I got following error:

Uncaught TypeError: Cannot call a class as a function
    at _classCallCheck (dist.min.js:formatted:23789:27)
    at LabelSeries (dist.min.js:formatted:23823:21)
    at Constructor.render (<anonymous>:1866:23)
    at Constructor.<anonymous> (react.js:6029:34)
    at Constructor._renderValidatedComponent (react.js:11403:21)
    at Constructor.<anonymous> (react.js:5582:14)
    at Constructor.mountComponent (react.js:11403:21)
    at Constructor.mountChildren (react.js:10913:42)
    at Constructor._createContentMarkup (react.js:6812:32)
    at Constructor.<anonymous> (react.js:6734:14)

After a lot of digging, I realised issue was that the react-vis library follows ES6, while my project is in ES5. So, I thought to transpile react-vis library to ES5. After digging a bit in the react-vis repo, I found that it uses browserify.

So to compile ES6 porject to single ES5 bundle file using browserify itself, I added --presets [ @babel/preset-env ] on this line itself as suggested here:

"build:browser": "browserify src/index.js -t [ babelify --presets [ @babel/preset-env ] ] --standalone reactVis | uglifyjs > dist/dist.min.js",

I also tried adding @babel/preset-react:

"build:browser": "browserify src/index.js -t [ babelify --presets [ @babel/preset-env @babel/preset-react] --rootMode upward ] --standalone reactVis | uglifyjs > dist/dist.min.js",

But in both cases I ended up getting same error: Cannot call a class as a function.

What I am missing?

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!