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); const result = optimizeModule(transformResult, optimizationOptions);
optimized = result.transformed.default; optimized = result.transformed.default;
injectedVars = optimized.code.match(/function\(([^)]*)/)[1].split(','); injectedVars = optimized.code.match(/function\(([^)]*)/)[1].split(',');
[requireName,,,, dependencyMapName] = injectedVars; [,requireName,,, dependencyMapName] = injectedVars;
}); });
it('optimizes code', () => { it('optimizes code', () => {

View File

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

View File

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