ccampbell / rainbow

Simple syntax highlighting library written in javascript
http://rainbowco.de
Apache License 2.0
3.3k stars 465 forks source link

Fails to build in webpack #221

Closed ohpyupi closed 5 years ago

ohpyupi commented 7 years ago

Hey guys,

Below is the error message I got when I attempt to build webpack bundle file with Rainbow.

Unexpected character '#' (1:0) `

!/usr/bin/env node

/ eslint-disable / var fs = require('fs'); ... `

I don't really see the reason why the hashbang command line should be there. So I tried it removing the line. However, I got another warning message. WARNING in ./~/bindings/bindings.js 76:22-40 Critical dependency: the request of a dependency is an expression

Is there anybody who solved the problem? Thanks.

superbogy commented 5 years ago

+1 same to me

IngwiePhoenix commented 5 years ago

If I am not mistaken, the hashbang isn't even required in NPM-based CLI apps, as they are wrapped by a script, which forwards arguments. Here is an example:

Ingwie@Ingwies-Macbook-Pro.local ~ $ file /usr/local/bin/babel
/usr/local/bin/babel: a /usr/bin/env node script text executable, ASCII text
Ingwie@Ingwies-Macbook-Pro.local ~ $ head -n 5 /usr/local/bin/babel
#!/usr/bin/env node

require("../lib/babel");

The corresponding file:

Now, this is on a Mac. On windows, this should be wrapped. So the best bet is to take the Babel aproach and just create a script that really just requires the actual library itself - so the hashbang does not get in the way.