dominictarr / JSONStream

rawStream.pipe(JSONStream.parse()).pipe(streamOfObjects)
Other
1.92k stars 165 forks source link

Can't be loaded by webpack #126

Closed zhaoyi0113 closed 7 years ago

zhaoyi0113 commented 7 years ago

I am trying to load JSONStream through webpack but failed with below error:

ERROR in ./~/JSONStream/index.js
Module parse failed: /Project/node_modules/JSONStream/index.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node

I found that the first line of index.js is #! /usr/bin/env node which gives such problem. Is there a way for me to load this module through webpack?

dominictarr commented 7 years ago

you should file this as a bug in webpack. I am sure there are loads of other modules that have this, and this is a very popular module that has been this way for a long time, it would be much easier to fix this in webpack than to fix every module which uses this. Browserify can handle this, btw.

corysimmons commented 7 years ago

Here's the issue if anyone's interested.

imerkle commented 7 years ago

I't doesn't solves it.

mrchief commented 7 years ago

hash bang is not valid JavaScript. Its interpreted by node js but that doesn't make it valid JS.

I am sure there are loads of other modules that have this

There are few but not many. At least not libs that aim to work in both node as well as browser. And it doesn't work on Windows as well.

There is no value in the hash bang. Node JS will interpret it correctly either way. I doubt webpack will ever address it, since its not a webpack issue technically. Its one of those issues which can be argued to death either which way.

In the end, it boils down to this - Do you envision the greater use case of this lib as a shell script or as a node package? Do you want this lib to be restricted to "linux+node" only environment (for having that 1 line) or do you want to open it up to much larger audience (and get rid of the line).

For folks looking for work-around: