What Does Prepack Do?
You can learn the basics of what Prepack does and how it works from this overview.
It's not complete, but it can serve as a high-level overview while avoiding the computer science jargon.
Prepack CLI
Installation
npm install -g prepack
Compiling a File
Compile a file and print it to the console:
prepack script.js
Compile a file and output to another file:
prepack script.js --out script-processed.js
If you want to output a source map file add the --srcmapOut. If your bundle was generated from some other compiler, Prepack will automatically look for a .map file but you can also specify it using the --srcmapIn option:
prepack script.js --out script-processed.js --srcmapIn script.map --srcmapOut script-processed.map
For advanced uses see the API options or prepack --help.
prepack [ --out output.js ] [ --compatibility jsc ] [ --mathRandomSeed seedvalue ] [ --srcmapIn inputMap ] [ --srcmapOut outputMap ] [ -- | input.js ]
REPL
You can also run Prepack in REPL mode. This probably isn't very useful but it lets you test bugs in Prepack's interpreter.
prepack-repl
Prepack API
You can also use the programmatic API as a Node.js module.
Installation
npm install --save-dev prepack
var Prepack = require("prepack");
import { prepack, prepackFileSync } from 'prepack';
import * as Prepack from 'prepack';
String
Prepack.prepackSources([{filePath, fileContents, sourceMapContents}], options) // returns { code: string, map: SourceMap }
File Async
Prepack.prepackFile(filename, options, callback) // callback(error, { code: string, map: SourceMap })
File Sync
Prepack.prepackFileSync(filenames, options) // returns { code: string, map: SourceMap }
