Skip to content

Commit

Permalink
docs: fix globEager example
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 10, 2021
1 parent cb3cf76 commit 936fb18
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ for (const path in modules) {
Matched files are by default lazy loaded via dynamic import and will be split into separate chunks during build. If you'd rather import all the modules directly (e.g. relying on side-effects in these modules to be applied first), you can use `import.meta.globEager` instead:

```js
const modules = import.meta.glob('./dir/*.js')
const modules = import.meta.globEager('./dir/*.js')
```

The above will be transformed into the following:

```js
// code produced by vite
import * as __glob__0_0 from './dir/foo.js'
import * as __glob__0_1 from './dir/bar.js'
const modules = {
'./dir/foo.js': () => import('./dir/foo.js'),
'./dir/bar.js': () => import('./dir/bar.js')
'./dir/foo.js': __glob__0_0,
'./dir/bar.js': __glob__0_1
}
```

Expand Down

0 comments on commit 936fb18

Please sign in to comment.