mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 12:15:37 +08:00
getTransformOptionsModulePath
Summary: Passing around a `getTransformOptions` function doesn't really work with the CLI utils, so I'm changing this to `getTransformOptionsModulePath` instead, which can easily be injected in through `rn-cli.config.js`. public Reviewed By: martinbigio Differential Revision: D2785789 fb-gh-sync-id: c9fdc358cb5d0db27e0d02496e44c013c77f3d5f
This commit is contained in:
committed by
facebook-github-bot-5
parent
893a54d0cd
commit
7035fbc58d
@@ -81,7 +81,6 @@ describe('Bundler', function() {
|
||||
bundler = new Bundler({
|
||||
projectRoots: ['/root'],
|
||||
assetServer: assetServer,
|
||||
getTransformOptions: () => ({}),
|
||||
});
|
||||
|
||||
modules = [
|
||||
|
||||
7
packager/react-packager/src/Bundler/index.js
vendored
7
packager/react-packager/src/Bundler/index.js
vendored
@@ -136,7 +136,9 @@ class Bundler {
|
||||
this._projectRoots = opts.projectRoots;
|
||||
this._assetServer = opts.assetServer;
|
||||
|
||||
this._getTransformOptions = opts.getTransformOptions;
|
||||
if (opts.getTransformOptionsModulePath) {
|
||||
this._getTransformOptions = require(opts.getTransformOptionsModulePath);
|
||||
}
|
||||
}
|
||||
|
||||
kill() {
|
||||
@@ -325,7 +327,8 @@ class Bundler {
|
||||
} else {
|
||||
return this._transformer.loadFileAndTransform(
|
||||
path.resolve(module.path),
|
||||
this._getTransformOptions({bundle, module, platform})
|
||||
this._getTransformOptions ?
|
||||
this._getTransformOptions({bundle, module, platform}) : {}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
6
packager/react-packager/src/Server/index.js
vendored
6
packager/react-packager/src/Server/index.js
vendored
@@ -64,9 +64,9 @@ const validateOpts = declareOpts({
|
||||
type: 'number',
|
||||
required: false,
|
||||
},
|
||||
getTransformOptions: {
|
||||
type: 'function',
|
||||
default: () => ({}),
|
||||
getTransformOptionsModulePath: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user