mirror of https://github.com/status-im/metro.git
Require transformer options to be present throughout
Summary: `transformModulePath` used to be an optional string, because `ConfigT` allowed for an optional `getTransformModulePath` method. Effectively, we required it to be present. This builds on top of the cleanups around `ConfigT` and gets rid of the flow error suppressions Reviewed By: jeanlauliac Differential Revision: D5037466 fbshipit-source-id: bc5c9cbc566e7aa74e7f6397e69fa87cdac7bc00
This commit is contained in:
parent
797a07ccc2
commit
f5abafd17b
|
@ -34,6 +34,7 @@ type Options = {
|
|||
projectRoots: Array<string>,
|
||||
reporter?: Reporter,
|
||||
+sourceExts: ?Array<string>,
|
||||
+transformModulePath: string,
|
||||
watch?: boolean,
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ jest
|
|||
.mock('../Bundle')
|
||||
.mock('../HMRBundle')
|
||||
.mock('../../Logger')
|
||||
.mock('/path/to/transformer.js', () => ({}), {virtual: true})
|
||||
;
|
||||
|
||||
var Bundler = require('../');
|
||||
|
@ -36,6 +37,7 @@ const os = require('os');
|
|||
|
||||
const {any, objectContaining} = expect;
|
||||
|
||||
|
||||
var commonOptions = {
|
||||
allowBundleUpdates: false,
|
||||
assetExts: defaults.assetExts,
|
||||
|
@ -44,6 +46,7 @@ var commonOptions = {
|
|||
platforms: defaults.platforms,
|
||||
resetCache: false,
|
||||
sourceExts: defaults.sourceExts,
|
||||
transformModulePath: '/path/to/transformer.js',
|
||||
watch: false,
|
||||
};
|
||||
|
||||
|
@ -95,6 +98,10 @@ describe('Bundler', function() {
|
|||
});
|
||||
Resolver.load = jest.fn().mockImplementation(opts => Promise.resolve(new Resolver(opts)));
|
||||
|
||||
fs.__setMockFilesystem({
|
||||
'path': {'to': {'transformer.js': ''}},
|
||||
});
|
||||
|
||||
fs.statSync.mockImplementation(function() {
|
||||
return {
|
||||
isDirectory: () => true,
|
||||
|
|
|
@ -133,7 +133,7 @@ type Options = {|
|
|||
+reporter: Reporter,
|
||||
+resetCache: boolean,
|
||||
+sourceExts: Array<string>,
|
||||
+transformModulePath?: string,
|
||||
+transformModulePath: string,
|
||||
+transformTimeoutInterval: ?number,
|
||||
+watch: boolean,
|
||||
|};
|
||||
|
@ -155,15 +155,9 @@ class Bundler {
|
|||
|
||||
opts.projectRoots.forEach(verifyRootExists);
|
||||
|
||||
let transformModuleHash;
|
||||
try {
|
||||
/* $FlowFixMe: if transformModulePath is null it'll just be caught */
|
||||
const transformModuleStr = fs.readFileSync(opts.transformModulePath);
|
||||
transformModuleHash =
|
||||
const transformModuleHash =
|
||||
crypto.createHash('sha1').update(transformModuleStr).digest('hex');
|
||||
} catch (error) {
|
||||
transformModuleHash = '';
|
||||
}
|
||||
|
||||
const stableProjectRoots = opts.projectRoots.map(p => {
|
||||
return path.relative(path.join(__dirname, '../../../..'), p);
|
||||
|
@ -197,7 +191,6 @@ class Bundler {
|
|||
const maxWorkerCount = Bundler.getMaxWorkerCount();
|
||||
|
||||
this._transformer = new Transformer(
|
||||
/* $FlowFixMe: in practice it's always here. */
|
||||
opts.transformModulePath,
|
||||
maxWorkerCount,
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ type Options = {
|
|||
resetCache?: boolean,
|
||||
silent?: boolean,
|
||||
+sourceExts: ?Array<string>,
|
||||
transformModulePath?: string,
|
||||
+transformModulePath: string,
|
||||
transformTimeoutInterval?: number,
|
||||
watch?: boolean,
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ class Server {
|
|||
resetCache: boolean,
|
||||
silent: boolean,
|
||||
+sourceExts: Array<string>,
|
||||
transformModulePath: void | string,
|
||||
+transformModulePath: string,
|
||||
transformTimeoutInterval: ?number,
|
||||
watch: boolean,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue