e53046b9ec
Summary: After examining how React Native sets up `process.env.NODE_ENV` using `global.__DEV__` from `prelude_dev.js` or `prelude.js` by treating them like polyfills I decided to use the same approach for environment variables. I setup my own rn-project.config.js file like so: ``` const blacklist = require('react-native/packager/blacklist'); const pathJoin = require('path').join; module.exports = { getBlacklistRE: function() { return blacklist([/build\/.*/, /app\/assets\/webpack.*/]); }, polyfillModuleNames: [pathJoin(__dirname, 'globals.js')] }; ``` I ran the packaging server using: `react-native start --config=config/react-native/rn-project.config.js --reset-cache` I expected my polyfillModuleNames to be passed into the Packager properly and be handled the same way the built-in polyfills worked. Unfortunately I noticed the Packager wasn't actually getting `opt.polyfillModuleNames`. Digging into the code a bit, it seems the local-cli wasn't passing the polyfillModuleNames from the config. There are no specs for runServer.js but this change can be tested by using a config that contains polyfillModuleNames. Sample config and run command provided above simple `global.js` provided below: ``` global.process = global.process ? global.process : {}; global.process.env = global.process.env ? global.process.env : {}; global.process.env['PROJECT_ENV'] = 'staging'; ``` Closes https://github.com/facebook/react-native/pull/13725 Differential Revision: D5077615 Pulled By: jeanlauliac fbshipit-source-id: f66a8a8bda2702cd9a4e5b92f5335f43ab2f9089 |
||
---|---|---|
.. | ||
__mocks__ | ||
Config.js | ||
PackageManager.js | ||
assertRequiredOptions.js | ||
copyAndReplace.js | ||
findSymlinksPaths.js | ||
isPackagerRunning.js | ||
isValidPackageName.js | ||
log.js | ||
parseCommandLine.js | ||
walk.js | ||
yarn.js |