Sync with Resolver/polyfills/require.js

Summary:
I don't know which version is better, but it should sync with `Resolver/polyfills/require.js: 168`
```js
    // keep args in sync with with defineModuleCode in
    // packager/react-packager/src/Resolver/index.js
    // and packager/react-packager/src/ModuleGraph/worker.js
    factory(global, require, moduleObject, exports, dependencyMap);
```
Closes https://github.com/facebook/react-native/pull/12033

Differential Revision: D4461635

Pulled By: davidaurelio

fbshipit-source-id: 1a17e6cbac5525dc09609b658bef82a23574b00c
This commit is contained in:
Liu Zhanhong 2017-01-25 03:52:37 -08:00 committed by Facebook Github Bot
parent cbc808dc86
commit 795c1d5148
3 changed files with 6 additions and 6 deletions

View File

@ -54,7 +54,7 @@ describe('optimizing JS modules', () => {
const result = optimizeModule(transformResult, optimizationOptions);
optimized = result.transformed.default;
injectedVars = optimized.code.match(/function\(([^)]*)/)[1].split(',');
[requireName,,,, dependencyMapName] = injectedVars;
[,requireName,,, dependencyMapName] = injectedVars;
});
it('optimizes code', () => {

View File

@ -105,7 +105,7 @@ describe('transforming JS modules:', () => {
const {code, dependencyMapName} = result.transformed.default;
expect(code.replace(/\s+/g, ''))
.toEqual(
`__d(function(require,module,global,exports,${
`__d(function(global,require,module,exports,${
dependencyMapName}){${transformedCode}});`
);
done();
@ -159,12 +159,12 @@ describe('transforming JS modules:', () => {
const {dev, prod} = result.transformed;
expect(dev.code.replace(/\s+/g, ''))
.toEqual(
`__d(function(require,module,global,exports,${
`__d(function(global,require,module,exports,${
dev.dependencyMapName}){arbitrary(code);});`
);
expect(prod.code.replace(/\s+/g, ''))
.toEqual(
`__d(function(require,module,global,exports,${
`__d(function(global,require,module,exports,${
prod.dependencyMapName}){arbitrary(code);});`
);
done();
@ -178,7 +178,7 @@ describe('transforming JS modules:', () => {
const {code} = result.transformed.default;
expect(code.replace(/\s+/g, ''))
.toEqual(
'__d(function(require,module,global,exports){' +
'__d(function(global,require,module,exports){' +
`module.exports=${json}});`
);
done();

View File

@ -35,7 +35,7 @@ export type TransformOptions = {|
|};
const defaultVariants = {default: {}};
const moduleFactoryParameters = ['require', 'module', 'global', 'exports'];
const moduleFactoryParameters = ['global', 'require', 'module', 'exports'];
const polyfillFactoryParameters = ['global'];
function transformModule(