@@ -161,22 +161,17 @@ export const constructCachePath = ({
161
161
* @param nextResolve callback
162
162
* @returns string
163
163
*/
164
- export const resolve = async ( specifier : string , { parentURL } : Context , nextResolve : NextResolve , debug = false ) => {
164
+ export const resolve = async ( specifier : string , { parentURL } : Context , nextResolve : NextResolve ) => {
165
165
const { nodeImportMapPath } = constructLoaderConfig ( )
166
166
if ( ! parentURL || ! nodeImportMapPath ) return nextResolve ( specifier ) ;
167
167
168
- try {
169
168
const importmap = constructImportMap ( nodeImportMapPath )
170
169
const modulePath = importmap . resolve (
171
170
specifier ,
172
171
cacheMap . get ( parentURL ) || parentURL
173
172
) ;
174
173
const moduleCachePath = await parseModule ( specifier , modulePath ) ;
175
174
return nextResolve ( moduleCachePath ) ;
176
- } catch ( error ) {
177
- if ( debug ) console . log ( error ) ;
178
- return nextResolve ( specifier ) ;
179
- }
180
175
} ;
181
176
182
177
/**
@@ -198,7 +193,12 @@ export const parseModule = async (specifier: string, modulePath: string) => {
198
193
199
194
cacheMap . set ( `file://${ cachePath } ` , modulePath ) ;
200
195
if ( existsSync ( cachePath ) ) return cachePath
201
- const code = await ( await fetch ( modulePath ) ) . text ( ) ;
196
+ const code = await ( await fetch ( modulePath ) . then ( response => {
197
+ if ( ! response . ok ) {
198
+ throw Error ( `404: Module not found: ${ modulePath } ` ) ;
199
+ }
200
+ return response ;
201
+ } ) ) . text ( ) ;
202
202
203
203
ensureFileSync ( cachePath ) ;
204
204
writeFileSync ( cachePath , code ) ;
0 commit comments