Skip to content

Commit 505a453

Browse files
committed
docs: update outdated references to globEager
It was removed from Vite, now supported as an optional argument.
1 parent b0d1812 commit 505a453

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

docs/src/guide/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ or when all components should be registered in all pages.
5656

5757
```js
5858
// app/frontend/entrypoints/application.js
59-
import.meta.globEager('../../components/**/*_component.js')
59+
import.meta.glob('../../components/**/*_component.js', { eager: true })
6060
```
6161

6262
Any files imported from each `.js` file will be bundled as well.

docs/src/guide/migrating-to-vite-3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In Vite 3, [`import.meta.glob`](https://vitejs.dev/guide/migration.html#import-m
3333

3434
```ts
3535
// app/frontend/controllers/index.js
36-
const controllers = import.meta.globEager('../**/*_controller.js')
36+
const controllers = import.meta.glob('../**/*_controller.js', { eager: true })
3737
```
3838

3939
That code now transforms to:
@@ -51,7 +51,7 @@ Depending on the the pattern you might not need to make any changes, but if you
5151
need the full path, you can leverage the new support for aliases:
5252

5353
```ts
54-
const controllers = import.meta.globEager('~/controllers/**/*_controller.js')
54+
const controllers = import.meta.glob('~/controllers/**/*_controller.js', { eager: true })
5555
```
5656

5757
:::tip Prefer Aliases

docs/src/guide/migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ Proceed to fix any errors that occur (i.e. differences between Webpack and Vite.
9090
+ <img src="<%= vite_asset_path('images/logo.svg') %>">
9191
```
9292

93-
- Replace `require.context` with [`import.meta.glob`][glob] or [`import.meta.globEager`][glob].
93+
- Replace `require.context` with [`import.meta.glob`][glob].
9494

9595
```diff
9696
- const context = require.context("./controllers", true, /\.js$/)
97-
+ const controllers = import.meta.globEager('./**/*_controller.js')
97+
+ const controllers = import.meta.glob('./**/*_controller.js', { eager: true })
9898
```
9999

100100
If you want to automatically register the Stimulus Controllers, have a look at <kbd>[stimulus-vite-helpers]</kbd> as a replacement for <kbd>@hotwired/stimulus-webpack-helpers</kbd>

examples/rails/app/frontend/entrypoints/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ setTimeout(() => import('~/outer_import'), 5000)
1515
import '@administrator/timer'
1616

1717
// Import all channels.
18-
import.meta.globEager('../channels/**/*_channel.js')
18+
import.meta.glob('../channels/**/*_channel.js', { eager: true })
1919

2020
Turbo.start()
2121
ActiveStorage.start()

test/test_app/app/frontend/entrypoints/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ console.log('Vite ⚡️ Rails')
1414
// ActiveStorage.start()
1515
//
1616
// // Import all channels.
17-
// const channels = import.meta.globEager('./**/*_channel.js')
17+
// const channels = import.meta.glob('./**/*_channel.js', { eager: true })
1818

1919
// Example: Import a stylesheet in app/frontend/index.css
2020
// import '~/index.css'

vite_rails/templates/entrypoints/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify
2222
// ActiveStorage.start()
2323
//
2424
// // Import all channels.
25-
// const channels = import.meta.globEager('./**/*_channel.js')
25+
// const channels = import.meta.glob('./**/*_channel.js', { eager: true })
2626

2727
// Example: Import a stylesheet in app/frontend/index.css
2828
// import '~/index.css'

vite_rails_legacy/templates/entrypoints/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ console.log('Visit the guide for more information: ', 'https://vite-ruby.netlify
2222
// ActiveStorage.start()
2323
//
2424
// // Import all channels.
25-
// const channels = import.meta.globEager('./**/*_channel.js')
25+
// const channels = import.meta.glob('./**/*_channel.js', { eager: true })
2626

2727
// Example: Import a stylesheet in app/frontend/index.css
2828
// import '~/index.css'

0 commit comments

Comments
 (0)