CroudTech / vue-quill

Quill component for vue
MIT License
121 stars 22 forks source link

Browserify Throws ParseError On Build #18

Closed brizandrew closed 6 years ago

brizandrew commented 6 years ago

First off, thanks for the great plugin!

I use a browserify build with vueify and babelify and I tried to import and use your library and build my file with browserify:

import Vue from 'vue';
import VueQuill from 'vue-quill';
Vue.use(VueQuill);
cross-env NODE_ENV=development browserify -g envify -p [ vueify/plugins/extract-css -o path/views.css ] -e path/main.js | uglifyjs -c warnings=false -m > path/scripts.min.js

When I do that, I get the following error:

/path/to/app/node_modules/vue-quill/vue-quill.js:1
import render from 'quill-render'
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

From what I know about this error, import/export statements usually need to be transpiled in order to work with browserify properly. Using that knowledge, I found that if I add babelify to your package.json (as shown below), it does work, but this obviously doesn't seem like the solution. Is there a step I'm missing to build it?

...  
"browserify": {
    "transform": [
      "babelify",
      "vueify"
    ]
},
...
BrockReece commented 6 years ago

Hey @brizandrew,

No I think you are correct, I migrated away from browserify to webpack last year and a recent version of vue-loader has changed the way the require statements are handled, so I moved to import statements to make this package more reliable.

But as import requires a babel transform, I should have updated the package.json. I will make the change this morning and bump the package version. Thanks for your help.

BrockReece commented 6 years ago

v1.3.1 should fix this for you.

Thanks again 👍