mirror of https://github.com/status-im/metro.git
Make metro-bundler use a no-op transformer by default
Summary: When starting to use `metro-bundler` as a standalone server, I found quite complicated the fact that it needs a transformer by default. Moreover, the transformer is not passed as a reference to a JS object, but as a path to a required file. I removed the need to be required, and defaulted to a dummy, basic transform, that does nothing by default. This avoids having to create an extra file and linking to it (potentially needing to involve `path` and other extra modules). Reviewed By: cpojer Differential Revision: D5622906 fbshipit-source-id: 0c2b1bec86fa542b3c05de42c89d4b5bb4384b34
This commit is contained in:
parent
3731fa7c3c
commit
84ae805e78
|
@ -91,7 +91,7 @@ export type Options = {|
|
||||||
silent?: boolean,
|
silent?: boolean,
|
||||||
+sourceExts: ?Array<string>,
|
+sourceExts: ?Array<string>,
|
||||||
+transformCache: TransformCache,
|
+transformCache: TransformCache,
|
||||||
+transformModulePath: string,
|
transformModulePath?: string,
|
||||||
watch?: boolean,
|
watch?: boolean,
|
||||||
workerPath: ?string,
|
workerPath: ?string,
|
||||||
|};
|
|};
|
||||||
|
@ -214,7 +214,8 @@ class Server {
|
||||||
silent: options.silent || false,
|
silent: options.silent || false,
|
||||||
sourceExts: options.sourceExts || defaults.sourceExts,
|
sourceExts: options.sourceExts || defaults.sourceExts,
|
||||||
transformCache: options.transformCache,
|
transformCache: options.transformCache,
|
||||||
transformModulePath: options.transformModulePath,
|
transformModulePath:
|
||||||
|
options.transformModulePath || defaults.transformModulePath,
|
||||||
watch: options.watch || false,
|
watch: options.watch || false,
|
||||||
workerPath: options.workerPath,
|
workerPath: options.workerPath,
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2015-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.
|
||||||
|
*
|
||||||
|
* @flow
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.transform = (file: {src: string}) => ({code: file.src});
|
|
@ -29,6 +29,8 @@ exports.providesModuleNodeModules = [
|
||||||
'react-native-windows',
|
'react-native-windows',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
exports.transformModulePath = require.resolve('./defaultTransform.js');
|
||||||
|
|
||||||
exports.runBeforeMainModule = [
|
exports.runBeforeMainModule = [
|
||||||
// Ensures essential globals are available and are patched correctly.
|
// Ensures essential globals are available and are patched correctly.
|
||||||
'InitializeCore',
|
'InitializeCore',
|
||||||
|
|
Loading…
Reference in New Issue