mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Provides an additionalGlobal initialization option
Summary: Release Note: none This PR should provide external tooling, that wraps Prepack Node, the ability to define Prepack globals. This will allow the React compiler to use standalone Prepack with the only differences being specific globals that are added (for React related stubs). The `additionalGlobals` is a function that passes through `realm` like other globals are handled. Closes https://github.com/facebook/prepack/pull/1073 Differential Revision: D6039946 Pulled By: trueadm fbshipit-source-id: f38155244d8d3836b56f39fe964ed0f13b198621
This commit is contained in:
parent
cfc6993e9c
commit
52d274f78e
@ -11,8 +11,10 @@
|
||||
|
||||
import type { ErrorHandler } from "./errors.js";
|
||||
import type { SerializerOptions, RealmOptions, Compatibility } from "./options";
|
||||
import { Realm } from "./realm.js";
|
||||
|
||||
export type PrepackOptions = {|
|
||||
additionalGlobals?: Realm => void,
|
||||
additionalFunctions?: Array<string>,
|
||||
compatibility?: Compatibility,
|
||||
debugNames?: boolean,
|
||||
|
@ -44,6 +44,9 @@ export function prepackSources(
|
||||
realmOptions.errorHandler = options.errorHandler;
|
||||
let realm = construct_realm(realmOptions);
|
||||
initializeGlobals(realm);
|
||||
if (typeof options.additionalGlobals === "function") {
|
||||
options.additionalGlobals(realm);
|
||||
}
|
||||
|
||||
if (options.serialize || !options.residual) {
|
||||
let serializer = new Serializer(realm, getSerializerOptions(options));
|
||||
|
Loading…
Reference in New Issue
Block a user