-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't minify symbols in production builds (#28881)
This disables symbol renaming in production builds. The original variable and function names are preserved. All other forms of compression applied by Closure (dead code elimination, inlining, etc) are unchanged — the final program is identical to what we were producing before, just in a more readable form. The motivation is to make it easier to debug React issues that only occur in production — the same reason we decided to start shipping sourcemaps in #28827 and #28827. However, because most apps run their own minification step on their npm dependencies, it's not necessary for us to minify the symbols before publishing — it'll be handled the app, if desired. This is the same strategy Meta has used to ship React for years. The React build itself has unminified symbols, but they get minified as part of Meta's regular build pipeline. Even if an app does not minify their npm dependencies, gzip covers most of the cost of symbol renaming anyway. This saves us from having to ship sourcemaps, which means even apps that don't have sourcemaps configured will be able to debug the React build as easily as they would any other npm dependency. DiffTrain build for [857ee8c](857ee8c)
- Loading branch information
Showing
2 changed files
with
236 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ea26e38e33bffeba1ecc42688d7e8cd7e0da1c02 | ||
857ee8cdf9af81bc94a7f04528fbda7fb2510eb4 |
236 changes: 235 additions & 1 deletion
236
compiled/facebook-www/unstable_server-external-runtime.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,235 @@ | ||
(function(){function e(e,t,n){t=document.getElementById(t);t.parentNode.removeChild(t);var r=document.getElementById(e);if(r){e=r.previousSibling;if(n)e.data="$!",r.setAttribute("data-dgst",n);else{n=e.parentNode;r=e.nextSibling;var i=0;do{if(r&&8===r.nodeType){var d=r.data;if("/$"===d)if(0===i)break;else i--;else"$"!==d&&"$?"!==d&&"$!"!==d||i++}d=r.nextSibling;n.removeChild(r);r=d}while(r);for(;t.firstChild;)n.insertBefore(t.firstChild,r);e.data="$"}e._reactRetry&&e._reactRetry()}}function t(t,n,r){for(var i=new Map,o=document,a,l,c=o.querySelectorAll("link[data-precedence],style[data-precedence]"),s=[],u=0;l=c[u++];)"not all"===l.getAttribute("media")?s.push(l):("LINK"===l.tagName&&d.set(l.getAttribute("href"),l),i.set(l.dataset.precedence,a=l));l=0;c=[];var m,f;for(u=!0;;){if(u){var v=r[l++];if(!v){u=!1;l=0;continue}var p=!1,b=0;var g=v[b++];if(f=d.get(g)){var h=f._p;p=!0}else{f=o.createElement("link");f.href=g;f.rel="stylesheet";for(f.dataset.precedence=m=v[b++];h=v[b++];)f.setAttribute(h,v[b++]);h=f._p=new Promise((function(e,t){f.onload=e;f.onerror=t}));d.set(g,f)}g=f.getAttribute("media");!h||"l"===h.s||g&&!window.matchMedia(g).matches||c.push(h);if(p)continue}else{f=s[l++];if(!f)break;m=f.getAttribute("data-precedence");f.removeAttribute("media")}p=i.get(m)||a;p===a&&(a=f);i.set(m,f);p?p.parentNode.insertBefore(f,p.nextSibling):(p=o.head,p.insertBefore(f,p.firstChild))}Promise.all(c).then(e.bind(null,t,n,""),e.bind(null,t,n,"Resource failed to load"))}function n(e){e=e.querySelectorAll("template");for(var t=0;t<e.length;t++)i(e[t])}function r(e){function t(e){for(var t=0;t<e.length;t++)for(var n=e[t].addedNodes,r=0;r<n.length;r++)n[r].parentNode&&i(n[r])}var n=new MutationObserver(t);n.observe(e,{childList:!0});window.addEventListener("DOMContentLoaded",(function(){t(n.takeRecords());n.disconnect()}))}function i(n){if(1===n.nodeType&&n.dataset){var r=n.dataset;if(null!=r.rxi){var i=r.dgst,d=r.msg,o=r.stck,a=r.cstck,l=document.getElementById(r.bid);l&&(r=l.previousSibling,r.data="$!",l=l.dataset,i&&(l.dgst=i),d&&(l.msg=d),o&&(l.stck=o),a&&(l.cstck=a),r._reactRetry&&r._reactRetry());n.remove()}else if(null!=r.rri)t(r.bid,r.sid,JSON.parse(r.sty)),n.remove();else if(null!=r.rci)e(r.bid,r.sid),n.remove();else if(null!=r.rsi){i=r.pid;d=document.getElementById(r.sid);i=document.getElementById(i);for(d.parentNode.removeChild(d);d.firstChild;)i.parentNode.insertBefore(d.firstChild,i);i.parentNode.removeChild(i);n.remove()}}}var d=new Map;(function(){addEventListener("submit",(function(e){if(!e.defaultPrevented){var t=e.target,n=e.submitter,r=t.action,i=n;if(n){var d=n.getAttribute("formAction");null!=d&&(r=d,i=null)}"javascript:throw new Error('React form unexpectedly submitted.')"===r&&(e.preventDefault(),i?(e=document.createElement("input"),e.name=i.name,e.value=i.value,i.parentNode.insertBefore(e,i),i=new FormData(t),e.parentNode.removeChild(e)):i=new FormData(t),e=t.ownerDocument||t,(e.$$reactFormReplay=e.$$reactFormReplay||[]).push(t,n,i))}}))})();window.$RC||(window.$RC=e,window.$RM=new Map);if(null!=document.body)"loading"===document.readyState&&r(document.body),n(document.body);else{var o=new MutationObserver((function(){null!=document.body&&("loading"===document.readyState&&r(document.body),n(document.body),o.disconnect())}));o.observe(document.documentElement,{childList:!0})}})(); | ||
(function () { | ||
function completeBoundary(suspenseBoundaryID, contentID, errorDigest) { | ||
contentID = document.getElementById(contentID); | ||
contentID.parentNode.removeChild(contentID); | ||
var suspenseIdNode = document.getElementById(suspenseBoundaryID); | ||
if (suspenseIdNode) { | ||
suspenseBoundaryID = suspenseIdNode.previousSibling; | ||
if (errorDigest) | ||
(suspenseBoundaryID.data = "$!"), | ||
suspenseIdNode.setAttribute("data-dgst", errorDigest); | ||
else { | ||
errorDigest = suspenseBoundaryID.parentNode; | ||
suspenseIdNode = suspenseBoundaryID.nextSibling; | ||
var depth = 0; | ||
do { | ||
if (suspenseIdNode && 8 === suspenseIdNode.nodeType) { | ||
var data = suspenseIdNode.data; | ||
if ("/$" === data) | ||
if (0 === depth) break; | ||
else depth--; | ||
else ("$" !== data && "$?" !== data && "$!" !== data) || depth++; | ||
} | ||
data = suspenseIdNode.nextSibling; | ||
errorDigest.removeChild(suspenseIdNode); | ||
suspenseIdNode = data; | ||
} while (suspenseIdNode); | ||
for (; contentID.firstChild; ) | ||
errorDigest.insertBefore(contentID.firstChild, suspenseIdNode); | ||
suspenseBoundaryID.data = "$"; | ||
} | ||
suspenseBoundaryID._reactRetry && suspenseBoundaryID._reactRetry(); | ||
} | ||
} | ||
function completeBoundaryWithStyles( | ||
suspenseBoundaryID, | ||
contentID, | ||
stylesheetDescriptors | ||
) { | ||
for ( | ||
var precedences = new Map(), | ||
thisDocument = document, | ||
lastResource, | ||
node, | ||
nodes = thisDocument.querySelectorAll( | ||
"link[data-precedence],style[data-precedence]" | ||
), | ||
styleTagsToHoist = [], | ||
i$0 = 0; | ||
(node = nodes[i$0++]); | ||
|
||
) | ||
"not all" === node.getAttribute("media") | ||
? styleTagsToHoist.push(node) | ||
: ("LINK" === node.tagName && | ||
resourceMap.set(node.getAttribute("href"), node), | ||
precedences.set(node.dataset.precedence, (lastResource = node))); | ||
node = 0; | ||
nodes = []; | ||
var precedence, resourceEl; | ||
for (i$0 = !0; ; ) { | ||
if (i$0) { | ||
var stylesheetDescriptor = stylesheetDescriptors[node++]; | ||
if (!stylesheetDescriptor) { | ||
i$0 = !1; | ||
node = 0; | ||
continue; | ||
} | ||
var avoidInsert = !1, | ||
j = 0; | ||
var href = stylesheetDescriptor[j++]; | ||
if ((resourceEl = resourceMap.get(href))) { | ||
var attr = resourceEl._p; | ||
avoidInsert = !0; | ||
} else { | ||
resourceEl = thisDocument.createElement("link"); | ||
resourceEl.href = href; | ||
resourceEl.rel = "stylesheet"; | ||
for ( | ||
resourceEl.dataset.precedence = precedence = | ||
stylesheetDescriptor[j++]; | ||
(attr = stylesheetDescriptor[j++]); | ||
|
||
) | ||
resourceEl.setAttribute(attr, stylesheetDescriptor[j++]); | ||
attr = resourceEl._p = new Promise(function (resolve, reject) { | ||
resourceEl.onload = resolve; | ||
resourceEl.onerror = reject; | ||
}); | ||
resourceMap.set(href, resourceEl); | ||
} | ||
href = resourceEl.getAttribute("media"); | ||
!attr || | ||
"l" === attr.s || | ||
(href && !window.matchMedia(href).matches) || | ||
nodes.push(attr); | ||
if (avoidInsert) continue; | ||
} else { | ||
resourceEl = styleTagsToHoist[node++]; | ||
if (!resourceEl) break; | ||
precedence = resourceEl.getAttribute("data-precedence"); | ||
resourceEl.removeAttribute("media"); | ||
} | ||
avoidInsert = precedences.get(precedence) || lastResource; | ||
avoidInsert === lastResource && (lastResource = resourceEl); | ||
precedences.set(precedence, resourceEl); | ||
avoidInsert | ||
? avoidInsert.parentNode.insertBefore( | ||
resourceEl, | ||
avoidInsert.nextSibling | ||
) | ||
: ((avoidInsert = thisDocument.head), | ||
avoidInsert.insertBefore(resourceEl, avoidInsert.firstChild)); | ||
} | ||
Promise.all(nodes).then( | ||
completeBoundary.bind(null, suspenseBoundaryID, contentID, ""), | ||
completeBoundary.bind( | ||
null, | ||
suspenseBoundaryID, | ||
contentID, | ||
"Resource failed to load" | ||
) | ||
); | ||
} | ||
function handleExistingNodes(target) { | ||
target = target.querySelectorAll("template"); | ||
for (var i = 0; i < target.length; i++) handleNode(target[i]); | ||
} | ||
function installFizzInstrObserver(target) { | ||
function handleMutations(mutations) { | ||
for (var i = 0; i < mutations.length; i++) | ||
for ( | ||
var addedNodes = mutations[i].addedNodes, j = 0; | ||
j < addedNodes.length; | ||
j++ | ||
) | ||
addedNodes[j].parentNode && handleNode(addedNodes[j]); | ||
} | ||
var fizzInstrObserver = new MutationObserver(handleMutations); | ||
fizzInstrObserver.observe(target, { childList: !0 }); | ||
window.addEventListener("DOMContentLoaded", function () { | ||
handleMutations(fizzInstrObserver.takeRecords()); | ||
fizzInstrObserver.disconnect(); | ||
}); | ||
} | ||
function handleNode(node_) { | ||
if (1 === node_.nodeType && node_.dataset) { | ||
var dataset = node_.dataset; | ||
if (null != dataset.rxi) { | ||
var errorDigest = dataset.dgst, | ||
errorMsg = dataset.msg, | ||
errorStack = dataset.stck, | ||
errorComponentStack = dataset.cstck, | ||
suspenseIdNode = document.getElementById(dataset.bid); | ||
suspenseIdNode && | ||
((dataset = suspenseIdNode.previousSibling), | ||
(dataset.data = "$!"), | ||
(suspenseIdNode = suspenseIdNode.dataset), | ||
errorDigest && (suspenseIdNode.dgst = errorDigest), | ||
errorMsg && (suspenseIdNode.msg = errorMsg), | ||
errorStack && (suspenseIdNode.stck = errorStack), | ||
errorComponentStack && (suspenseIdNode.cstck = errorComponentStack), | ||
dataset._reactRetry && dataset._reactRetry()); | ||
node_.remove(); | ||
} else if (null != dataset.rri) | ||
completeBoundaryWithStyles( | ||
dataset.bid, | ||
dataset.sid, | ||
JSON.parse(dataset.sty) | ||
), | ||
node_.remove(); | ||
else if (null != dataset.rci) | ||
completeBoundary(dataset.bid, dataset.sid), node_.remove(); | ||
else if (null != dataset.rsi) { | ||
errorDigest = dataset.pid; | ||
errorMsg = document.getElementById(dataset.sid); | ||
errorDigest = document.getElementById(errorDigest); | ||
for (errorMsg.parentNode.removeChild(errorMsg); errorMsg.firstChild; ) | ||
errorDigest.parentNode.insertBefore(errorMsg.firstChild, errorDigest); | ||
errorDigest.parentNode.removeChild(errorDigest); | ||
node_.remove(); | ||
} | ||
} | ||
} | ||
var resourceMap = new Map(); | ||
(function () { | ||
addEventListener("submit", function (event) { | ||
if (!event.defaultPrevented) { | ||
var form = event.target, | ||
submitter = event.submitter, | ||
action = form.action, | ||
formDataSubmitter = submitter; | ||
if (submitter) { | ||
var submitterAction = submitter.getAttribute("formAction"); | ||
null != submitterAction && | ||
((action = submitterAction), (formDataSubmitter = null)); | ||
} | ||
"javascript:throw new Error('React form unexpectedly submitted.')" === | ||
action && | ||
(event.preventDefault(), | ||
formDataSubmitter | ||
? ((event = document.createElement("input")), | ||
(event.name = formDataSubmitter.name), | ||
(event.value = formDataSubmitter.value), | ||
formDataSubmitter.parentNode.insertBefore( | ||
event, | ||
formDataSubmitter | ||
), | ||
(formDataSubmitter = new FormData(form)), | ||
event.parentNode.removeChild(event)) | ||
: (formDataSubmitter = new FormData(form)), | ||
(event = form.ownerDocument || form), | ||
(event.$$reactFormReplay = event.$$reactFormReplay || []).push( | ||
form, | ||
submitter, | ||
formDataSubmitter | ||
)); | ||
} | ||
}); | ||
})(); | ||
window.$RC || ((window.$RC = completeBoundary), (window.$RM = new Map())); | ||
if (null != document.body) | ||
"loading" === document.readyState && | ||
installFizzInstrObserver(document.body), | ||
handleExistingNodes(document.body); | ||
else { | ||
var domBodyObserver = new MutationObserver(function () { | ||
null != document.body && | ||
("loading" === document.readyState && | ||
installFizzInstrObserver(document.body), | ||
handleExistingNodes(document.body), | ||
domBodyObserver.disconnect()); | ||
}); | ||
domBodyObserver.observe(document.documentElement, { childList: !0 }); | ||
} | ||
})(); |