Skip to content

Commit 39f4cf0

Browse files
rodetyyx990803
authored andcommitted
Proposed update from require.ensure() to import()
Hello, I just started investigating in this area so let me know if my assumptions are wrong. The [Webpack documentation](https://webpack.js.org/guides/code-splitting-async/) linked here states: ``` webpack supports two similar techniques to achieve this goal: using import() (preferred, ECMAScript proposal) and require.ensure() (legacy, webpack specific). ``` I was able to make `import()` work with a very simple change. I'm taking the assumption that we'd update this documentation to take the current preferred method.
1 parent fd2fb67 commit 39f4cf0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/en/advanced/lazy-loading.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ All we need to do is define our route components as async components:
99

1010
``` js
1111
const Foo = resolve => {
12-
// `require.ensure` is webpack's special syntax for a code-split point.
13-
require.ensure(['./Foo.vue'], () => {
12+
// The `import()` call sets a code-split point.
13+
import('./Foo.vue').then(() => {
1414
resolve(require('./Foo.vue'))
1515
})
1616
}

0 commit comments

Comments
 (0)