mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
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
162 lines
7.2 KiB
HTML
162 lines
7.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Prepack · 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">Getting Started</a>
|
|
<a href="frequently-asked-questions.html" class="nav-item is-active">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>Why do I get a <code>ReferenceError</code> when trying to prepack my code?</h2>
|
|
|
|
<p class="align-left">
|
|
Trying to prepack a seemlingly simple program such as <code>global.result = UnknownProperty;</code> will cause a
|
|
<code>ReferenceError</code>. The reason is that Prepack actually runs the global code, not knowing anything else
|
|
about the environment. And the semantics of JavaScript is that an unknown identifier that cannot be resolved
|
|
causes a <code>ReferenceError</code>. You might want to invest into modeling your environment.
|
|
Check out the section <i>The Environment matters!</i> on the landing page.
|
|
</p>
|
|
|
|
<h2>Why does <code>global.UnknownProperty</code> prepack to <code>undefined</code>?</h2>
|
|
|
|
<p class="align-left">
|
|
Prepack actually runs the global code, and by default, any accesses to unknown properties of an object result in
|
|
<code>undefined</code>. Thus, <code>global.UnknownProperty</code> prepacks to <code>undefined</code>.
|
|
You might want to invest into modeling your environment.
|
|
Check out the section <i>The Environment matters!</i> on the landing page.
|
|
</p>
|
|
|
|
<h2>What is an <code>__IntrospectionError</code>?</h2>
|
|
|
|
<p class="align-left">
|
|
Prepack actually runs the global code.
|
|
When functions such as <code>Date.now</code> or <code>Math.random</code> are invoked,
|
|
their behavior is <i>non-deterministic</i>. Prepack doesn't know which exact value they will return
|
|
when the resulting prepacked code will run again later in the real run-time environment.
|
|
(You can also directly inject such non-deterministic values using Prepack's <code>__abstract</code> built-in, or
|
|
other modeling built-ins described in the section <i>The Environment matters!</i> on the landing page.)
|
|
</o>
|
|
<p class="align-left">
|
|
When the global code branches over such values,
|
|
it is not clear at prepack-time which branch will be taken later in the real run-time environment.
|
|
Therefore, Prepack tries to explore all possible behaviors, and summarize them.
|
|
However, Prepack is still limited in its abilities, and sometimes it just won't ever make sense to explore all possible behaviors.
|
|
In those cases, Prepack throws a <code>__IntrospectionError</code>.
|
|
This is not a user error, but a Prepack limitation.
|
|
It is sometimes possible to work around these limitations by changing your code. The easiest way to work around the limitation is to move the problematic code out of the global code path into a callback that's only invoked later, or by making the problematic part of the initialization phase lazy.
|
|
</p>
|
|
<p class="align-left">
|
|
If you get such an error while using <code>Math.random</code>,
|
|
consider setting the <code>mathRandomSeed</code> option to make all random numbers queries along the global code path deterministic.
|
|
</p>
|
|
|
|
<h2>When will Prepack understand all DOM objects?</h2>
|
|
|
|
<p class="align-left">
|
|
Monitor <a href="https://github.com/facebook/prepack/issues/24">this GitHub issue</a>.
|
|
</p>
|
|
|
|
<h2>Why didn't Prepack optimize code that's in a function?</h2>
|
|
|
|
<p class="align-left">
|
|
Prepack only optimizes code that gets executed along the global code path, the initialization phase.
|
|
Any code that sits behind callbacks is not optimized at this time.
|
|
</p>
|
|
|
|
<h2>When is Prepack ready to be used in production?</h2>
|
|
|
|
<p class="align-left">
|
|
Wait for our <a href="https://www.npmjs.com/package/prepack">latest release</a> to reach v1.0.
|
|
</p>
|
|
|
|
<h2>Has Prepack been integrated with other tools?</h2>
|
|
|
|
<p class="align-left">
|
|
The following are a few plugins to other tools.
|
|
They have been created and are maintained separately from Prepack itself.
|
|
If you run into any issues with those plugins,
|
|
please ask the plugin maintainers for support.
|
|
</p>
|
|
<p class="align-left">
|
|
<b>Prepack is still in an early development stage and not ready for production use just yet.</b>
|
|
</p>
|
|
|
|
<ul class="align-left">
|
|
<li>
|
|
<a href="https://www.npmjs.com/package/rollup-plugin-prepack">A Rollup plugin for Prepack</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://www.npmjs.com/package/prepack-webpack-plugin">A webpack plugin for Prepack</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://marketplace.visualstudio.com/items?itemName=RobinMalfait.prepack-vscode">A Visual Studio code plugin for Prepack</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://www.npmjs.com/package/babel-plugin-flow-prepack">A babel plugin which transforms Flow annotations into prepack model declarations.</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-background">
|
|
<div class="content-container">
|
|
<div class="footer">
|
|
<div>
|
|
Copyright © 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>
|