File tree Expand file tree Collapse file tree 8 files changed +56
-8
lines changed
Expand file tree Collapse file tree 8 files changed +56
-8
lines changed Original file line number Diff line number Diff line change 11* node_modules /
2- example /bundle.js
3- example /bundle.js.map
2+ example /build /
Original file line number Diff line number Diff line change 1+ import React = require( 'react' ) ;
2+
3+ var AsyncComponent = React . createClass ( {
4+
5+ render ( ) {
6+ return React . DOM . div ( { } , 'I AM ASYNC!' ) ;
7+ }
8+ } ) ;
9+
10+ export = AsyncComponent ;
Original file line number Diff line number Diff line change 11import React = require( 'react' ) ;
22
3- export var Button = React . createClass ( {
3+ var Button = React . createClass ( {
44
55 render ( ) {
66 return React . DOM . button ( { onClick : this . onClick } , 'Typed Button!' ) ;
77 } ,
88
99 componentDidMount ( ) {
10- throw new Error ( 'xx ') ;
10+ console . log ( 'hello ') ;
1111 } ,
1212
1313 onClick ( e ) {
1414 alert ( 'Works!' ) ;
1515 }
1616} ) ;
17+
18+ export = Button ;
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ BIN = ./node_modules/.bin
33build : install typings
44 $(BIN ) /webpack
55
6+ watch : install typings
7+ $(BIN ) /webpack --watch
8+
69install :
710 @npm install
811
Original file line number Diff line number Diff line change 11<!doctype html>
22< div id ="main "> </ div >
3- < script src ="bundle.js "> </ script >
3+ < script src ="build/ bundle.js "> </ script >
Original file line number Diff line number Diff line change @@ -4,8 +4,29 @@ require('./index.css');
44
55import React = require( 'react/addons' ) ;
66import Button = require( './Button' ) ;
7+ import AsyncComponent = require( './AsyncComponent' ) ;
78
9+ var App = React . createClass ( {
10+
11+ render ( ) {
12+ return React . DOM . div ( { } ,
13+ React . createElement ( Button , { } ) ,
14+ this . state . async ? React . createElement ( this . state . async , { } ) : null
15+ ) ;
16+ } ,
17+
18+ getInitialState ( ) {
19+ return { async : null } ;
20+ } ,
21+
22+ componentDidMount ( ) {
23+ require . ensure ( [ './AsyncComponent' ] , ( require ) => {
24+ var async : typeof AsyncComponent = require ( './AsyncComponent' ) ;
25+ this . setState ( { async : async } ) ;
26+ } ) ;
27+ }
28+ } ) ;
829
930React . render (
10- React . createElement ( Button . Button , { } ) ,
31+ React . createElement ( App , { } ) ,
1132 document . getElementById ( 'main' ) ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ module.exports = {
55 devtool : 'source-map' ,
66
77 output : {
8- filename : __dirname + '/bundle.js'
8+ path : 'build' ,
9+ filename : 'bundle.js' ,
10+ chunkFilename : '[id].js' ,
11+ publicPath : '/build/'
912 } ,
1013
1114 resolve : {
Original file line number Diff line number Diff line change 11/**
22 * Type declarations for Webpack runtime.
33 */
4- declare function require ( x : string ) : any
4+
5+ interface WebpackRequireEnsureCallback {
6+ ( ( id : string ) => any ) => any
7+ }
8+
9+ interface WebpackRequire {
10+ ( id : string ) => any;
11+ ensure ( ids : string [ ] , WebpackRequireEnsureCallback ) => any;
12+ }
13+
14+ declare var require : WebpackRequire ;
You can’t perform that action at this time.
0 commit comments