Skip to content

Commit 0aad488

Browse files
committed
updated examples, added bundle loader example
1 parent f81c516 commit 0aad488

File tree

12 files changed

+260
-39
lines changed

12 files changed

+260
-39
lines changed

examples/buildAll.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ cp.exec("cd code-splitted-require.context && node build.js", result);
88
cp.exec("cd code-splitting && node build.js", result);
99
cp.exec("cd coffee-script && node build.js", result);
1010
cp.exec("cd loader && node build.js", result);
11-
cp.exec("cd require.context && node build.js", result);
11+
cp.exec("cd require.context && node build.js", result);
12+
cp.exec("cd code-splitting-bundle-loader && node build.js", result);

examples/code-splitted-require.context/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ Modules first chunk: 2
153153
<id> <size> <filename>
154154
<reason> from <filename>
155155
output.js
156-
0 162 .\example.js
156+
0 273 .\example.js
157157
main
158-
1 332 (webpack)\buildin\__webpack_console.js
158+
1 420 (webpack)\buildin\__webpack_console.js
159159
require (2x) from .\example.js
160160
1.output.js
161-
2 143 [context] (webpack)\examples\require.context\templates
161+
2 203 [context] (webpack)\examples\require.context\templates
162162
sync context from .\example.js
163-
3 72 (webpack)\examples\require.context\templates\a.js
163+
3 80 (webpack)\examples\require.context\templates\a.js
164164
sync context from .\example.js
165-
4 72 (webpack)\examples\require.context\templates\b.js
165+
4 80 (webpack)\examples\require.context\templates\b.js
166166
sync context from .\example.js
167-
5 72 (webpack)\examples\require.context\templates\c.js
167+
5 80 (webpack)\examples\require.context\templates\c.js
168168
sync context from .\example.js
169169
```
170170

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# example.js
2+
3+
``` javascript
4+
require("bundle!./file.js")(function(fileJsExports) {
5+
console.log(fileJsExports);
6+
});
7+
```
8+
9+
# file.js
10+
11+
``` javascript
12+
module.exports = "It works";
13+
```
14+
15+
16+
# js/output.js
17+
18+
``` javascript
19+
/******/(function(document, undefined) {
20+
/******/ return function(modules) {
21+
/******/ var installedModules = {}, installedChunks = {0:1};
22+
/******/ function require(moduleId) {
23+
/******/ if(typeof moduleId !== "number") throw new Error("Cannot find module '"+moduleId+"'");
24+
/******/ if(installedModules[moduleId])
25+
/******/ return installedModules[moduleId].exports;
26+
/******/ var module = installedModules[moduleId] = {
27+
/******/ exports: {}
28+
/******/ };
29+
/******/ modules[moduleId](module, module.exports, require);
30+
/******/ return module.exports;
31+
/******/ }
32+
/******/ require.ensure = function(chunkId, callback) {
33+
/******/ if(installedChunks[chunkId] === 1) return callback(require);
34+
/******/ if(installedChunks[chunkId] !== undefined)
35+
/******/ installedChunks[chunkId].push(callback);
36+
/******/ else {
37+
/******/ installedChunks[chunkId] = [callback];
38+
/******/ var head = document.getElementsByTagName('head')[0];
39+
/******/ var script = document.createElement('script');
40+
/******/ script.type = 'text/javascript';
41+
/******/ script.charset = 'utf-8';
42+
/******/ script.src = modules.c+chunkId+modules.a;
43+
/******/ head.appendChild(script);
44+
/******/ }
45+
/******/ };
46+
/******/ window[modules.b] = function(chunkId, moreModules) {
47+
/******/ for(var moduleId in moreModules)
48+
/******/ modules[moduleId] = moreModules[moduleId];
49+
/******/ var callbacks = installedChunks[chunkId];
50+
/******/ installedChunks[chunkId] = 1;
51+
/******/ for(var i = 0; i < callbacks.length; i++)
52+
/******/ callbacks[i](require);
53+
/******/ };
54+
/******/ return require(0);
55+
/******/ }
56+
/******/})(document)
57+
/******/({a:".output.js",b:"webpackJsonp",c:"",
58+
/******/0: function(module, exports, require) {
59+
60+
/******/ /* WEBPACK FREE VAR INJECTION */ (function(console) {
61+
require(/* bundle!./file.js */2)(function(fileJsExports) {
62+
console.log(fileJsExports);
63+
});
64+
/******/ /* WEBPACK FREE VAR INJECTION */ }(require(/* __webpack_console */1)))
65+
66+
/******/},
67+
/******/
68+
/******/1: function(module, exports, require) {
69+
70+
var console = window.console;
71+
module.exports = console;
72+
for(var name in {log:1, info:1, error:1, warn:1, dir:1, trace:1, assert:1})
73+
if(!console[name])
74+
console[name] = function() {};
75+
if(!console.time)
76+
console.time = function(label) {
77+
times[label] = Date.now();
78+
};
79+
if(!console.timeEnd)
80+
console.timeEnd = function() {
81+
var duration = Date.now() - times[label];
82+
console.log('%s: %dms', label, duration);
83+
};
84+
85+
/******/},
86+
/******/
87+
/******/2: function(module, exports, require) {
88+
89+
var cbs = [],
90+
data;
91+
module.exports = function(cb) {
92+
if(cbs) cbs.push(cb);
93+
else cb(data);
94+
}
95+
require.ensure(1, function(require) {
96+
data = require(/* !.\file.js */3);
97+
var callbacks = cbs;
98+
cbs = null;
99+
for(var i = 0, l = callbacks.length; i < l; i++) {
100+
callbacks[i](data);
101+
}
102+
});
103+
104+
/******/},
105+
/******/
106+
/******/})
107+
```
108+
109+
# js/1.output.js
110+
111+
``` javascript
112+
/******/webpackJsonp(1, {
113+
/******/3: function(module, exports, require) {
114+
115+
module.exports = "It works";
116+
117+
/******/},
118+
/******/
119+
/******/})
120+
```
121+
122+
# Info
123+
124+
## Uncompressed
125+
126+
```
127+
Hash: a5f91336d183b3a3ebd2441528b41903
128+
Chunks: 2
129+
Modules: 4
130+
Modules including duplicates: 4
131+
Modules pre chunk: 2
132+
Modules first chunk: 3
133+
output.js: 2915 characters
134+
1.output.js: 135 characters
135+
136+
<id> <size> <filename>
137+
<reason> from <filename>
138+
output.js
139+
0 91 .\example.js
140+
main
141+
1 420 (webpack)\buildin\__webpack_console.js
142+
require (1x) from .\example.js
143+
2 367 (webpack)\~\bundle-loader!.\file.js
144+
require (1x) from .\example.js
145+
1.output.js
146+
3 28 .\file.js
147+
async require (1x) from .\file.js
148+
```
149+
150+
## Minimized (uglify-js, no zip)
151+
152+
```
153+
Hash: a5f91336d183b3a3ebd2441528b41903
154+
Chunks: 2
155+
Modules: 4
156+
Modules including duplicates: 4
157+
Modules pre chunk: 2
158+
Modules first chunk: 3
159+
output.js: 1131 characters
160+
1.output.js: 57 characters
161+
162+
<id> <size> <filename>
163+
<reason> from <filename>
164+
output.js
165+
0 39 .\example.js
166+
main
167+
1 332 (webpack)\buildin\__webpack_console.js
168+
require (1x) from .\example.js
169+
2 169 (webpack)\~\bundle-loader!.\file.js
170+
require (1x) from .\example.js
171+
1.output.js
172+
3 25 .\file.js
173+
async require (1x) from .\file.js
174+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("../build-common");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require("bundle!./file.js")(function(fileJsExports) {
2+
console.log(fileJsExports);
3+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "It works";
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# example.js
2+
3+
``` javascript
4+
{{example.js}}
5+
```
6+
7+
# file.js
8+
9+
``` javascript
10+
{{file.js}}
11+
```
12+
13+
14+
# js/output.js
15+
16+
``` javascript
17+
{{js/output.js}}
18+
```
19+
20+
# js/1.output.js
21+
22+
``` javascript
23+
{{js/1.output.js}}
24+
```
25+
26+
# Info
27+
28+
## Uncompressed
29+
30+
```
31+
{{stdout}}
32+
```
33+
34+
## Minimized (uglify-js, no zip)
35+
36+
```
37+
{{min:stdout}}
38+
```

examples/code-splitting/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ Modules first chunk: 3
120120
<id> <size> <filename>
121121
<reason> from <filename>
122122
output.js
123-
0 82 .\example.js
123+
0 155 .\example.js
124124
main
125-
1 0 .\node_modules\b.js
125+
1 11 .\~\b.js
126126
require (2x) from .\example.js
127-
2 0 .\node_modules\a.js
127+
2 11 .\~\a.js
128128
require (1x) from .\example.js
129129
1.output.js
130-
3 0 .\node_modules\c.js
130+
3 11 .\~\c.js
131131
async require (1x) from .\example.js
132-
4 0 .\node_modules\d.js
132+
4 11 .\~\d.js
133133
async require (1x) from .\example.js
134134
```
135135

@@ -150,13 +150,13 @@ Modules first chunk: 3
150150
output.js
151151
0 82 .\example.js
152152
main
153-
1 0 .\node_modules\b.js
153+
1 0 .\~\b.js
154154
require (2x) from .\example.js
155-
2 0 .\node_modules\a.js
155+
2 0 .\~\a.js
156156
require (1x) from .\example.js
157157
1.output.js
158-
3 0 .\node_modules\c.js
158+
3 0 .\~\c.js
159159
async require (1x) from .\example.js
160-
4 0 .\node_modules\d.js
160+
4 0 .\~\d.js
161161
async require (1x) from .\example.js
162162
```

examples/coffee-script/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ Modules: 4
116116
Modules including duplicates: 4
117117
Modules pre chunk: 4
118118
Modules first chunk: 4
119-
output.js: 1951 characters
119+
output.js: 1951 characters
120120
121121
<id> <size> <filename>
122122
<reason> from <filename>
123123
output.js
124-
0 23 .\example.js
124+
0 43 .\example.js
125125
main
126-
1 332 (webpack)\buildin\__webpack_console.js
126+
1 420 (webpack)\buildin\__webpack_console.js
127127
require (1x) from .\example.js
128128
require (1x) from .\cup2.coffee
129-
2 76 (webpack)\node_modules\coffee-loader\index.js!.\cup2.coffee
129+
2 92 (webpack)\~\coffee-loader!.\cup2.coffee
130130
require (2x) from .\cup1.coffee
131-
3 101 (webpack)\node_modules\coffee-loader\index.js!.\cup1.coffee
131+
3 178 (webpack)\~\coffee-loader!.\cup1.coffee
132132
require (1x) from .\example.js
133133
```
134134

@@ -141,7 +141,7 @@ Modules: 4
141141
Modules including duplicates: 4
142142
Modules pre chunk: 4
143143
Modules first chunk: 4
144-
output.js: 784 characters
144+
output.js: 784 characters
145145
146146
<id> <size> <filename>
147147
<reason> from <filename>
@@ -151,8 +151,8 @@ output.js
151151
1 332 (webpack)\buildin\__webpack_console.js
152152
require (1x) from .\example.js
153153
require (1x) from .\cup2.coffee
154-
2 76 (webpack)\node_modules\coffee-loader\index.js!.\cup2.coffee
154+
2 76 (webpack)\~\coffee-loader!.\cup2.coffee
155155
require (2x) from .\cup1.coffee
156-
3 101 (webpack)\node_modules\coffee-loader\index.js!.\cup1.coffee
156+
3 101 (webpack)\~\coffee-loader!.\cup1.coffee
157157
require (1x) from .\example.js
158158
```

examples/loader/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,20 @@ Modules: 5
136136
Modules including duplicates: 5
137137
Modules pre chunk: 5
138138
Modules first chunk: 5
139-
output.js: 2063 characters
139+
output.js: 2063 characters
140140
141141
<id> <size> <filename>
142142
<reason> from <filename>
143143
output.js
144-
0 109 .\example.js
144+
0 333 .\example.js
145145
main
146-
1 332 (webpack)\buildin\__webpack_console.js
146+
1 420 (webpack)\buildin\__webpack_console.js
147147
require (3x) from .\example.js
148-
2 28 (webpack)\node_modules\json-loader\index.js!.\test.json
148+
2 36 (webpack)\~\json-loader!.\test.json
149149
require (1x) from .\example.js
150150
require (1x) from .\example.js
151-
3 35 .\loader.js!.\file.js
151+
3 41 .\loader.js!.\file.js
152152
require (1x) from .\example.js
153-
4 36 (webpack)\require-polyfill.web.js
153+
4 87 (webpack)\require-polyfill.web.js
154154
require (1x) from .\example.js
155155
```

0 commit comments

Comments
 (0)