prepack/website/getting-started.html
James Nolan 3c9c6ac2a5 Make master/docs a single source of truth for gh-pages
Summary:
Release note: none

To address issue #956 .

The idea is to have all documentation (aka "the website") in a single `docs/` directory on the `master` branch like [Jest](https://github.com/facebook/jest/tree/master/docs) and [Relay](https://github.com/facebook/relay/tree/master/docs) do. This directory then serves as a single source of truth to publish the `gh-pages` branch.

This PR:
- Moves the current content of the `gh-pages` branch to a `docs/` directory in `master`
- Provides a bash script for maintainers to easily publish the `gh-pages` branch from the `docs/` directory. The script also builds `prepack.min.js` from master to make sure gh-pages always has the latest version of prepack.

Additionally, I noticed the `gh-pages` branch had two `prepack.min.js` files (one in `./` and one in `./js/`). I removed the first one because it is apparently not used but it may break other websites if they references that file.

0. Fork the repo to avoid modifying the real website

1. Change the site
`> git checkout master`
`> echo ".nav { background-color: chartreuse; }" >> docs/css/style.css`
`> git add docs/css/style.css`
`> commit -m "The navigation bar looks better in green"`
`> git push`

2. Run the publication script:
`> ./scripts/publish-gh-pages.sh`

3. Verify that the gh-pages has been updated:
`> git checkout gh-pages`
`> git pull`
`> git diff HEAD~ # should show the line you added`
Closes https://github.com/facebook/prepack/pull/1223

Differential Revision: D6547395

Pulled By: j-nolan

fbshipit-source-id: 6e6d3aec97c0bcc2555c421d6f4a889bcd8df208
2017-12-12 12:10:05 -08:00

264 lines
11 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Prepack &middot; Partial evaluator for JavaScript</title>
<script src="js/prism.js"></script>
<link rel="stylesheet" href="css/style.css"/>
<link rel="stylesheet" href="css/prism.css"/>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-44373548-29', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<nav class="nav">
<div class="content-container">
<div class="nav-left">
<a class="nav-item is-brand" href="./">
Prepack
</a>
</div>
<span id="nav-toggle" class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div id="nav-menu" class="nav-right nav-menu">
<a href="./" class="nav-item">About</a>
<a href="getting-started.html" class="nav-item is-active">Getting Started</a>
<a href="frequently-asked-questions.html" class="nav-item">FAQs</a>
<a href="repl.html" class="nav-item">Try It Out</a>
<a href="https://github.com/facebook/prepack" class="nav-item">GitHub</a>
</div>
</div>
</nav>
<div class="content">
<div class="section">
<div class="content-container">
<h2>Prepack CLI</h2>
<h3>Installation</h3>
<div class="code-block language-sh">
<pre><code>npm install -g prepack</code></pre>
</div>
<h3>Compiling a File</h3>
<p class="align-left">Compile a file and print it to the console:</p>
<div class="code-block language-sh">
<pre><code>prepack script.js</code></pre>
</div>
<p class="align-left">Compile a file and output <strong>to another file</strong>:</p>
<div class="code-block language-sh">
<pre><code>prepack script.js --out script-processed.js</code></pre>
</div>
<p class="align-left">If you want to output <strong>a source map file</strong> add the <code>--srcmapOut</code>. If your bundle was generated from some other compiler, Prepack will automatically look for a <code>.map</code> file but you can also specify it using the <code>--srcmapIn</code> option:</p>
<div class="code-block language-sh">
<pre><code>prepack script.js --out script-processed.js --srcmapIn script.map --srcmapOut script-processed.map</code></pre>
</div>
<p class="align-left">
For advanced uses <a href="#options">see the API options</a> or <code>prepack --help</code>.
</p>
<div class="code-block language-sh">
<pre><code>prepack [ --out output.js ] [ --compatibility jsc ] [ --mathRandomSeed seedvalue ] [ --srcmapIn inputMap ] [ --srcmapOut outputMap ] [ --speculate ] [ --trace ] [ -- | input.js ] [ --singlePass ] [ --debugNames ] [ --logStatistics ]</code></pre>
</div>
<h3>REPL</h3>
<p class="align-left">
You can also run Prepack in REPL mode. This probably isn't very useful but it lets you test bugs in Prepack's interpreter.
</p>
<div class="code-block language-sh">
<pre><code>prepack-repl</code></pre>
</div>
</div>
</div>
<div class="section">
<div class="content-container">
<h2>Prepack API</h2>
<p class="align-left">
You can also use the programmatic API as a Node.js module.
</p>
<h3>Installation</h3>
<div class="code-block language-sh">
<pre><code>npm install --save-dev prepack</code></pre>
</div>
<div class="code-block language-js">
<pre><code>var Prepack = require("prepack");
import { prepack, prepackFileSync } from 'prepack';
import * as Prepack from 'prepack';</code></pre>
</div>
<h3>String</h3>
<div class="code-block language-js">
<pre><code>Prepack.prepack(codeString, options) // returns { code: string, map: SourceMap }</code></pre>
</div>
<h3>Babel AST</h3>
<div class="code-block language-js">
<pre><code>Prepack.prepackFromAst(babelAstNode, code, options) // returns { code: string, map: SourceMap }</code></pre>
</div>
<p class="align-left">Note: Currently, the source code still has to be provided for <code>Function.prototype.toString</code> and error messages.</p>
<h3>File Async</h3>
<div class="code-block language-js">
<pre><code>Prepack.prepackFile(filename, options, callback) // callback(error, { code: string, map: SourceMap })</code></pre>
</div>
<h3>File Sync</h3>
<div class="code-block language-js">
<pre><code>Prepack.prepackFileSync(filename, options) // returns { code: string, map: SourceMap }</code></pre>
</div>
<h3 id="options">Options</h3>
<table class="options-table">
<thead>
<tr>
<th>Option</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>filename</code></td>
<td><code>string</code></td>
<td>inferred</td>
<td>Filename to use in error stacks.</td>
</tr>
<tr>
<td><code>inputSourceMapFilename</code></td>
<td><code>string</code></td>
<td><code>null</code></td>
<td>If provided, this input source map file is used as the input before generating a new source map.</td>
</tr>
<tr>
<td><code>sourceMaps</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>Determines whether a source map file should be generated.</td>
</tr>
<tr>
<td><code>compatibility</code></td>
<td><code>"browser" | "jsc-600-1-4-17"</code></td>
<td><code>"browser"</code></td>
<td>Select a built-in environment compatibility. More built-in environments will be added in the future.</td>
</tr>
<tr>
<td><code>mathRandomSeed</code></td>
<td><code>string</code></td>
<td><code>null<code></td>
<td>If a seed string is provided, <code>Math.random()</code> can be relied on and used in concrete code paths.</td>
</tr>
<tr>
<td><code>speculate</code></td>
<td><code>boolean</code></td>
<td>false</td>
<td>Speculatively pre-execute more `require(...)` calls if they're part of the residual program.</td>
</tr>
<tr>
<td><code>trace</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>Logs evaluated function calls.</td>
</tr>
<tr>
<td><code>debugNames</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>If true, try to retain original variable and function names as part of the generated code.</td>
</tr>
<tr>
<td><code>singlePass</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>Currently, the serializer makes two passes to optimize the variable naming in the output but this is slow so this lets you opt for a single pass. This option is expected to be unnecessary in the future.</td>
</tr>
<tr>
<td><code>logStatistics</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>If true, logs statistics about the number of objects, functions and ids generated.</td>
</tr>
<tr>
<td><code>logModules</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>If true, logs modules evaluated.</td>
</tr>
<tr>
<td><code>delayUnsupportedRequires</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>If true, speculatively executed requires that failed to execute doesn't get preexecuted.</td>
</tr>
<tr>
<td><code>internalDebug</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>If true, prints the JS stack inside of Prepack along with the stack in the Prepacked program. Useful for debugging Prepack itself.</td>
</tr>
<tr>
<td><code>uniqueSuffix</code></td>
<td><code>string</code></td>
<td><code>null</code></td>
<td>If adds a unique suffix to generated IDs so that they don't risk colliding with anything else in the program. Expected to be automatic in the future.</td>
</tr>
<tr>
<td><code>timeout</code></td>
<td><code>number</code></td>
<td><code>Infinity</code></td>
<td>Number of milliseconds to run a program before it times out. Useful to avoid infinite loops in the Prepacked program.</td>
</tr>
<tr>
<td><code>strictlyMonotonicDateNow</code></td>
<td><code>boolean</code></td>
<td><code>false</code></td>
<td>Currently only used to run the Test262 test suite which requires reading Date.now() in increasing order.</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="footer-background">
<div class="content-container">
<div class="footer">
<div>
Copyright &copy; 2017 Facebook Inc.
</div>
<div>
<a href="https://code.facebook.com/projects/" target="_blank">
<img
class="oss-logo"
src="./static/images/oss_logo.png"
alt="Facebook Open Source"
title="Facebook Open Source" />
</a>
</div>
</div>
</div>
</div>
<script src="js/toggle_menu.js"></script>
</body>
</html>