Skip to content

Commit 378163a

Browse files
committed
moved non-harmony default import function into runtime
webpack#2451
1 parent 706c76c commit 378163a

20 files changed

Lines changed: 333 additions & 212 deletions

File tree

examples/harmony/README.md

Lines changed: 90 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function increment(val) {
5353

5454
/******/ // objects to store loaded and loading chunks
5555
/******/ var installedChunks = {
56-
/******/ 0: 0
56+
/******/ 1: 0
5757
/******/ };
5858

5959
/******/ // The require function
@@ -128,14 +128,35 @@ export function increment(val) {
128128
/******/ // identity function for calling harmory imports with the correct context
129129
/******/ __webpack_require__.i = function(value) { return value; };
130130

131+
/******/ // define getter function for harmory exports
132+
/******/ __webpack_require__.d = function(exports, name, getter) {
133+
/******/ Object.defineProperty(exports, name, {
134+
/******/ configurable: false,
135+
/******/ enumerable: true,
136+
/******/ get: getter
137+
/******/ });
138+
/******/ };
139+
140+
/******/ // getDefaultExport function for compatibility with non-harmony modules
141+
/******/ __webpack_require__.n = function(module) {
142+
/******/ var getter = module && module.__esModule ?
143+
/******/ function getDefault() { return module['default']; } :
144+
/******/ function getModuleExports() { return module; };
145+
/******/ __webpack_require__.d(getter, 'a', getter);
146+
/******/ return getter;
147+
/******/ };
148+
149+
/******/ // Object.prototype.hasOwnProperty.call
150+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
151+
131152
/******/ // __webpack_public_path__
132153
/******/ __webpack_require__.p = "js/";
133154

134155
/******/ // on error function for async loading
135156
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
136157

137158
/******/ // Load entry module and return exports
138-
/******/ return __webpack_require__(__webpack_require__.s = 2);
159+
/******/ return __webpack_require__(__webpack_require__.s = 3);
139160
/******/ })
140161
/************************************************************************/
141162
/******/ ([
@@ -145,49 +166,49 @@ export function increment(val) {
145166
\**********************/
146167
/***/ function(module, exports, __webpack_require__) {
147168

148-
"use strict";
149-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(/*! ./math */ 3);
150-
/* harmony export */ exports["a"] = increment;
151-
function increment(val) {
152-
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* add */])(val, 1);
153-
};
169+
"use strict";
170+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(/*! ./math */ 2);
171+
/* harmony export */ exports["a"] = increment;
172+
function increment(val) {
173+
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* add */])(val, 1);
174+
};
154175

155176

156177
/***/ },
157178
/* 1 */,
158179
/* 2 */
159-
/*!********************!*\
160-
!*** ./example.js ***!
161-
\********************/
180+
/*!*****************!*\
181+
!*** ./math.js ***!
182+
\*****************/
162183
/***/ function(module, exports, __webpack_require__) {
163184

164-
"use strict";
165-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__increment__ = __webpack_require__(/*! ./increment */ 0);
166-
167-
var a = 1;
168-
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__increment__["a" /* increment */])(a); // 2
169-
170-
// async loading
171-
__webpack_require__.e/* System.import */(1).then(__webpack_require__.bind(null, /*! ./async-loaded */ 1)).then(function(asyncLoaded) {
172-
console.log(asyncLoaded);
173-
});
185+
"use strict";
186+
/* harmony export */ exports["a"] = add;function add() {
187+
var sum = 0, i = 0, args = arguments, l = args.length;
188+
while (i < l) {
189+
sum += args[i++];
190+
}
191+
return sum;
192+
}
174193

175194

176195
/***/ },
177196
/* 3 */
178-
/*!*****************!*\
179-
!*** ./math.js ***!
180-
\*****************/
197+
/*!********************!*\
198+
!*** ./example.js ***!
199+
\********************/
181200
/***/ function(module, exports, __webpack_require__) {
182201

183-
"use strict";
184-
/* harmony export */ exports["a"] = add;function add() {
185-
var sum = 0, i = 0, args = arguments, l = args.length;
186-
while (i < l) {
187-
sum += args[i++];
188-
}
189-
return sum;
190-
}
202+
"use strict";
203+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__increment__ = __webpack_require__(/*! ./increment */ 0);
204+
205+
var a = 1;
206+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__increment__["a" /* increment */])(a); // 2
207+
208+
// async loading
209+
__webpack_require__.e/* System.import */(0).then(__webpack_require__.bind(null, /*! ./async-loaded */ 1)).then(function(asyncLoaded) {
210+
console.log(asyncLoaded);
211+
});
191212

192213

193214
/***/ }
@@ -199,43 +220,49 @@ export function increment(val) {
199220
## Uncompressed
200221

201222
```
202-
Hash: 7c0c96380daef3d0f428
203-
Version: webpack 2.1.0-beta.11
204-
Time: 66ms
223+
Hash: b0a43c6029aaacb5e196
224+
Version: webpack 2.1.0-beta.19
225+
Time: 69ms
205226
Asset Size Chunks Chunk Names
206-
output.js 5.74 kB 0 [emitted] main
207-
1.js 372 bytes 1 [emitted]
208-
chunk {0} output.js (main) 426 bytes [rendered]
209-
> main [2] ./example.js
210-
[0] ./increment.js 94 bytes {0} [built]
211-
harmony import ./increment [2] ./example.js 1:0-47
212-
[2] ./example.js 190 bytes {0} [built]
213-
[3] ./math.js 142 bytes {0} [built]
227+
0.js 323 bytes 0 [emitted]
228+
output.js 6.6 kB 1 [emitted] main
229+
Entrypoint main = output.js
230+
chunk {0} 0.js 25 bytes {1} [rendered]
231+
> [3] ./example.js 6:0-31
232+
[1] ./async-loaded.js 25 bytes {0} [built]
233+
System.import ./async-loaded [3] ./example.js 6:0-31
234+
chunk {1} output.js (main) 426 bytes [entry] [rendered]
235+
> main [3] ./example.js
236+
[0] ./increment.js 94 bytes {1} [built]
237+
[only some exports used: increment]
238+
harmony import ./increment [3] ./example.js 1:0-47
239+
[2] ./math.js 142 bytes {1} [built]
240+
[only some exports used: add]
214241
harmony import ./math [0] ./increment.js 1:0-29
215-
chunk {1} 1.js 25 bytes {0} [rendered]
216-
> [2] ./example.js 6:0-31
217-
[1] ./async-loaded.js 25 bytes {1} [built]
218-
System.import ./async-loaded [2] ./example.js 6:0-31
242+
[3] ./example.js 190 bytes {1} [built]
219243
```
220244

221245
## Minimized (uglify-js, no zip)
222246

223247
```
224-
Hash: 7c0c96380daef3d0f428
225-
Version: webpack 2.1.0-beta.11
226-
Time: 159ms
227-
Asset Size Chunks Chunk Names
228-
output.js 1.34 kB 0 [emitted] main
229-
1.js 151 bytes 1 [emitted]
230-
chunk {0} output.js (main) 426 bytes [rendered]
231-
> main [2] ./example.js
232-
[0] ./increment.js 94 bytes {0} [built]
233-
harmony import ./increment [2] ./example.js 1:0-47
234-
[2] ./example.js 190 bytes {0} [built]
235-
[3] ./math.js 142 bytes {0} [built]
248+
Hash: b0a43c6029aaacb5e196
249+
Version: webpack 2.1.0-beta.19
250+
Time: 138ms
251+
Asset Size Chunks Chunk Names
252+
0.js 97 bytes 0 [emitted]
253+
output.js 1.6 kB 1 [emitted] main
254+
Entrypoint main = output.js
255+
chunk {0} 0.js 25 bytes {1} [rendered]
256+
> [3] ./example.js 6:0-31
257+
[1] ./async-loaded.js 25 bytes {0} [built]
258+
System.import ./async-loaded [3] ./example.js 6:0-31
259+
chunk {1} output.js (main) 426 bytes [entry] [rendered]
260+
> main [3] ./example.js
261+
[0] ./increment.js 94 bytes {1} [built]
262+
[only some exports used: increment]
263+
harmony import ./increment [3] ./example.js 1:0-47
264+
[2] ./math.js 142 bytes {1} [built]
265+
[only some exports used: add]
236266
harmony import ./math [0] ./increment.js 1:0-29
237-
chunk {1} 1.js 25 bytes {0} [rendered]
238-
> [2] ./example.js 6:0-31
239-
[1] ./async-loaded.js 25 bytes {1} [built]
240-
System.import ./async-loaded [2] ./example.js 6:0-31
267+
[3] ./example.js 190 bytes {1} [built]
241268
```

0 commit comments

Comments
 (0)