Skip to content

Commit 988709d

Browse files
authored
fix(perf): defer loading of pretty-error to improve startup time (#1789)
1 parent d5ce5a8 commit 988709d

File tree

22 files changed

+225
-182
lines changed

22 files changed

+225
-182
lines changed

examples/chunk-optimization/dist/webpack-5/219.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
"use strict";
12
(self["webpackChunk"] = self["webpackChunk"] || []).push([[219],{
23

34
/***/ 609:
45
/***/ ((module) => {
56

6-
"use strict";
77

88

99
/*
@@ -76,7 +76,6 @@ module.exports = function (cssWithMappingToString) {
7676
/***/ 62:
7777
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7878

79-
"use strict";
8079

8180

8281
var isOldIE = function isOldIE() {

examples/chunk-optimization/dist/webpack-5/965.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
"use strict";
12
(self["webpackChunk"] = self["webpackChunk"] || []).push([[965],{
23

34
/***/ 173:
45
/***/ ((module, __webpack_exports__, __webpack_require__) => {
56

6-
"use strict";
77
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
88
/* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
99
/* harmony export */ });
@@ -23,7 +23,6 @@ ___CSS_LOADER_EXPORT___.push([module.id, "body {\n background: snow;\n}", ""]);
2323
/***/ 965:
2424
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2525

26-
"use strict";
2726
__webpack_require__.r(__webpack_exports__);
2827
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2928
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
@@ -39,11 +38,11 @@ var options = {};
3938
options.insert = "head";
4039
options.singleton = false;
4140

42-
var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* .default */ .Z, options);
41+
var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z, options);
4342

4443

4544

46-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* .default.locals */ .Z.locals || {});
45+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_main_css__WEBPACK_IMPORTED_MODULE_1__/* ["default"].locals */ .Z.locals || {});
4746

4847
/***/ })
4948

examples/chunk-optimization/dist/webpack-5/entryA.js

+60-58
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ document.body.appendChild(h1);
2222
/******/ // The require function
2323
/******/ function __webpack_require__(moduleId) {
2424
/******/ // Check if module is in cache
25-
/******/ if(__webpack_module_cache__[moduleId]) {
26-
/******/ return __webpack_module_cache__[moduleId].exports;
25+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
26+
/******/ if (cachedModule !== undefined) {
27+
/******/ return cachedModule.exports;
2728
/******/ }
2829
/******/ // Create a new module (and put it into the cache)
2930
/******/ var module = __webpack_module_cache__[moduleId] = {
@@ -42,10 +43,39 @@ document.body.appendChild(h1);
4243
/******/ // expose the modules object (__webpack_modules__)
4344
/******/ __webpack_require__.m = __webpack_modules__;
4445
/******/
45-
/******/ // the startup function
46-
/******/ // It's empty as some runtime module handles the default behavior
47-
/******/ __webpack_require__.x = x => {};
4846
/************************************************************************/
47+
/******/ /* webpack/runtime/chunk loaded */
48+
/******/ (() => {
49+
/******/ var deferred = [];
50+
/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
51+
/******/ if(chunkIds) {
52+
/******/ priority = priority || 0;
53+
/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
54+
/******/ deferred[i] = [chunkIds, fn, priority];
55+
/******/ return;
56+
/******/ }
57+
/******/ var notFulfilled = Infinity;
58+
/******/ for (var i = 0; i < deferred.length; i++) {
59+
/******/ var [chunkIds, fn, priority] = deferred[i];
60+
/******/ var fulfilled = true;
61+
/******/ for (var j = 0; j < chunkIds.length; j++) {
62+
/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
63+
/******/ chunkIds.splice(j--, 1);
64+
/******/ } else {
65+
/******/ fulfilled = false;
66+
/******/ if(priority < notFulfilled) notFulfilled = priority;
67+
/******/ }
68+
/******/ }
69+
/******/ if(fulfilled) {
70+
/******/ deferred.splice(i--, 1)
71+
/******/ var r = fn();
72+
/******/ if (r !== undefined) result = r;
73+
/******/ }
74+
/******/ }
75+
/******/ return result;
76+
/******/ };
77+
/******/ })();
78+
/******/
4979
/******/ /* webpack/runtime/compat get default export */
5080
/******/ (() => {
5181
/******/ // getDefaultExport function for compatibility with non-harmony modules
@@ -92,14 +122,11 @@ document.body.appendChild(h1);
92122
/******/
93123
/******/ // object to store loaded and loading chunks
94124
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
95-
/******/ // Promise = chunk loading, 0 = chunk loaded
125+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
96126
/******/ var installedChunks = {
97127
/******/ 938: 0
98128
/******/ };
99129
/******/
100-
/******/ var deferredModules = [
101-
/******/ [727,494,491,219,965]
102-
/******/ ];
103130
/******/ // no chunk on demand loading
104131
/******/
105132
/******/ // no prefetching
@@ -110,75 +137,50 @@ document.body.appendChild(h1);
110137
/******/
111138
/******/ // no HMR manifest
112139
/******/
113-
/******/ var checkDeferredModules = x => {};
140+
/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
114141
/******/
115142
/******/ // install a JSONP callback for chunk loading
116143
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
117-
/******/ var [chunkIds, moreModules, runtime, executeModules] = data;
144+
/******/ var [chunkIds, moreModules, runtime] = data;
118145
/******/ // add "moreModules" to the modules object,
119146
/******/ // then flag all "chunkIds" as loaded and fire callback
120-
/******/ var moduleId, chunkId, i = 0, resolves = [];
147+
/******/ var moduleId, chunkId, i = 0;
148+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
149+
/******/ for(moduleId in moreModules) {
150+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
151+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
152+
/******/ }
153+
/******/ }
154+
/******/ if(runtime) var result = runtime(__webpack_require__);
155+
/******/ }
156+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
121157
/******/ for(;i < chunkIds.length; i++) {
122158
/******/ chunkId = chunkIds[i];
123159
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
124-
/******/ resolves.push(installedChunks[chunkId][0]);
160+
/******/ installedChunks[chunkId][0]();
125161
/******/ }
126162
/******/ installedChunks[chunkId] = 0;
127163
/******/ }
128-
/******/ for(moduleId in moreModules) {
129-
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
130-
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
131-
/******/ }
132-
/******/ }
133-
/******/ if(runtime) runtime(__webpack_require__);
134-
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
135-
/******/ while(resolves.length) {
136-
/******/ resolves.shift()();
137-
/******/ }
138-
/******/
139-
/******/ // add entry modules from loaded chunk to deferred list
140-
/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules);
141-
/******/
142-
/******/ // run deferred modules when all chunks ready
143-
/******/ return checkDeferredModules();
164+
/******/ return __webpack_require__.O(result);
144165
/******/ }
145166
/******/
146167
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
147168
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
148169
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
149-
/******/
150-
/******/ function checkDeferredModulesImpl() {
151-
/******/ var result;
152-
/******/ for(var i = 0; i < deferredModules.length; i++) {
153-
/******/ var deferredModule = deferredModules[i];
154-
/******/ var fulfilled = true;
155-
/******/ for(var j = 1; j < deferredModule.length; j++) {
156-
/******/ var depId = deferredModule[j];
157-
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
158-
/******/ }
159-
/******/ if(fulfilled) {
160-
/******/ deferredModules.splice(i--, 1);
161-
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
162-
/******/ }
163-
/******/ }
164-
/******/ if(deferredModules.length === 0) {
165-
/******/ __webpack_require__.x();
166-
/******/ __webpack_require__.x = x => {};
167-
/******/ }
168-
/******/ return result;
169-
/******/ }
170-
/******/ var startup = __webpack_require__.x;
171-
/******/ __webpack_require__.x = () => {
172-
/******/ // reset startup function so it can be called again when more startup code is added
173-
/******/ __webpack_require__.x = startup || (x => {});
174-
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
175-
/******/ };
170+
/******/ })();
171+
/******/
172+
/******/ /* webpack/runtime/nonce */
173+
/******/ (() => {
174+
/******/ __webpack_require__.nc = undefined;
176175
/******/ })();
177176
/******/
178177
/************************************************************************/
179178
/******/
180-
/******/ // run startup
181-
/******/ var __webpack_exports__ = __webpack_require__.x();
179+
/******/ // startup
180+
/******/ // Load entry module and return exports
181+
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
182+
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [494,491,219,965], () => (__webpack_require__(727)))
183+
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
182184
/******/
183185
/******/ })()
184186
;

examples/chunk-optimization/dist/webpack-5/entryB.js

+60-58
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ document.body.appendChild(h1);
2121
/******/ // The require function
2222
/******/ function __webpack_require__(moduleId) {
2323
/******/ // Check if module is in cache
24-
/******/ if(__webpack_module_cache__[moduleId]) {
25-
/******/ return __webpack_module_cache__[moduleId].exports;
24+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
25+
/******/ if (cachedModule !== undefined) {
26+
/******/ return cachedModule.exports;
2627
/******/ }
2728
/******/ // Create a new module (and put it into the cache)
2829
/******/ var module = __webpack_module_cache__[moduleId] = {
@@ -41,10 +42,39 @@ document.body.appendChild(h1);
4142
/******/ // expose the modules object (__webpack_modules__)
4243
/******/ __webpack_require__.m = __webpack_modules__;
4344
/******/
44-
/******/ // the startup function
45-
/******/ // It's empty as some runtime module handles the default behavior
46-
/******/ __webpack_require__.x = x => {};
4745
/************************************************************************/
46+
/******/ /* webpack/runtime/chunk loaded */
47+
/******/ (() => {
48+
/******/ var deferred = [];
49+
/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
50+
/******/ if(chunkIds) {
51+
/******/ priority = priority || 0;
52+
/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
53+
/******/ deferred[i] = [chunkIds, fn, priority];
54+
/******/ return;
55+
/******/ }
56+
/******/ var notFulfilled = Infinity;
57+
/******/ for (var i = 0; i < deferred.length; i++) {
58+
/******/ var [chunkIds, fn, priority] = deferred[i];
59+
/******/ var fulfilled = true;
60+
/******/ for (var j = 0; j < chunkIds.length; j++) {
61+
/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
62+
/******/ chunkIds.splice(j--, 1);
63+
/******/ } else {
64+
/******/ fulfilled = false;
65+
/******/ if(priority < notFulfilled) notFulfilled = priority;
66+
/******/ }
67+
/******/ }
68+
/******/ if(fulfilled) {
69+
/******/ deferred.splice(i--, 1)
70+
/******/ var r = fn();
71+
/******/ if (r !== undefined) result = r;
72+
/******/ }
73+
/******/ }
74+
/******/ return result;
75+
/******/ };
76+
/******/ })();
77+
/******/
4878
/******/ /* webpack/runtime/compat get default export */
4979
/******/ (() => {
5080
/******/ // getDefaultExport function for compatibility with non-harmony modules
@@ -91,14 +121,11 @@ document.body.appendChild(h1);
91121
/******/
92122
/******/ // object to store loaded and loading chunks
93123
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
94-
/******/ // Promise = chunk loading, 0 = chunk loaded
124+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
95125
/******/ var installedChunks = {
96126
/******/ 513: 0
97127
/******/ };
98128
/******/
99-
/******/ var deferredModules = [
100-
/******/ [282,494,219,965]
101-
/******/ ];
102129
/******/ // no chunk on demand loading
103130
/******/
104131
/******/ // no prefetching
@@ -109,75 +136,50 @@ document.body.appendChild(h1);
109136
/******/
110137
/******/ // no HMR manifest
111138
/******/
112-
/******/ var checkDeferredModules = x => {};
139+
/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
113140
/******/
114141
/******/ // install a JSONP callback for chunk loading
115142
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
116-
/******/ var [chunkIds, moreModules, runtime, executeModules] = data;
143+
/******/ var [chunkIds, moreModules, runtime] = data;
117144
/******/ // add "moreModules" to the modules object,
118145
/******/ // then flag all "chunkIds" as loaded and fire callback
119-
/******/ var moduleId, chunkId, i = 0, resolves = [];
146+
/******/ var moduleId, chunkId, i = 0;
147+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
148+
/******/ for(moduleId in moreModules) {
149+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
150+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
151+
/******/ }
152+
/******/ }
153+
/******/ if(runtime) var result = runtime(__webpack_require__);
154+
/******/ }
155+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
120156
/******/ for(;i < chunkIds.length; i++) {
121157
/******/ chunkId = chunkIds[i];
122158
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
123-
/******/ resolves.push(installedChunks[chunkId][0]);
159+
/******/ installedChunks[chunkId][0]();
124160
/******/ }
125161
/******/ installedChunks[chunkId] = 0;
126162
/******/ }
127-
/******/ for(moduleId in moreModules) {
128-
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
129-
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
130-
/******/ }
131-
/******/ }
132-
/******/ if(runtime) runtime(__webpack_require__);
133-
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
134-
/******/ while(resolves.length) {
135-
/******/ resolves.shift()();
136-
/******/ }
137-
/******/
138-
/******/ // add entry modules from loaded chunk to deferred list
139-
/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules);
140-
/******/
141-
/******/ // run deferred modules when all chunks ready
142-
/******/ return checkDeferredModules();
163+
/******/ return __webpack_require__.O(result);
143164
/******/ }
144165
/******/
145166
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
146167
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
147168
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
148-
/******/
149-
/******/ function checkDeferredModulesImpl() {
150-
/******/ var result;
151-
/******/ for(var i = 0; i < deferredModules.length; i++) {
152-
/******/ var deferredModule = deferredModules[i];
153-
/******/ var fulfilled = true;
154-
/******/ for(var j = 1; j < deferredModule.length; j++) {
155-
/******/ var depId = deferredModule[j];
156-
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
157-
/******/ }
158-
/******/ if(fulfilled) {
159-
/******/ deferredModules.splice(i--, 1);
160-
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
161-
/******/ }
162-
/******/ }
163-
/******/ if(deferredModules.length === 0) {
164-
/******/ __webpack_require__.x();
165-
/******/ __webpack_require__.x = x => {};
166-
/******/ }
167-
/******/ return result;
168-
/******/ }
169-
/******/ var startup = __webpack_require__.x;
170-
/******/ __webpack_require__.x = () => {
171-
/******/ // reset startup function so it can be called again when more startup code is added
172-
/******/ __webpack_require__.x = startup || (x => {});
173-
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
174-
/******/ };
169+
/******/ })();
170+
/******/
171+
/******/ /* webpack/runtime/nonce */
172+
/******/ (() => {
173+
/******/ __webpack_require__.nc = undefined;
175174
/******/ })();
176175
/******/
177176
/************************************************************************/
178177
/******/
179-
/******/ // run startup
180-
/******/ var __webpack_exports__ = __webpack_require__.x();
178+
/******/ // startup
179+
/******/ // Load entry module and return exports
180+
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
181+
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [494,219,965], () => (__webpack_require__(282)))
182+
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
181183
/******/
182184
/******/ })()
183185
;

0 commit comments

Comments
 (0)