Why do I get a ReferenceError
when trying to prepack my code?
Trying to prepack a seemingly simple program such as global.result = UnknownProperty;
will cause a
ReferenceError
. 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 ReferenceError
. You might want to invest into modeling your environment.
Check out the section The Environment matters! on the landing page.
Why does global.UnknownProperty
prepack to undefined
?
Prepack actually runs the global code, and by default, any accesses to unknown properties of an object result in
undefined
. Thus, global.UnknownProperty
prepacks to undefined
.
You might want to invest into modeling your environment.
Check out the section The Environment matters! on the landing page.
What is an __IntrospectionError
or a PPxxxx error code?
Prepack actually runs the global code.
When functions such as Date.now
or Math.random
are invoked,
their behavior is non-deterministic. 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 __abstract
built-in, or
other modeling built-ins described in the section The Environment matters! on the landing page.)
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 either throws a generic __IntrospectionError
, or reports a specialized PPxxxx error.
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.
If you get such an error while using Math.random
,
consider setting the mathRandomSeed
option to make all random numbers queries along the global code path deterministic.
All PPxxxx error code are documented on the Prepack wiki.
When will Prepack understand all DOM objects?
Monitor this GitHub issue.
Why didn't Prepack optimize code that's in a function?
Prepack only optimizes code that gets executed along the global code path, the initialization phase. Any code that sits behind callbacks is not optimized by default. Check out the Optimize More Code! section on the landing page for information on how to optimize functions.
When is Prepack ready to be used in production?
Wait for our latest release to reach v1.0.
Has Prepack been integrated with other tools?
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.
Prepack is still in an early development stage and not ready for production use just yet.