mirror of
https://github.com/status-im/metro.git
synced 2025-02-28 02:30:29 +00:00
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) {
|
function prelude(optimize) {
|
||||||
return virtualModule(
|
return virtualModule(
|
||||||
`var __DEV__=${String(!optimize)},` +
|
`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: {
|
file: {
|
||||||
code:
|
code:
|
||||||
'var __DEV__=true,__BUNDLE_START_TIME__=' +
|
'var __DEV__=true,__BUNDLE_START_TIME__=' +
|
||||||
'this.nativePerformanceNow?nativePerformanceNow():Date.now();',
|
'this.nativePerformanceNow?nativePerformanceNow():Date.now(),' +
|
||||||
|
"process={env:{NODE_ENV:'development'}};",
|
||||||
map: null,
|
map: null,
|
||||||
path: '',
|
path: '',
|
||||||
type: 'script',
|
type: 'script',
|
||||||
@ -48,7 +49,8 @@ describe('build setup', () => {
|
|||||||
const [prelude] = result.modules;
|
const [prelude] = result.modules;
|
||||||
expect(prelude.file.code).toEqual(
|
expect(prelude.file.code).toEqual(
|
||||||
'var __DEV__=false,__BUNDLE_START_TIME__=' +
|
'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.__BUNDLE_START_TIME__ = global.nativePerformanceNow
|
||||||
? global.nativePerformanceNow()
|
? global.nativePerformanceNow()
|
||||||
: Date.now();
|
: Date.now();
|
||||||
|
|
||||||
|
global.process = {env: {NODE_ENV: 'production'}};
|
||||||
|
@ -15,3 +15,5 @@ global.__DEV__ = true;
|
|||||||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow
|
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow
|
||||||
? global.nativePerformanceNow()
|
? global.nativePerformanceNow()
|
||||||
: Date.now();
|
: Date.now();
|
||||||
|
|
||||||
|
global.process = {env: {NODE_ENV: 'development'}};
|
||||||
|
@ -4,6 +4,11 @@ exports[`basic_bundle bundles package with polyfills 1`] = `
|
|||||||
"(function (global) {
|
"(function (global) {
|
||||||
global.__DEV__ = false;
|
global.__DEV__ = false;
|
||||||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
||||||
|
global.process = {
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production'
|
||||||
|
}
|
||||||
|
};
|
||||||
})(this);
|
})(this);
|
||||||
(function (global) {
|
(function (global) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -195,6 +200,11 @@ exports[`basic_bundle bundles package without polyfills 1`] = `
|
|||||||
"(function (global) {
|
"(function (global) {
|
||||||
global.__DEV__ = false;
|
global.__DEV__ = false;
|
||||||
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
global.__BUNDLE_START_TIME__ = global.nativePerformanceNow ? global.nativePerformanceNow() : Date.now();
|
||||||
|
global.process = {
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production'
|
||||||
|
}
|
||||||
|
};
|
||||||
})(this);
|
})(this);
|
||||||
(function (global) {
|
(function (global) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user