Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not import default in .vue files #63

Closed
jiangfengming opened this issue Dec 13, 2016 · 3 comments
Closed

can not import default in .vue files #63

jiangfengming opened this issue Dec 13, 2016 · 3 comments
Assignees

Comments

@jiangfengming
Copy link

jiangfengming commented Dec 13, 2016

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)
@Atinux
Copy link
Member

Atinux commented Dec 13, 2016

Hi @fenivana

Thanks for spotting it, it will be fixed in the next release 👍

@Atinux Atinux self-assigned this Dec 13, 2016
@Atinux
Copy link
Member

Atinux commented Dec 19, 2016

Fixed in 0.9.0

@Atinux Atinux closed this as completed Dec 19, 2016
@lock
Copy link

lock bot commented Nov 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 5, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants