Unverified Commit bb869bc0 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1019 from hypothesis/envify

Enable conditional inclusion of code based on NODE_ENV checks
parents 90bcfb11 f5d81fd0
......@@ -77,6 +77,7 @@
"katex": "^0.10.0",
"lodash.debounce": "^4.0.3",
"lodash.get": "^4.3.0",
"loose-envify": "^1.4.0",
"mkdirp": "^0.5.1",
"mocha": "^6.0.0",
"ng-tags-input": "^3.1.1",
......
......@@ -10,6 +10,7 @@ const babelify = require('babelify');
const browserify = require('browserify');
const coffeeify = require('coffeeify');
const exorcist = require('exorcist');
const envify = require('loose-envify/custom');
const gulpUtil = require('gulp-util');
const mkdirp = require('mkdirp');
const through = require('through2');
......@@ -225,6 +226,16 @@ module.exports = function createBundle(config, buildOpts) {
bundle.transform({global: true}, uglifyify);
}
// Include or disable debugging checks in our code and dependencies by
// replacing references to `process.env.NODE_ENV`.
bundle.transform(envify({
NODE_ENV: process.env.NODE_ENV || 'development',
}), {
// Ideally packages should configure this transform in their package.json
// file if they need it, but not all of them do.
global: true,
});
function build() {
const output = fs.createWriteStream(bundlePath);
const b = bundle.bundle();
......
......@@ -3,6 +3,7 @@
/* global __dirname */
const path = require('path');
const envify = require('loose-envify/custom');
module.exports = function(config) {
config.set({
......@@ -94,6 +95,8 @@ module.exports = function(config) {
],
},
],
// Enable debugging checks in libraries that use `NODE_ENV` guards.
[envify({ NODE_ENV: 'development' }), { global: true }],
],
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment