Skip to content

Commit 15377b5

Browse files
authored
Merge pull request webpack#4269 from simon04/import-in-examples
Use import() instead of System.import in examples
2 parents 1cc7272 + e2a883f commit 15377b5

8 files changed

Lines changed: 208 additions & 209 deletions

File tree

‎examples/chunkhash/README.md‎

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The configuration required for this is:
1313
``` javascript
1414
import vendor from "./vendor";
1515
// some module
16-
System.import("./async1");
17-
System.import("./async2");
16+
import("./async1");
17+
import("./async2");
1818
```
1919

2020
# vendor.js
@@ -62,7 +62,7 @@ module.exports = {
6262

6363
<!-- inlined minimized file "manifest.[chunkhash].js" -->
6464
<script>
65-
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,a,c){for(var u,i,f,s=0,l=[];s<t.length;s++)i=t[s],o[i]&&l.push(o[i][0]),o[i]=0;for(u in a)Object.prototype.hasOwnProperty.call(a,u)&&(e[u]=a[u]);for(n&&n(t,a,c);l.length;)l.shift()();if(c)for(s=0;s<c.length;s++)f=r(r.s=c[s]);return f};var t={},o={4:0};r.e=function(e){function n(){a.onerror=a.onload=null,clearTimeout(c);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,r.nc&&a.setAttribute("nonce",r.nc),a.src=r.p+""+{0:"d8d9958181fae97ba27d",1:"36e4c03aa77bd58b0abc",2:"28b8ea2c1cc4eaebd919",3:"14bf1a160bee78ea17f7"}[e]+".js";var c=setTimeout(n,12e4);a.onerror=a.onload=n;var u=new Promise(function(r,n){o[e]=[r,n]});return o[e][2]=u,t.appendChild(a),u},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="js/",r.oe=function(e){throw console.error(e),e}}([]);
65+
!function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,s=0,d=[];s<t.length;s++)i=t[s],o[i]&&d.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(n&&n(t,c,a);d.length;)d.shift()();if(a)for(s=0;s<a.length;s++)f=r(r.s=a[s]);return f};var t={},o={4:0};r.e=function(e){function n(){c.onerror=c.onload=null,clearTimeout(a);var r=o[e];0!==r&&(r&&r[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return Promise.resolve();if(o[e])return o[e][2];var t=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,r.nc&&c.setAttribute("nonce",r.nc),c.src=r.p+""+{0:"ecd2b16a48d8b92daf31",1:"3ab6307df46b05a2e3c3",2:"0910ffec005965d55bfb",3:"7e3d3299e6c5c1defd1d"}[e]+".js";var a=setTimeout(n,12e4);c.onerror=c.onload=n;var u=new Promise(function(r,n){o[e]=[r,n]});return o[e][2]=u,t.appendChild(c),u},r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="js/",r.oe=function(e){throw console.error(e),e}}([]);
6666
</script>
6767

6868
<!-- optional when using the CommonChunkPlugin for vendor modules -->
@@ -84,30 +84,30 @@ webpackJsonp([2,4],[
8484
/*!*******************!*\
8585
!*** ./vendor.js ***!
8686
\*******************/
87-
/***/ function(module, exports, __webpack_require__) {
87+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
8888

8989
"use strict";
90-
Object.defineProperty(exports, "__esModule", { value: true });
90+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
9191
// some vendor lib (should be in common chunk)
92-
/* harmony default export */ exports["default"] = 123;
92+
/* harmony default export */ __webpack_exports__["default"] = (123);
9393

9494

95-
/***/ },
95+
/***/ }),
9696
/* 1 */,
9797
/* 2 */,
9898
/* 3 */,
9999
/* 4 */
100100
/* unknown exports provided */
101101
/* all exports used */
102-
/*!********************!*\
103-
!*** multi common ***!
104-
\********************/
105-
/***/ function(module, exports, __webpack_require__) {
102+
/*!**********************!*\
103+
!*** multi ./vendor ***!
104+
\**********************/
105+
/***/ (function(module, exports, __webpack_require__) {
106106

107107
module.exports = __webpack_require__(/*! ./vendor */0);
108108

109109

110-
/***/ }
110+
/***/ })
111111
],[4]);
112112
```
113113

@@ -122,18 +122,18 @@ webpackJsonp([3,4],{
122122
/*!********************!*\
123123
!*** ./example.js ***!
124124
\********************/
125-
/***/ function(module, exports, __webpack_require__) {
125+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
126126

127127
"use strict";
128-
Object.defineProperty(exports, "__esModule", { value: true });
128+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
129129
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vendor__ = __webpack_require__(/*! ./vendor */ 0);
130130

131131
// some module
132132
__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */ 1));
133133
__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */ 2));
134134

135135

136-
/***/ }
136+
/***/ })
137137

138138
},[3]);
139139
```
@@ -143,67 +143,67 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! .
143143
## Uncompressed
144144

145145
```
146-
Hash: 7b7e514d1f86a946849f
147-
Version: webpack 2.2.0-rc.2
146+
Hash: 4e82450959815ca9c86c
147+
Version: webpack 2.2.1
148148
Asset Size Chunks Chunk Names
149-
d8d9958181fae97ba27d.js 237 bytes 0, 4 [emitted]
150-
36e4c03aa77bd58b0abc.js 243 bytes 1, 4 [emitted]
151-
common.chunkhash.js 701 bytes 2, 4 [emitted] common
152-
main.chunkhash.js 630 bytes 3, 4 [emitted] main
149+
ecd2b16a48d8b92daf31.js 238 bytes 0, 4 [emitted]
150+
3ab6307df46b05a2e3c3.js 244 bytes 1, 4 [emitted]
151+
common.chunkhash.js 747 bytes 2, 4 [emitted] common
152+
main.chunkhash.js 652 bytes 3, 4 [emitted] main
153153
manifest.chunkhash.js 5.66 kB 4 [emitted] manifest
154154
Entrypoint main = manifest.chunkhash.js common.chunkhash.js main.chunkhash.js
155155
Entrypoint common = manifest.chunkhash.js common.chunkhash.js
156-
chunk {0} d8d9958181fae97ba27d.js 29 bytes {3} [rendered]
157-
> [3] ./example.js 4:0-25
158-
[2] ./async2.js 29 bytes {0} [built]
159-
import() ./async2 [3] ./example.js 4:0-25
160-
chunk {1} 36e4c03aa77bd58b0abc.js 29 bytes {3} [rendered]
161-
> [3] ./example.js 3:0-25
162-
[1] ./async1.js 29 bytes {1} [built]
163-
import() ./async1 [3] ./example.js 3:0-25
164-
chunk {2} common.chunkhash.js (common) 97 bytes {4} [initial] [rendered]
165-
> common [4] multi common
166-
[0] ./vendor.js 69 bytes {2} [built]
156+
chunk {0} ecd2b16a48d8b92daf31.js 28 bytes {3} [rendered]
157+
> [3] ./example.js 4:0-18
158+
[2] ./async2.js 28 bytes {0} [built]
159+
import() ./async2 [3] ./example.js 4:0-18
160+
chunk {1} 3ab6307df46b05a2e3c3.js 28 bytes {3} [rendered]
161+
> [3] ./example.js 3:0-18
162+
[1] ./async1.js 28 bytes {1} [built]
163+
import() ./async1 [3] ./example.js 3:0-18
164+
chunk {2} common.chunkhash.js (common) 95 bytes {4} [initial] [rendered]
165+
> common [4] multi ./vendor
166+
[0] ./vendor.js 67 bytes {2} [built]
167167
[exports: default]
168168
harmony import ./vendor [3] ./example.js 1:0-30
169-
single entry ./vendor [4] multi common
170-
[4] multi common 28 bytes {2} [built]
171-
chunk {3} main.chunkhash.js (main) 104 bytes {2} [initial] [rendered]
169+
single entry ./vendor [4] multi ./vendor common:100000
170+
[4] multi ./vendor 28 bytes {2} [built]
171+
chunk {3} main.chunkhash.js (main) 86 bytes {2} [initial] [rendered]
172172
> main [3] ./example.js
173-
[3] ./example.js 104 bytes {3} [built]
173+
[3] ./example.js 86 bytes {3} [built]
174174
chunk {4} manifest.chunkhash.js (manifest) 0 bytes [entry] [rendered]
175175
```
176176

177177
## Minimized (uglify-js, no zip)
178178

179179
```
180-
Hash: 7b7e514d1f86a946849f
181-
Version: webpack 2.2.0-rc.2
180+
Hash: 4e82450959815ca9c86c
181+
Version: webpack 2.2.1
182182
Asset Size Chunks Chunk Names
183-
d8d9958181fae97ba27d.js 40 bytes 0, 4 [emitted]
184-
36e4c03aa77bd58b0abc.js 39 bytes 1, 4 [emitted]
183+
ecd2b16a48d8b92daf31.js 40 bytes 0, 4 [emitted]
184+
3ab6307df46b05a2e3c3.js 39 bytes 1, 4 [emitted]
185185
common.chunkhash.js 154 bytes 2, 4 [emitted] common
186186
main.chunkhash.js 168 bytes 3, 4 [emitted] main
187187
manifest.chunkhash.js 1.48 kB 4 [emitted] manifest
188188
Entrypoint main = manifest.chunkhash.js common.chunkhash.js main.chunkhash.js
189189
Entrypoint common = manifest.chunkhash.js common.chunkhash.js
190-
chunk {0} d8d9958181fae97ba27d.js 29 bytes {3} [rendered]
191-
> [3] ./example.js 4:0-25
192-
[2] ./async2.js 29 bytes {0} [built]
193-
import() ./async2 [3] ./example.js 4:0-25
194-
chunk {1} 36e4c03aa77bd58b0abc.js 29 bytes {3} [rendered]
195-
> [3] ./example.js 3:0-25
196-
[1] ./async1.js 29 bytes {1} [built]
197-
import() ./async1 [3] ./example.js 3:0-25
198-
chunk {2} common.chunkhash.js (common) 97 bytes {4} [initial] [rendered]
199-
> common [4] multi common
200-
[0] ./vendor.js 69 bytes {2} [built]
190+
chunk {0} ecd2b16a48d8b92daf31.js 28 bytes {3} [rendered]
191+
> [3] ./example.js 4:0-18
192+
[2] ./async2.js 28 bytes {0} [built]
193+
import() ./async2 [3] ./example.js 4:0-18
194+
chunk {1} 3ab6307df46b05a2e3c3.js 28 bytes {3} [rendered]
195+
> [3] ./example.js 3:0-18
196+
[1] ./async1.js 28 bytes {1} [built]
197+
import() ./async1 [3] ./example.js 3:0-18
198+
chunk {2} common.chunkhash.js (common) 95 bytes {4} [initial] [rendered]
199+
> common [4] multi ./vendor
200+
[0] ./vendor.js 67 bytes {2} [built]
201201
[exports: default]
202202
harmony import ./vendor [3] ./example.js 1:0-30
203-
single entry ./vendor [4] multi common
204-
[4] multi common 28 bytes {2} [built]
205-
chunk {3} main.chunkhash.js (main) 104 bytes {2} [initial] [rendered]
203+
single entry ./vendor [4] multi ./vendor common:100000
204+
[4] multi ./vendor 28 bytes {2} [built]
205+
chunk {3} main.chunkhash.js (main) 86 bytes {2} [initial] [rendered]
206206
> main [3] ./example.js
207-
[3] ./example.js 104 bytes {3} [built]
207+
[3] ./example.js 86 bytes {3} [built]
208208
chunk {4} manifest.chunkhash.js (manifest) 0 bytes [entry] [rendered]
209209
```

‎examples/chunkhash/example.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import vendor from "./vendor";
22
// some module
3-
System.import("./async1");
4-
System.import("./async2");
3+
import("./async1");
4+
import("./async2");

0 commit comments

Comments
 (0)