Prepack is a tool that optimizes JavaScript source code: Computations that can be done at compile-time instead of run-time get eliminated. Prepack replaces the global code of a JavaScript bundle with equivalent code that is a simple sequence of assignments. This gets rid of most intermediate computations and object allocations.
How to get the code
Clone repository and make it your current directory.
git submodule init
git submodule update –recursive –remote
Get npm and node, then do npm install
How to build, lint, type check
npm run build
You can later run npm run watch in the background to just compile changed files on the fly.
npm run lint
npm run flow
How to run tests
Make sure the code is built, either by running npm run build or npm run watch
npm test
You can run individual test suites as follows.
npm run test-serializer
This tests the interpreter and serializer. All tests should pass.
npm run test-test262
This tests conformance against the test262 suite. Not all will pass, increasing conformance is work in progress.
How to run the interpreter
Make sure the code is built, either by running npm run build or npm run watch
npm run repl
This starts an interactive interpreter session.
How to run Prepack
Make sure the code is built, either by running npm run build or npm run watch.
Have a JavaScript file handy that you want to prepack, for example:
echo “function hello() { return ‘hello’; } function world() { return ‘world’; } s = hello() + ‘ ‘ + world();” >/tmp/sample.js
npm run prepack /tmp/sample.js
Try –help for more options.
How to validate changes
Instead of building, linting, type checking, testing separately, the following does everything together:
npm run validate
Find more: https://prepack.io