fgnass/spin.js

Unexpected token {

Closed this issue · 10 comments

inport {Spinner} from '/spin.js-3.1.0/spin.js'

I'm getting this when uglifing a bundle:

[07:05:20] 'minify-js' errored after 958 ms
[07:05:20] GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: punc ({)
File: C:\Work\Quoxient\Source\QSoar\QSoar\js\qt_bundle_charting.js
Line: 42780

...which corresponds to line 113/114 in the dist of version 3.10.0.

Concur--and the use of import rather than require breaks using this in Electron. Not in a position to use either webpack or Rollup--this build is already complicated enough.

Same issue with Meteor JS. Meteor's build tool doesn't transpile code in node_modules directory so the browser throws this error as it doesn't understand the ES6 module syntax.

Perhaps you can stick with spin.js 2.x until your build tools support ES6. They'll have to support it eventually since more and more libraries are starting to use it!

@theodorejb Thanks for the suggestion - that's exactly what I'm doing for the moment :) I've just discovered that transpiling of node_modules is on the roadmap for the next Meteor release (v1.6.2) so that should solve it properly (for Meteor users at least).

Getting the same error and had to downgrade to v2.
In webpack you typically exclude node_module from babel-loader, as it's a common convention to publish transpiled modules to npm, so this module won't work with create-react-app for example.

How do you downgrade to v2?

@MMP3AC3 you can run yarn upgrade spin.js@^2.0.0 or npm install spin.js@^2.0.0

@moretti I downgraded to v2, but it's still not working...not sure if I'm doing this right

Is it the typo inport should be import?