You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+20-16
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,22 @@
2
2
3
3
Implements [RFC#939: import.meta.glob](https://github.com/emberjs/rfcs/pull/939) for ember-classic (pre-embroider).
4
4
5
-
Example:
5
+
## Compatibility
6
+
7
+
- Apps using ember-source v3.28
8
+
- ember-auto-import v2
9
+
-_not_ embroider. For embroider, use [`babel-plugin-transform-vite-meta-glob`](https://www.npmjs.com/package/babel-plugin-transform-vite-meta-glob)
10
+
11
+
## Installation
12
+
13
+
```
14
+
pnpm add ember-classic-import-meta-glob
15
+
```
16
+
17
+
## Usage
18
+
19
+
20
+
Default usage:
6
21
```js
7
22
// If you type this in your app:
8
23
constwidgets=import.meta.glob('./widgets/*.js')
@@ -28,23 +43,12 @@ const widgets = {
28
43
}
29
44
```
30
45
31
-
## Compatibility
32
-
33
-
- Apps using ember-source v3.28
34
-
- ember-auto-import v2
35
-
-_not_ embroider. For embroider, use [`babel-plugin-transform-vite-meta-glob`](https://www.npmjs.com/package/babel-plugin-transform-vite-meta-glob)
36
-
37
-
## Installation
38
-
39
-
```
40
-
pnpm add ember-classic-import-meta-glob
41
-
```
42
-
43
-
## Usage
44
-
45
-
In your JS files:
46
+
## Differences from RFC#939
46
47
48
+
- Extensions in the import paths are optional -- this because they do not exist at runtime, and the implementation for this version of import.meta.glob cannot determine what the original file names were.
49
+
- the keys in the return object from `glob` will not contain file name extensions, because they do not exist at runtime.
47
50
51
+
For ember-classic, this is meant to _ease_ migration to the new, modern features, reducing the overall diff you'd need if you didn't have entire feature sets that are available to embroider.
`the third argument to import.meta.glob must be passed and be the module path. This is filled in automatically via the babel plugin. If you're seeing this something has gone wrong with installing the babel plugin`,
@@ -45,19 +49,24 @@ export function importMetaGlob(glob, options, modulePath) {
45
49
letcurrentDir=reversedParts.reverse().join('/');
46
50
47
51
// TODO: drop the extensions, since at runtime, we don't have them.
0 commit comments