@@ -161,22 +161,17 @@ export const constructCachePath = ({
161161 * @param nextResolve callback
162162 * @returns string
163163 */
164- export const resolve = async ( specifier : string , { parentURL } : Context , nextResolve : NextResolve , debug = false ) => {
164+ export const resolve = async ( specifier : string , { parentURL } : Context , nextResolve : NextResolve ) => {
165165 const { nodeImportMapPath } = constructLoaderConfig ( )
166166 if ( ! parentURL || ! nodeImportMapPath ) return nextResolve ( specifier ) ;
167167
168- try {
169168 const importmap = constructImportMap ( nodeImportMapPath )
170169 const modulePath = importmap . resolve (
171170 specifier ,
172171 cacheMap . get ( parentURL ) || parentURL
173172 ) ;
174173 const moduleCachePath = await parseModule ( specifier , modulePath ) ;
175174 return nextResolve ( moduleCachePath ) ;
176- } catch ( error ) {
177- if ( debug ) console . log ( error ) ;
178- return nextResolve ( specifier ) ;
179- }
180175} ;
181176
182177/**
@@ -198,7 +193,12 @@ export const parseModule = async (specifier: string, modulePath: string) => {
198193
199194 cacheMap . set ( `file://${ cachePath } ` , modulePath ) ;
200195 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 ( ) ;
202202
203203 ensureFileSync ( cachePath ) ;
204204 writeFileSync ( cachePath , code ) ;
0 commit comments