@@ -221,7 +221,9 @@ export class Application implements ServerApplication {
221
221
}
222
222
if ( validated ) {
223
223
await this . compile ( url )
224
- this . #pageRouting. update ( ...this . createRouteUpdate ( url ) )
224
+ if ( this . #modules. has ( url ) ) {
225
+ this . #pageRouting. update ( ...this . createRouteUpdate ( url ) )
226
+ }
225
227
}
226
228
}
227
229
}
@@ -232,7 +234,9 @@ export class Application implements ServerApplication {
232
234
for await ( const { path : p } of walk ( apiDir , { ...walkOptions , exts : moduleExts } ) ) {
233
235
const url = util . cleanPath ( '/api/' + util . trimPrefix ( p , apiDir ) )
234
236
await this . compile ( url )
235
- this . #apiRouting. update ( ...this . createRouteUpdate ( url ) )
237
+ if ( this . #modules. has ( url ) ) {
238
+ this . #apiRouting. update ( ...this . createRouteUpdate ( url ) )
239
+ }
236
240
}
237
241
}
238
242
@@ -772,7 +776,7 @@ export class Application implements ServerApplication {
772
776
const v = plugin . resolve ( url )
773
777
let content : Uint8Array
774
778
if ( v instanceof Promise ) {
775
- content = ( await v )
779
+ content = await v
776
780
} else {
777
781
content = v
778
782
}
@@ -784,8 +788,12 @@ export class Application implements ServerApplication {
784
788
785
789
if ( ! util . isLikelyHttpURL ( url ) ) {
786
790
const filepath = join ( this . srcDir , util . trimPrefix ( url , 'file://' ) )
787
- const content = await Deno . readFile ( filepath )
788
- return { content, contentType : null }
791
+ if ( existsFileSync ( filepath ) ) {
792
+ const content = await Deno . readFile ( filepath )
793
+ return { content, contentType : null }
794
+ } else {
795
+ return Promise . reject ( new Error ( `No such file` ) )
796
+ }
789
797
}
790
798
791
799
const u = new URL ( url )
@@ -826,7 +834,7 @@ export class Application implements ServerApplication {
826
834
827
835
// download dep when deno cache failed
828
836
let err = new Error ( 'Unknown' )
829
- for ( let i = 0 ; i < 15 ; i ++ ) {
837
+ for ( let i = 0 ; i < 10 ; i ++ ) {
830
838
if ( i === 0 ) {
831
839
if ( ! isLocalhost ) {
832
840
log . info ( 'Download' , url )
@@ -978,8 +986,8 @@ export class Application implements ServerApplication {
978
986
if ( ! once ) {
979
987
this . #modules. set ( url , mod )
980
988
}
981
- try {
982
- if ( existsFileSync ( metaFile ) ) {
989
+ if ( existsFileSync ( metaFile ) ) {
990
+ try {
983
991
const { url : __url , sourceHash, deps } = JSON . parse ( await Deno . readTextFile ( metaFile ) )
984
992
if ( __url === url && util . isNEString ( sourceHash ) && util . isArray ( deps ) ) {
985
993
mod . sourceHash = sourceHash
@@ -988,8 +996,8 @@ export class Application implements ServerApplication {
988
996
log . warn ( `removing invalid metadata '${ name } .meta.json'` )
989
997
Deno . remove ( metaFile )
990
998
}
991
- }
992
- } catch ( e ) { }
999
+ } catch ( e ) { }
1000
+ }
993
1001
}
994
1002
995
1003
let sourceContent = new Uint8Array ( )
@@ -1020,13 +1028,19 @@ export class Application implements ServerApplication {
1020
1028
}
1021
1029
}
1022
1030
if ( shouldFetch ) {
1023
- const { content, contentType : ctype } = await this . fetchModule ( url )
1024
- const sourceHash = computeHash ( content )
1025
- sourceContent = content
1026
- contentType = ctype
1027
- if ( mod . sourceHash === '' || mod . sourceHash !== sourceHash ) {
1028
- mod . sourceHash = sourceHash
1029
- shouldCompile = true
1031
+ try {
1032
+ const { content, contentType : ctype } = await this . fetchModule ( url )
1033
+ const sourceHash = computeHash ( content )
1034
+ sourceContent = content
1035
+ contentType = ctype
1036
+ if ( mod . sourceHash === '' || mod . sourceHash !== sourceHash ) {
1037
+ mod . sourceHash = sourceHash
1038
+ shouldCompile = true
1039
+ }
1040
+ } catch ( err ) {
1041
+ log . error ( `Fetch module '${ url } ':` , err . message )
1042
+ this . #modules. delete ( url )
1043
+ return mod
1030
1044
}
1031
1045
}
1032
1046
}
@@ -1035,13 +1049,12 @@ export class Application implements ServerApplication {
1035
1049
if ( shouldCompile ) {
1036
1050
const source = await this . precompile ( url , sourceContent , contentType )
1037
1051
if ( source === null ) {
1038
- log . warn ( `Unsupported module '${ url } '` )
1052
+ log . error ( `Unsupported module '${ url } '` )
1039
1053
this . #modules. delete ( url )
1040
1054
return mod
1041
1055
}
1042
1056
1043
1057
const t = performance . now ( )
1044
-
1045
1058
const { code, deps, starExports, map } = await transform ( url , source . code , {
1046
1059
...this . defaultCompileOptions ,
1047
1060
swcOptions : {
0 commit comments