cerebral-legacy / cerebral-view-inferno

The Inferno view package for Cerebral
4 stars 0 forks source link

ERROR in main.js from UglifyJs #2

Open saitodisse opened 8 years ago

saitodisse commented 8 years ago

I'm getting this error when I try to use UglifyJs:

ERROR in main.js from UglifyJs
SyntaxError: Unexpected token: name (CerebralComponent) [./~/cerebral-view-inferno/src/hoc.js:25,0]

Already tryied to disable mangle but I got same error:

    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        mangle: false,
      }
    })

maybe this helps: http://www.jbrantly.com/es6-modules-with-typescript-and-webpack/

saitodisse commented 8 years ago

My webpack configuration is creating a main.js with this line bellow:

class CerebralComponent extends InfernoComponent {

That's why uglify craches. 😒

This is my webpack config:

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
require('dotenv').config({path: '.env-prod'});

module.exports = {
  entry: path.resolve('src', 'main.js'),
  output: {
    path: path.resolve('dist'),
    filename: 'main.js',
    publicPath: ''
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'md list',
      template: path.resolve('src', 'index.template.ejs'),
      inject: 'body'
    }),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
        'API_KEY': JSON.stringify(process.env.API_KEY),
        'AUTH_DOMAIN': JSON.stringify(process.env.AUTH_DOMAIN),
        'DATABASE_URL': JSON.stringify(process.env.DATABASE_URL),
        'STORAGE_BUCKET': JSON.stringify(process.env.STORAGE_BUCKET),
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
        mangle: false,
      }
    })
  ],
  module: {
    loaders: [
    { test: /\.js?$/,
      include: path.resolve('src'),
      loader: 'babel',
      query: {
        presets: ['es2015', 'stage-0'],
        plugins: [
          'inferno',
          ['module-alias', [
            { 'src': 'src', 'expose': '~' },
          ]],
        ]

      }
    },
    ]
  }
};
Guria commented 8 years ago

cc @christanalfoni we can't use class in es5 code. @saitodisse as a workaround include cerebral-view-inferno to babel-loader

saitodisse commented 8 years ago

Thanks @Guria. For now I'm going to switch to React. Webpack loaders is a long road to learn.