File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ const rawResult = {
6666 }
6767}
6868
69+ const relativeRawResult = {
70+ '../glob-import/dir/baz.json' : {
71+ msg : 'baz'
72+ }
73+ }
74+
6975test ( 'should work' , async ( ) => {
7076 expect ( await page . textContent ( '.result' ) ) . toBe (
7177 JSON . stringify ( allResult , null , 2 )
@@ -81,6 +87,12 @@ test('import glob raw', async () => {
8187 )
8288} )
8389
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+
8496if ( ! isBuild ) {
8597 test ( 'hmr for adding/removing files' , async ( ) => {
8698 addFile ( 'dir/a.js' , '' )
Original file line number Diff line number Diff line change 11< pre class ="result "> </ pre >
22< pre class ="result-node_modules "> </ pre >
33< pre class ="globraw "> </ pre >
4+ < pre class ="relative-glob-raw "> </ pre >
45
56< script type ="module " src ="./dir/index.js "> </ script >
67< script type ="module ">
5253 2
5354 )
5455</ 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(
147147 )
148148 }
149149 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' )
151151 ) } ,`
152152 } else {
153153 const importeeUrl = isCSSRequest ( importee ) ? `${ importee } ?used` : importee
You can’t perform that action at this time.
0 commit comments