This tiny proof of concept does:
- Provide
scripts/get_jspp.js
, which will download the latest JS++ binary into a locally createdbin/
folder. - Execute the above script upon this package being installed.
- Provide a small NPM script that will run JS++ on
index.jspp
, then forward the output to WebPack and produceindex.out.js
.
How to reproduce this concept:
- Clone this repository.
cd
into it and executenpm install .
.- Run
npm test
. - Inspect the output of
index.out.js
.
Essentially, JS++ is tricked into treating require()
as an external variable - which effectively leaves calls to it within the source code. The output of that compilation is then given to WebPack as an entry. WebPack picks up the require()
calls, and translates them, inlining someModule.js
into the build.
You can run this too: node ./index.out.js
This should produce something similar to this:
$ node ./index.out.js
4
It should be noted, that this configuration to WebPack will leave the modules' original reqiure strings intact - during a production build however, those would be replaced by numers instead.