@@ -17,19 +17,25 @@ const Home = { template: '<div>home</div>' }
1717// or
1818// - () => Promise<Component>
1919
20- // For single component, we can use the AMD shorthand
21- // require(['dep'], dep => { ... })
22- const Foo = resolve => require ( [ './Foo.vue' ] , resolve )
20+ // For single component, we can simply use dynamic import which returns
21+ // a Promise.
22+ const Foo = ( ) => import ( './Foo.vue' )
2323
24- // If using Webpack 2, you can also do:
25- // const Foo = () => System.import('./Foo.vue')
24+ // The import() syntax is a replacement for the deprecated System.import() and
25+ // is specified at https://github.com/tc39/proposal-dynamic-import. Webpack 2
26+ // supports using it to indicate a code-splitting point.
27+ // Note: if using Babel you will need `babel-plugin-syntax-dynamic-import`.
28+
29+ // If using Webpack 1, you will have to use AMD syntax or require.ensure:
30+ // const Foo = resolve => require(['./Foo.vue'], resolve)
2631
2732// If you want to group a number of components that belong to the same
2833// nested route in the same async chunk, you will need to use
2934// require.ensure. The 3rd argument is the chunk name they belong to -
3035// modules that belong to the same chunk should use the same chunk name.
31- const Bar = r => require . ensure ( [ ] , ( ) => r ( require ( './Bar.vue' ) ) , '/bar' )
32- const Baz = r => require . ensure ( [ ] , ( ) => r ( require ( './Baz.vue' ) ) , '/bar' )
36+ // For more details see https://webpack.js.org/guides/code-splitting-require/
37+ const Bar = resolve => require . ensure ( [ ] , ( ) => resolve ( require ( './Bar.vue' ) ) , '/bar' )
38+ const Baz = resolve => require . ensure ( [ ] , ( ) => resolve ( require ( './Baz.vue' ) ) , '/bar' )
3339
3440const router = new VueRouter ( {
3541 mode : 'history' ,
0 commit comments