Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with JSZip, webpack and acorn #327

Closed
lisamburns opened this issue Aug 5, 2016 · 8 comments · Fixed by #328
Closed

issue with JSZip, webpack and acorn #327

lisamburns opened this issue Aug 5, 2016 · 8 comments · Fixed by #328

Comments

@lisamburns
Copy link

lisamburns commented Aug 5, 2016

There is an error when using acornJS with JSZip.

Error in plugin 'webpack-stream'
Message:
    ./~/jszip/package.json
Module parse failed: <PATH>/node_modules/jszip/package.json Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:9)
    at Parser.pp$4.raise (<PATH>/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (<PATH>/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp.semicolon (<PATH>/node_modules/acorn/dist/acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (<PATH>/node_modules/acorn/dist/acorn.js:966:10)
    at Parser.pp$1.parseStatement (<PATH>/node_modules/acorn/dist/acorn.js:730:24)
    at Parser.pp$1.parseBlock (<PATH>/node_modules/acorn/dist/acorn.js:981:25)
    at Parser.pp$1.parseStatement (<PATH>/node_modules/acorn/dist/acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (<PATH>/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (<PATH>/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (<PATH>/node_modules/acorn/dist/acorn.js:3098:39)

Commenting out this line from jszip/lib/index.js prevents the gulp error.
JSZip.version = require('../package.json').version;

@elrumordelaluz
Copy link

Same here.

ERROR in ./~/jszip/package.json
Module parse failed: /Users/.../node_modules/jszip/package.json Unexpected token (2:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:8)

Solved with json-loader

in webpack.config.js

//...
{ test: /\.json$/, loader: "json-loader" }
//...

@esfourteen-zz
Copy link

broke for us as well with 3.1.0, 3.0.0 works fine

@dduponchel
Copy link
Collaborator

This comes from #317 where I reused the version in package.json.
I don't know well webpack: is there an easy fix on JSZip's side ? (if not, I'll revert to an hard-coded version).

@elrumordelaluz
Copy link

@dduponchel Where is used precisely the exposed JSZip.version?

@dduponchel
Copy link
Collaborator

It's not used internally, it is here to expose the version to other developers.

@lisamburns
Copy link
Author

lisamburns commented Aug 5, 2016

I also used json-loader within my webpack startup config (see snippet below) but I still get that error.
{test: /\.json$/, include: /node_modules/, loader: 'json-loader'},

dduponchel added a commit to dduponchel/jszip that referenced this issue Aug 5, 2016
Webpack don't support by default requiring json files like we did for
JSZip.version. It break builds so this commit fixes it by using an
hard-coded string instead (we'll try to find a better way later).

Fixes Stuk#327.
dduponchel added a commit to dduponchel/jszip that referenced this issue Aug 5, 2016
Webpack doesn't support requiring json files (like we did for
`JSZip.version`) without extra configuration. It breaks builds so this commit
fixes it by using an hard-coded string instead (we'll try to find a better way
later).

Fixes Stuk#327.
@lisamburns
Copy link
Author

lisamburns commented Aug 5, 2016

Yup, 3.0.0 works fine for me too.

@dduponchel
Copy link
Collaborator

Fixed in 3.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants