T
T
toly192017-07-13 11:25:56
JavaScript
toly19, 2017-07-13 11:25:56

Why is the third-party library code not being transpiled into webpack2+babel?

I'm trying to use the library https://github.com/gnodi/ecma-version
There is an index.js file code:

import * as ecmaVersion from '@gnodi/ecma-version';
console.log(ecmaVersion)

It crashes when trying to assemble
ERROR in bundle.js from UglifyJs
Unexpected token: name (compatibleVersion) [bundle.js:117,6]

In the bundle.js- file, line 117 is just 'let'? That is, the module code was simply copied to the bundle. why didn't he migrate to es5???
here is a piece of webpack.config.js
const common = {
  entry: {
    app: "./src/index"
  },
  output: {
    filename: "bundle.js",
    path: path.join(__dirname, "dist")
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: [/node_modules/],
        use: [{
          loader: 'babel-loader',
          options: {
            presets: ['es2015', 'stage-3', 'react']
          }
        }]
      },

//...

module.exports = function (env) {
  if (env === "production") {
    common.plugins.push(new webpack.optimize.UglifyJsPlugin({
      beautify: false,
      comments: false,
      compress: {
        sequences: true,
        booleans: true,
        loops: true,
        unused: true,
        warnings: false,
        drop_console: true,
        unsafe: true
      }
    }));
//...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question