0

I'm getting this error when trying to export:

    import webpack from 'webpack'; export default var compiler = webpack({entry: "./app/app.js",module: {
    loaders: [
      {
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {stage: 0, presets : ['es2015','react'] ,plugins: ['./build/babelRelayPlugin']},
        test: /\.js$/,
      }
    ]
  },
  output: {   filename : "./js/bundle.js"}
});

Then when I run it I get:

SyntaxError: .../webpack.config.babel.js: Unexpected token (4:15) export default var compiler = webpack({

The error is on the "var".

I'm running this script in package.json:

"start": "babel-node ./server.js",
"dev": "npm run build && npm run watch",
"build": "npm run build:schema && npm run build:browser",
"build:schema": "babel-node ./build/updateSchema.js",
"build:browser": "webpack ./js/app.js ./js/bundle.js",
"watch": "parallelshell 'npm run watch:schema' 'npm run watch:browser' 'npm run watch:server'",
"watch:schema": "onchange ./data/schema.js -- npm run build:schema",
"watch:browser": "onchange ./js/app.js -- npm run build:browser",
"watch:server": "nodemon app.js"

npm run dev

my app.js:

require('babel-core/register');require('./server.js');

So I guess I have something wrong with babel. Can anyone help me?

Diogo Barroso
  • 885
  • 2
  • 9
  • 17
  • So, Diogo, does my answer help? – Cerbrus Nov 26 '15 at 10:02
  • hej, I'm sorry I tried but didn't work. I decided to separate webpack into running on a different shell "webpack -w" – Diogo Barroso Nov 26 '15 at 10:07
  • if you want to export/import a component, consider this babel plugin : transform-es2015-modules-amd , This plugin transforms ES2015 modules to Asynchronous Module Definition (AMD), and presets env, react – Jayavel Feb 08 '18 at 05:17

0 Answers0