Skip assertDoc calls in production (#3268)

This commit is contained in:
Lucas Duailibe authored and GitHub committed 2017-11-16 09:54:57 -02:00
1 parent b959801d6a
commit 66d9b266e8
2 files changed
+27 -12

No files matched your search

+2 -1
View File
@@ -16,7 +16,8 @@ export default Object.assign(baseConfig, {
// with rollup the module is turned into a plain function located directly // with rollup the module is turned into a plain function located directly
// in index.js so `module.parent` does not exist. Defaulting to `module` // in index.js so `module.parent` does not exist. Defaulting to `module`
// instead seems to work. // instead seems to work.
"module.parent": "(module.parent || module)" "module.parent": "(module.parent || module)",
"process.env.NODE_ENV": JSON.stringify("production")
}), }),
json(), json(),
resolve({ preferBuiltins: true }), resolve({ preferBuiltins: true }),
+25 -11
View File
@@ -12,7 +12,9 @@ function assertDoc(val) {
} }
function concat(parts) { function concat(parts) {
parts.forEach(assertDoc); if (process.env.NODE_ENV !== "production") {
parts.forEach(assertDoc);
}
// We cannot do this until we change `printJSXElement` to not // We cannot do this until we change `printJSXElement` to not
// access the internals of a document directly. // access the internals of a document directly.
@@ -24,13 +26,17 @@ function concat(parts) {
} }
function indent(contents) { function indent(contents) {
assertDoc(contents); if (process.env.NODE_ENV !== "production") {
assertDoc(contents);
}
return { type: "indent", contents }; return { type: "indent", contents };
} }
function align(n, contents) { function align(n, contents) {
assertDoc(contents); if (process.env.NODE_ENV !== "production") {
assertDoc(contents);
}
return { type: "align", contents, n }; return { type: "align", contents, n };
} }
@@ -38,7 +44,9 @@ function align(n, contents) {
function group(contents, opts) { function group(contents, opts) {
opts = opts || {}; opts = opts || {};
assertDoc(contents); if (process.env.NODE_ENV !== "production") {
assertDoc(contents);
}
return { return {
type: "group", type: "group",
@@ -56,24 +64,30 @@ function conditionalGroup(states, opts) {
} }
function fill(parts) { function fill(parts) {
parts.forEach(assertDoc); if (process.env.NODE_ENV !== "production") {
parts.forEach(assertDoc);
}
return { type: "fill", parts }; return { type: "fill", parts };
} }
function ifBreak(breakContents, flatContents) { function ifBreak(breakContents, flatContents) {
if (breakContents) { if (process.env.NODE_ENV !== "production") {
assertDoc(breakContents); if (breakContents) {
} assertDoc(breakContents);
if (flatContents) { }
assertDoc(flatContents); if (flatContents) {
assertDoc(flatContents);
}
} }
return { type: "if-break", breakContents, flatContents }; return { type: "if-break", breakContents, flatContents };
} }
function lineSuffix(contents) { function lineSuffix(contents) {
assertDoc(contents); if (process.env.NODE_ENV !== "production") {
assertDoc(contents);
}
return { type: "line-suffix", contents }; return { type: "line-suffix", contents };
} }