Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda