Skip to content

Commit dfe09d3

Browse files
committed
Support LAB debug output via process.env.DEBUG_LAB
1 parent 732499f commit dfe09d3

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/react-server/core/util/LAB.src.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
global_defaults[_AlwaysPreserveOrder] = false;
208208
global_defaults[_AllowDuplicates] = false;
209209
global_defaults[_CacheBust] = false;
210-
/*!START_DEBUG*/global_defaults[_Debug] = false;/*!END_DEBUG*/
210+
/*!START_DEBUG*/global_defaults[_Debug] = true;/*!END_DEBUG*/
211211
global_defaults[_BasePath] = "";
212212

213213
// execute a script that has been preloaded already

packages/react-server/core/util/LABString.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
var lab = require("fs").readFileSync(__dirname + "/LAB.src.js", "utf-8");
22

3-
lab = require("uglify-js").minify(lab, {fromString: true}).code;
3+
// Don't need this.
4+
lab = lab.replace(/^"use strict";/, "");
5+
6+
// Run with `DEBUG_LAB=true` to see its output in console.log.
7+
if (!process.env.DEBUG_LAB) {
8+
9+
// This is exactly what @getify does to remove debug code.
10+
// https://github.com/getify/LABjs/blob/master/BUILD.md
11+
lab = lab.replace(/\/\*!START_DEBUG(?:.|[\n\r])*?END_DEBUG\*\//g, "");
12+
13+
// After the debug code is removed just uglify.
14+
lab = require("uglify-js").minify(lab, {fromString: true}).code;
15+
}
416

517
module.exports = `
618
/*! LAB.js (LABjs :: Loading And Blocking JavaScript)

0 commit comments

Comments
 (0)