Simplify File type: map is nullable, but not optional

Summary:
Simplifies the `File` type by making `map` a non-optional, but nullable property.
Also adds helper functions for empty/virtual modules

Reviewed By: jeanlauliac

Differential Revision: D5111580

fbshipit-source-id: 9cab6634a9bdb0522dc36aec2abccaef9cf35339
This commit is contained in:
David Aurelio
2017-05-23 10:31:27 -07:00
committed by Facebook Github Bot
parent 918bae282b
commit 6b2122be13
6 changed files with 35 additions and 21 deletions
+2 -14
View File
@@ -10,6 +10,8 @@
*/
'use strict';
const virtualModule = require('../module').virtual;
import type {IdForPathFn, Module} from '../types.flow';
// Transformed modules have the form
@@ -77,17 +79,3 @@ exports.requireCallsTo = function* (
yield virtualModule(`require(${idForPath(module.file)});`);
}
};
// creates a virtual module (i.e. not corresponding to a file on disk)
// with the given source code.
exports.virtualModule = virtualModule;
function virtualModule(code: string) {
return {
dependencies: [],
file: {
code,
path: '',
type: 'script',
},
};
}