Home

Issue: 63

can not import default in .vue files

[issue link]

If importing the default object of .js file in a .vue file, the default object will be wrapped.

foo.js

export default {
  bar: 123
};

some.vue

import foo from './foo';
// need to use foo.default to access the default object
console.log(foo.default.bar);

I think the problem is because vue-loader did not config the babel option: modules: false at https://github.com/nuxt/nuxt.js/blob/master/lib/build/webpack/vue-loader.config.js#L7

  let config = {
    postcss: this.options.build.postcss,
    loaders: {
      'js': 'babel-loader?presets[]=es2015&presets[]=stage-2',
      'less': 'vue-style-loader!css-loader!less-loader',
      'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
      'scss': 'vue-style-loader!css-loader!sass-loader',
      'stylus': 'vue-style-loader!css-loader!stylus-loader',
      'styl': 'vue-style-loader!css-loader!stylus-loader'
    }
  }

I wonder why set the babel options here rather than use the .babelrc ?

This bug report is available on Nuxt.js community (#c47)