Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

99
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda