Closed zhaoyi0113 closed 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.
Here's the issue if anyone's interested.
I't doesn't solves it.
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:
I am trying to load JSONStream through webpack but failed with below error:
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?