wffranco / vue-strap

Bootstrap components built with Vue.js
http://wffranco.github.io/vue-strap/
MIT License
338 stars 133 forks source link

SyntaxError: Unexpected token: operator (>) [./~/vue-strap/src/utils/utils.js:4,0] #74

Open larryu opened 7 years ago

larryu commented 7 years ago

When runing command npm run production, I got the following error.

/js/app.js from UglifyJs SyntaxError: Unexpected token: operator (>) [./~/vue-strap/src/utils/utils.js:4,0]

But when I ran npm run dev, it was fine. Any idea and suggestion? Thanks.

sleman commented 7 years ago

Getting the same.

sleman commented 7 years ago

Only fix is to transpile only this one file which makes me think this was done by mistake:

./node_modules/.bin/babel node_modules/vue-strap/src/utils/utils.js --presets es2015 > node_modules/vue-strap/src/utils/utils.js

larryu commented 7 years ago

@sleman Awesome, works perfectly. Thanks mate.

sleman commented 7 years ago

Please keep this open, needs to get fixed in the repo.

wffranco commented 7 years ago

not sure what you do here :rofl:

@sleman please if you can make a pull request, then I can check it and understand whats going on :v

lbausch commented 7 years ago

Any progress on this? Having the same issue.

josiahdahl commented 7 years ago

@larryu I ran into a very similar issue when trying to test with Karma. Here's the overview:

// src/components/MyComponent.vue
// What I did
import Modal from 'vue-strap/src/Modal';

export default {
  ...
  components: { Modal },
  ...
}

// The right way
import { modal } from 'vue-strap';
export default {
  ...
  components: { modal },
// You might have to do components: { Modal: modal }
  ...
}

The problem is that by importing from the source folder (as suggested by the docs), you include the file `~/vue-strap/src/utils/utils.js' which doesn't get compiled by the third-party plugin.

Something that may lead to the problem is that the keys used to import the components are named in camel case, instead of the usual Pascal case. This is fine, but I don't think it is explicit in the documentation.

@wffranco would you be open to updating the documentation? I've been using this fork for a while and I like it a lot. I can submit a PR in the next week or so.

For quick reference, here are the components available. selection_008

larryu commented 7 years ago

@josiahdahl Thanks for the explanation.

vesper8 commented 7 years ago

@josiahdahl oh god this issue has been causing me so much grief for the last 3 hours!!! and this was it!! arrgh.. thanks a lot for sharing your solution!!

larryu commented 7 years ago

For those who have the same issue. The following is the another solution if you use Laravel-mix. https://github.com/JeffreyWay/laravel-mix/issues/631