Answer the question
In order to leave comments, you need to log in
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)
ERROR in bundle.js from UglifyJs
Unexpected token: name (compatibleVersion) [bundle.js:117,6]
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 questionAsk a Question
731 491 924 answers to any question