mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Emit PrePack information as global into bundle (optionally)
Summary: Emit PrePack info into the generated bundle. The intention is for this to include information about enabled prepack options. Currently it only includes a flag if lazy objects are enabled. Its emitted as global which is somewhat intrusive so its guarded by a flag currently and defaults to false. Example: ``` var __PREPACK__ = {lazyObjects: false} ``` Reviewed By: NTillmann Differential Revision: D8321765 fbshipit-source-id: 03a41b2cef84ea44c02c71e233b407e3ddc1197d
This commit is contained in:
parent
377b000029
commit
5ee7ba4aa8
@ -92,6 +92,7 @@ export type SerializerOptions = {
|
||||
inlineExpressions?: boolean,
|
||||
trace?: boolean,
|
||||
heapGraphFormat?: "DotLanguage" | "VISJS",
|
||||
prepackInfo?: boolean,
|
||||
};
|
||||
|
||||
export type PartialEvaluatorOptions = {
|
||||
|
@ -80,6 +80,7 @@ function run(
|
||||
--repro Create a zip file with all information needed to reproduce a Prepack run"
|
||||
--cpuprofile Create a CPU profile file for the run that can be loaded into the Chrome JavaScript CPU Profile viewer",
|
||||
--debugDiagnosticSeverity FatalError | RecoverableError | Warning | Information (default = FatalError). Diagnostic level at which debugger will stop
|
||||
--prepackInfo Emit a global variable with information about the corresponding PrePack run.
|
||||
`;
|
||||
let args = Array.from(process.argv);
|
||||
args.splice(0, 2);
|
||||
@ -120,6 +121,7 @@ function run(
|
||||
residual: false,
|
||||
profile: false,
|
||||
reactEnabled: false,
|
||||
prepackInfo: false,
|
||||
};
|
||||
|
||||
let reproArguments = [];
|
||||
@ -356,6 +358,7 @@ fi
|
||||
},
|
||||
flags
|
||||
);
|
||||
|
||||
if (heapGraphFilePath !== undefined) resolvedOptions.heapGraphFormat = "DotLanguage";
|
||||
if (lazyObjectsRuntime !== undefined && (resolvedOptions.delayInitializations || resolvedOptions.inlineExpressions)) {
|
||||
console.error("lazy objects feature is incompatible with delayInitializations and inlineExpressions options");
|
||||
|
@ -65,6 +65,7 @@ export type PrepackOptions = {|
|
||||
debugOutFilePath?: string,
|
||||
abstractValueImpliesMax?: number,
|
||||
debuggerConfigArgs?: DebuggerConfigArguments,
|
||||
prepackInfo?: boolean,
|
||||
|};
|
||||
|
||||
export function getRealmOptions({
|
||||
@ -130,6 +131,7 @@ export function getSerializerOptions({
|
||||
inlineExpressions = false,
|
||||
initializeMoreModules = false,
|
||||
trace = false,
|
||||
prepackInfo = false,
|
||||
}: PrepackOptions): SerializerOptions {
|
||||
let result: SerializerOptions = {
|
||||
delayInitializations,
|
||||
@ -144,6 +146,7 @@ export function getSerializerOptions({
|
||||
profile,
|
||||
inlineExpressions,
|
||||
trace,
|
||||
prepackInfo,
|
||||
};
|
||||
if (lazyObjectsRuntime !== undefined) {
|
||||
result.lazyObjectsRuntime = lazyObjectsRuntime;
|
||||
|
@ -2236,6 +2236,23 @@ export class ResidualHeapSerializer {
|
||||
);
|
||||
}
|
||||
|
||||
if (this._options.prepackInfo) {
|
||||
this.emitter.emit(
|
||||
t.expressionStatement(
|
||||
t.assignmentExpression(
|
||||
"=",
|
||||
this.preludeGenerator.globalReference("__PREPACK__", false),
|
||||
t.objectExpression([
|
||||
t.objectProperty(
|
||||
t.identifier("lazyObjects"),
|
||||
t.booleanLiteral(this._options.lazyObjectsRuntime !== undefined)
|
||||
),
|
||||
])
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
this.postGeneratorSerialization();
|
||||
|
||||
Array.prototype.push.apply(this.prelude, this.preludeGenerator.prelude);
|
||||
|
Loading…
Reference in New Issue
Block a user