Add id to DeltaEntry object

Reviewed By: mjesun

Differential Revision: D6158753

fbshipit-source-id: 5997e36c8d85da750113250e5180a1f54ee14b76
This commit is contained in:
Rafael Oleza 2017-10-26 03:09:47 -07:00 committed by Facebook Github Bot
parent e4dad595e1
commit 0e764686e1
1 changed files with 15 additions and 8 deletions

View File

@ -36,6 +36,7 @@ export type DeltaEntryType =
export type DeltaEntry = {| export type DeltaEntry = {|
+code: string, +code: string,
+id: number,
+map: ?Array<RawMapping>, +map: ?Array<RawMapping>,
+name: string, +name: string,
+path: string, +path: string,
@ -182,6 +183,12 @@ class DeltaTransformer extends EventEmitter {
const transformerOptions = await this._deltaCalculator.getTransformerOptions(); const transformerOptions = await this._deltaCalculator.getTransformerOptions();
const dependencyEdges = this._deltaCalculator.getDependencyEdges(); const dependencyEdges = this._deltaCalculator.getDependencyEdges();
// Return the source code that gets prepended to all the modules. This
// contains polyfills and startup code (like the require() implementation).
const prependSources = reset
? await this._getPrepend(transformerOptions, dependencyEdges)
: new Map();
// Precalculate all module ids sequentially. We do this to be sure that the // Precalculate all module ids sequentially. We do this to be sure that the
// mapping between module -> moduleId is deterministic between runs. // mapping between module -> moduleId is deterministic between runs.
const modules = Array.from(modified.values()); const modules = Array.from(modified.values());
@ -198,12 +205,6 @@ class DeltaTransformer extends EventEmitter {
modifiedDelta.set(this._getModuleId({path: id}), null); modifiedDelta.set(this._getModuleId({path: id}), null);
}); });
// Return the source code that gets prepended to all the modules. This
// contains polyfills and startup code (like the require() implementation).
const prependSources = reset
? await this._getPrepend(transformerOptions, dependencyEdges)
: new Map();
// Return the source code that gets appended to all the modules. This // Return the source code that gets appended to all the modules. This
// contains the require() calls to startup the execution of the modules. // contains the require() calls to startup the execution of the modules.
const appendSources = reset const appendSources = reset
@ -282,6 +283,7 @@ class DeltaTransformer extends EventEmitter {
moduleId, moduleId,
{ {
code, code,
id: moduleId,
map: null, map: null,
name, name,
source: code, source: code,
@ -294,9 +296,11 @@ class DeltaTransformer extends EventEmitter {
if (this._bundleOptions.sourceMapUrl) { if (this._bundleOptions.sourceMapUrl) {
const code = '//# sourceMappingURL=' + this._bundleOptions.sourceMapUrl; const code = '//# sourceMappingURL=' + this._bundleOptions.sourceMapUrl;
const id = this._getModuleId({path: '/sourcemap.js'});
append.set(this._getModuleId({path: '/sourcemap.js'}), { append.set(id, {
code, code,
id,
map: null, map: null,
name: 'sourcemap.js', name: 'sourcemap.js',
path: '/sourcemap.js', path: '/sourcemap.js',
@ -381,10 +385,13 @@ class DeltaTransformer extends EventEmitter {
// uglifyJS only returns standard Source Maps). // uglifyJS only returns standard Source Maps).
const map = Array.isArray(wrapped.map) ? wrapped.map : undefined; const map = Array.isArray(wrapped.map) ? wrapped.map : undefined;
const id = this._getModuleId(module);
return [ return [
this._getModuleId(module), id,
{ {
code: ';' + wrapped.code, code: ';' + wrapped.code,
id,
map, map,
name, name,
source: metadata.source, source: metadata.source,