Skip to content

Commit e4bb4d5

Browse files
committed
updated example
1 parent 180f5e5 commit e4bb4d5

2 files changed

Lines changed: 46 additions & 43 deletions

File tree

‎examples/code-splitting-specify-chunk-name/README.md‎

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
This example illustrates how to specify chunk name in `require.ensure()` and `import()` to separated modules into separate chunks manually.
44

55
``` javascript
6-
import("./templates/foo" /* webpackChunkName = "chunk-foo" */ ).then(function(foo) {
7-
console.log('foo:', foo);
6+
import("./templates/foo" /* webpackChunkName: "chunk-foo" */ ).then(function(foo) {
7+
console.log('foo:', foo);
88
})
99

1010
require.ensure([], function(require) {
11-
var foo = require("./templates/foo");
12-
console.log('foo:', foo);
11+
var foo = require("./templates/foo");
12+
console.log('foo:', foo);
1313
}, "chunk-foo1");
1414

1515
var createContextVar = "r";
16-
import("./templates/ba" + createContextVar /* webpackChunkName = "chunk-bar-baz" */ ).then(function(bar) {
17-
console.log('bar:', bar);
16+
import("./templates/ba" + createContextVar /* webpackChunkName: "chunk-bar-baz" */ ).then(function(bar) {
17+
console.log('bar:', bar);
1818
})
1919
```
2020

@@ -34,7 +34,8 @@ export default foo;
3434

3535
# js/output.js
3636

37-
<details><summary>`/******/ (function(modules) { /* webpackBootstrap */ })`</summary>
37+
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
38+
3839
``` javascript
3940
/******/ (function(modules) { // webpackBootstrap
4041
/******/ // install a JSONP callback for chunk loading
@@ -181,7 +182,9 @@ export default foo;
181182
/******/ })
182183
/************************************************************************/
183184
```
185+
184186
</details>
187+
185188
``` javascript
186189
/******/ ([
187190
/* 0 */,
@@ -237,17 +240,17 @@ webpackAsyncContext.id = 1;
237240
/***/ (function(module, exports, __webpack_require__) {
238241

239242
__webpack_require__.e/* import() */(1/*! chunk-foo */).then(__webpack_require__.bind(null, /*! ./templates/foo */ 0)).then(function(foo) {
240-
console.log('foo:', foo);
243+
console.log('foo:', foo);
241244
})
242245

243246
__webpack_require__.e/* require.ensure */(1/*! chunk-foo1 *//* duplicate */).then((function(require) {
244-
var foo = __webpack_require__(/*! ./templates/foo */ 0);
245-
console.log('foo:', foo);
247+
var foo = __webpack_require__(/*! ./templates/foo */ 0);
248+
console.log('foo:', foo);
246249
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
247250

248251
var createContextVar = "r";
249252
__webpack_require__(/*! ./templates */ 1)("./ba" + createContextVar).then(function(bar) {
250-
console.log('bar:', bar);
253+
console.log('bar:', bar);
251254
})
252255

253256

@@ -262,65 +265,65 @@ __webpack_require__(/*! ./templates */ 1)("./ba" + createContextVar).then(functi
262265
## Uncompressed
263266

264267
```
265-
Hash: d0f458846155660cd0f3
266-
Version: webpack 2.3.2
268+
Hash: 6c765b06647a6b15d61a
269+
Version: webpack 2.3.3
267270
Asset Size Chunks Chunk Names
268-
0.output.js 869 bytes 0 [emitted] chunk-bar-baz
269-
1.output.js 436 bytes 1 [emitted] chunk-foo
270-
output.js 7.28 kB 2 [emitted] main
271+
0.output.js 875 bytes 0 [emitted] chunk-bar-baz
272+
1.output.js 439 bytes 1 [emitted] chunk-foo
273+
output.js 7.29 kB 2 [emitted] main
271274
Entrypoint main = output.js
272-
chunk {0} 0.output.js (chunk-bar-baz) 76 bytes {2} [rendered]
273-
[2] ./templates/bar.js 38 bytes {0} [optional] [built]
275+
chunk {0} 0.output.js (chunk-bar-baz) 82 bytes {2} [rendered]
276+
[2] ./templates/bar.js 41 bytes {0} [optional] [built]
274277
[exports: default]
275278
context element ./bar [1] ./templates async ^\.\/ba.*$ ./bar
276279
context element ./bar.js [1] ./templates async ^\.\/ba.*$ ./bar.js
277-
[3] ./templates/baz.js 38 bytes {0} [optional] [built]
280+
[3] ./templates/baz.js 41 bytes {0} [optional] [built]
278281
[exports: default]
279282
context element ./baz [1] ./templates async ^\.\/ba.*$ ./baz
280283
context element ./baz.js [1] ./templates async ^\.\/ba.*$ ./baz.js
281-
chunk {1} 1.output.js (chunk-foo) 38 bytes {2} [rendered]
282-
> duplicate chunk-foo [4] ./example.js 1:0-63
284+
chunk {1} 1.output.js (chunk-foo) 41 bytes {2} [rendered]
285+
> duplicate chunk-foo [4] ./example.js 1:0-62
283286
> duplicate chunk-foo1 [4] ./example.js 5:0-8:16
284-
[0] ./templates/foo.js 38 bytes {1} [built]
287+
[0] ./templates/foo.js 41 bytes {1} [built]
285288
[exports: default]
286-
import() ./templates/foo [4] ./example.js 1:0-63
287-
cjs require ./templates/foo [4] ./example.js 6:12-38
288-
chunk {2} output.js (main) 571 bytes [entry] [rendered]
289+
import() ./templates/foo [4] ./example.js 1:0-62
290+
cjs require ./templates/foo [4] ./example.js 6:11-37
291+
chunk {2} output.js (main) 580 bytes [entry] [rendered]
289292
> main [4] ./example.js
290293
[1] ./templates async ^\.\/ba.*$ 160 bytes {2} [built]
291-
import() context ./templates [4] ./example.js 11:0-85
292-
[4] ./example.js 411 bytes {2} [built]
294+
import() context ./templates [4] ./example.js 11:0-84
295+
[4] ./example.js 420 bytes {2} [built]
293296
```
294297

295298
## Minimized (uglify-js, no zip)
296299

297300
```
298-
Hash: d0f458846155660cd0f3
299-
Version: webpack 2.3.2
301+
Hash: 6c765b06647a6b15d61a
302+
Version: webpack 2.3.3
300303
Asset Size Chunks Chunk Names
301304
0.output.js 212 bytes 0 [emitted] chunk-bar-baz
302305
1.output.js 115 bytes 1 [emitted] chunk-foo
303-
output.js 1.84 kB 2 [emitted] main
306+
output.js 1.85 kB 2 [emitted] main
304307
Entrypoint main = output.js
305-
chunk {0} 0.output.js (chunk-bar-baz) 76 bytes {2} [rendered]
306-
[2] ./templates/bar.js 38 bytes {0} [optional] [built]
308+
chunk {0} 0.output.js (chunk-bar-baz) 82 bytes {2} [rendered]
309+
[2] ./templates/bar.js 41 bytes {0} [optional] [built]
307310
[exports: default]
308311
context element ./bar [1] ./templates async ^\.\/ba.*$ ./bar
309312
context element ./bar.js [1] ./templates async ^\.\/ba.*$ ./bar.js
310-
[3] ./templates/baz.js 38 bytes {0} [optional] [built]
313+
[3] ./templates/baz.js 41 bytes {0} [optional] [built]
311314
[exports: default]
312315
context element ./baz [1] ./templates async ^\.\/ba.*$ ./baz
313316
context element ./baz.js [1] ./templates async ^\.\/ba.*$ ./baz.js
314-
chunk {1} 1.output.js (chunk-foo) 38 bytes {2} [rendered]
315-
> duplicate chunk-foo [4] ./example.js 1:0-63
317+
chunk {1} 1.output.js (chunk-foo) 41 bytes {2} [rendered]
318+
> duplicate chunk-foo [4] ./example.js 1:0-62
316319
> duplicate chunk-foo1 [4] ./example.js 5:0-8:16
317-
[0] ./templates/foo.js 38 bytes {1} [built]
320+
[0] ./templates/foo.js 41 bytes {1} [built]
318321
[exports: default]
319-
import() ./templates/foo [4] ./example.js 1:0-63
320-
cjs require ./templates/foo [4] ./example.js 6:12-38
321-
chunk {2} output.js (main) 571 bytes [entry] [rendered]
322+
import() ./templates/foo [4] ./example.js 1:0-62
323+
cjs require ./templates/foo [4] ./example.js 6:11-37
324+
chunk {2} output.js (main) 580 bytes [entry] [rendered]
322325
> main [4] ./example.js
323326
[1] ./templates async ^\.\/ba.*$ 160 bytes {2} [built]
324-
import() context ./templates [4] ./example.js 11:0-85
325-
[4] ./example.js 411 bytes {2} [built]
327+
import() context ./templates [4] ./example.js 11:0-84
328+
[4] ./example.js 420 bytes {2} [built]
326329
```

‎examples/code-splitting-specify-chunk-name/example.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import("./templates/foo" /* webpackChunkName = "chunk-foo" */ ).then(function(foo) {
1+
import("./templates/foo" /* webpackChunkName: "chunk-foo" */ ).then(function(foo) {
22
console.log('foo:', foo);
33
})
44

@@ -8,7 +8,7 @@ require.ensure([], function(require) {
88
}, "chunk-foo1");
99

1010
var createContextVar = "r";
11-
import("./templates/ba" + createContextVar /* webpackChunkName = "chunk-bar-baz" */ ).then(function(bar) {
11+
import("./templates/ba" + createContextVar /* webpackChunkName: "chunk-bar-baz" */ ).then(function(bar) {
1212
console.log('bar:', bar);
1313
})
1414

0 commit comments

Comments
 (0)