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

155
Visualizações
babel + core-js + webpack make code support old chrome, many node_modules file raise "export ... was not found" error

I reproduce err in this project

following is my babel.config.js

module.exports = {
    presets: [
        ["@babel/preset-env", {
            "useBuiltIns": "usage",
            "corejs": 3, // or 2,
            "targets": {
                "chrome": "54" // babel is for debug, it make code compatible android webview, so compatible my genymotion android webview is enough
            },
            "exclude": ["@babel/plugin-transform-regenerator", "@babel/plugin-transform-arrow-functions"]
        }],
    ]
}

when npx webpack serve, it raise many similar errs like export 'default' (imported as 'stripAnsi') was not found in './modules/strip-ansi/index.js' (module has no exports)

when babel.config.js set chrome:54, it raise err; when set chrome:74, not err, but I expect all code support chrome 54 and I must use core-js to apply polyfill, so how to fix this bug?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Some deps use module.exports will conflict with babel + corejs, so make babel ignore these deps, and even no babel, most popular deps native support old browser(like react, react-dom use module.exports, they natively support very old browser)

in my case, only little deps cause this err, so i use babel.config.js "exclude" like following:

module.exports = {
    presets: [
        ["@babel/preset-env", {
            "useBuiltIns": "usage",
            "corejs": "3.19.0", // or 2,
            "targets": {
                "android": "54" // babel is for debug, it make code compatible android webview, so compatible my genymotion android webview is enough
            },
            "exclude": ["@babel/plugin-transform-regenerator", "@babel/plugin-transform-arrow-functions"]
        }],
        "@babel/preset-react",
    ],
    exclude: [/node_modules\/react/, /node_modules\/urijs/, /node_modules\/axios/]
}

also, if maybe deps cause this err, use babel.config.js "include" fix it

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