mirror of https://github.com/status-im/metro.git
metro, metro-buck: preprend NODE_ENV variable to bundles
Reviewed By: rafeca Differential Revision: D6674216 fbshipit-source-id: ca0d17f679eb8fb8dd4c50192836faaf02d1aba8
This commit is contained in:
parent
fa8e1a6ea1
commit
521653798f
|
@ -66,6 +66,7 @@ exports.createBuildSetup = (
|
|||
function prelude(optimize) {
|
||||
return virtualModule(
|
||||
`var __DEV__=${String(!optimize)},` +
|
||||
'__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now();',
|
||||
'__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now(),' +
|
||||
`process={env:{NODE_ENV:'${optimize ? 'production' : 'development'}'}};`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ describe('build setup', () => {
|
|||
file: {
|
||||
code:
|
||||
'var __DEV__=true,__BUNDLE_START_TIME__=' +
|
||||
'this.nativePerformanceNow?nativePerformanceNow():Date.now();',
|
||||
'this.nativePerformanceNow?nativePerformanceNow():Date.now(),' +
|
||||
"process={env:{NODE_ENV:'development'}};",
|
||||
map: null,
|
||||
path: '',
|
||||
type: 'script',
|
||||
|
@ -48,7 +49,8 @@ describe('build setup', () => {
|
|||
const [prelude] = result.modules;
|
||||
expect(prelude.file.code).toEqual(
|
||||
'var __DEV__=false,__BUNDLE_START_TIME__=' +
|
||||
'this.nativePerformanceNow?nativePerformanceNow():Date.now();',
|
||||
'this.nativePerformanceNow?nativePerformanceNow():Date.now(),' +
|
||||
"process={env:{NODE_ENV:'production'}};",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,3 +15,5 @@ global.__DEV__ = false;
|
|||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow
|
||||
? global.nativePerformanceNow()
|
||||
: Date.now();
|
||||
|
||||
global.process = {env: {NODE_ENV: 'production'}};
|
||||
|
|
|
@ -15,3 +15,5 @@ global.__DEV__ = true;
|
|||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow
|
||||
? global.nativePerformanceNow()
|
||||
: Date.now();
|
||||
|
||||
global.process = {env: {NODE_ENV: 'development'}};
|
||||
|
|
|
@ -4,6 +4,11 @@ exports[`basic_bundle bundles package with polyfills 1`] = `
|
|||
"(function (global) {
|
||||
global.__DEV__ = false;
|
||||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
||||
global.process = {
|
||||
env: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
@ -195,6 +200,11 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
|
|||
"(function (global) {
|
||||
global.__DEV__ = false;
|
||||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
||||
global.process = {
|
||||
env: {
|
||||
NODE_ENV: 'production'
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
|
Loading…
Reference in New Issue