greyby/vue-spinner

ParseError: Unexpected token when trying to import

nivv opened this issue · 5 comments

nivv commented

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

Can you provide the code?

nivv commented

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.

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

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.

Thank you @cyberdummy . I had update the README.