greyby / vue-spinner

vue spinners
MIT License
1.8k stars 176 forks source link

ParseError: Unexpected token when trying to import #2

Closed nivv closed 8 years ago

nivv commented 8 years ago

I'm getting the below error when trying to import any of the loaders. I've tried to create my own components with the same contents and that works fine.

import PulseLoader from 'vue-spinner/src/PulseLoader.vue'
[12:38:54] gulp-notify: [Laravel Elixir] Browserify Failed!: Unexpected token

/Users/user/projects/vue-project/node_modules/vue-spinner/src/PulseLoader.vue:1
<template>
^
ParseError: Unexpected token
greyby commented 8 years ago

Can you provide the code?

nivv commented 8 years ago

Main.js (using browserify/vueify)

var Vue = require('vue');
Vue.use(require('vue-resource'));

import PulseLoader from 'vue-spinner/src/PulseLoader.vue';

new Vue({
    el: '#app',

    components: {
        PulseLoader
    }
});

If I copy the contents from PulseLoader.vue to my own component dir it loads fine. I'm guessing there's some problem with my build tool chain.

greyby commented 8 years ago

Please turn on vue debugging mode to see the error log. Vue.config.debug = true

cyberdummy commented 8 years ago

Its because browserify will not pass included files from the node_modules folder to its transformers (vueify).

import { PulseLoader } from 'vue-spinner/dist/vue-spinner.min';

As an import line should work.

var PulseLoader= require('vue-spinner/dist/vue-spinner.min').PulseLoader;

If you want to use CommonJS.

greyby commented 8 years ago

Thank you @cyberdummy . I had update the README.