File tree 3 files changed +32
-1
lines changed
3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ const rawResult = {
66
66
}
67
67
}
68
68
69
+ const relativeRawResult = {
70
+ '../glob-import/dir/baz.json' : {
71
+ msg : 'baz'
72
+ }
73
+ }
74
+
69
75
test ( 'should work' , async ( ) => {
70
76
expect ( await page . textContent ( '.result' ) ) . toBe (
71
77
JSON . stringify ( allResult , null , 2 )
@@ -81,6 +87,12 @@ test('import glob raw', async () => {
81
87
)
82
88
} )
83
89
90
+ test ( 'import relative glob raw' , async ( ) => {
91
+ expect ( await page . textContent ( '.relative-glob-raw' ) ) . toBe (
92
+ JSON . stringify ( relativeRawResult , null , 2 )
93
+ )
94
+ } )
95
+
84
96
if ( ! isBuild ) {
85
97
test ( 'hmr for adding/removing files' , async ( ) => {
86
98
addFile ( 'dir/a.js' , '' )
Original file line number Diff line number Diff line change 1
1
< pre class ="result "> </ pre >
2
2
< pre class ="result-node_modules "> </ pre >
3
3
< pre class ="globraw "> </ pre >
4
+ < pre class ="relative-glob-raw "> </ pre >
4
5
5
6
< script type ="module " src ="./dir/index.js "> </ script >
6
7
< script type ="module ">
52
53
2
53
54
)
54
55
</ script >
56
+
57
+ < script type ="module ">
58
+ const relativeRawModules = import . meta. globEager (
59
+ '../glob-import/dir/*.json' ,
60
+ {
61
+ as : 'raw'
62
+ }
63
+ )
64
+ const relativeGlobRaw = { }
65
+ Object . keys ( relativeRawModules ) . forEach ( ( key ) => {
66
+ relativeGlobRaw [ key ] = JSON . parse ( relativeRawModules [ key ] )
67
+ } )
68
+ document . querySelector ( '.relative-glob-raw' ) . textContent = JSON . stringify (
69
+ relativeGlobRaw ,
70
+ null ,
71
+ 2
72
+ )
73
+ </ script >
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ export async function transformImportGlob(
147
147
)
148
148
}
149
149
entries += ` ${ JSON . stringify ( file ) } : ${ JSON . stringify (
150
- await fsp . readFile ( path . join ( base , file ) , 'utf-8' )
150
+ await fsp . readFile ( path . join ( base , files [ i ] ) , 'utf-8' )
151
151
) } ,`
152
152
} else {
153
153
const importeeUrl = isCSSRequest ( importee ) ? `${ importee } ?used` : importee
You can’t perform that action at this time.
0 commit comments