prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
62 lines (49 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DebugReproManagerImplementation = void 0;
var _SourceMapManager = require("./SourceMapManager.js");
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* strict-local */
/**
* Manager that captures name of all original sourcefiles touched by Prepack.
* When Prepack exits (regardless of success or failure), the list of all
* relevant sourcefiles is passed back to the CLI to be included in the reproBundle.
*/
class DebugReproManagerImplementation {
construct(configArgs) {
this._sourceMapManager = new _SourceMapManager.SourceMapManager(configArgs.buckRoot, configArgs.sourcemaps);
if (configArgs.sourcemaps) {
this._sourceMapNames = [];
configArgs.sourcemaps.forEach(m => {
if (m.sourceMapFilename !== undefined) this._sourceMapNames.push(m.sourceMapFilename);
});
}
this._usedSourceFiles = new Set();
return this;
} // Manager to translate between relative/absolute paths used by sourceMaps/Filesystem.
addSourceFile(fileName) {
if (!fileName.includes("node_modules")) this._usedSourceFiles.add(this._sourceMapManager.relativeToAbsolute(fileName));
}
getSourceFilePaths() {
return Array.from(this._usedSourceFiles).map(absolutePath => {
return {
absolute: absolutePath,
relative: this._sourceMapManager.absoluteToRelative(absolutePath)
};
});
}
getSourceMapPaths() {
return this._sourceMapNames;
}
}
exports.DebugReproManagerImplementation = DebugReproManagerImplementation;
//# sourceMappingURL=DebugReproManager.js.map