@@ -26,7 +26,6 @@ export type Module = {
26
26
/** The dependency descriptor. */
27
27
export type DependencyDescriptor = {
28
28
url : string
29
- hash : string
30
29
isDynamic ?: boolean
31
30
}
32
31
@@ -593,12 +592,12 @@ export class Application implements ServerApplication {
593
592
once ?: boolean ,
594
593
} = { }
595
594
) : Promise < Module > {
596
- const { sourceCode, forceCompile, once } = options
597
595
const isRemote = util . isLikelyHttpURL ( url )
598
596
const localUrl = toLocalUrl ( url )
599
597
const name = trimModuleExt ( path . basename ( localUrl ) )
600
598
const saveDir = path . join ( this . buildDir , path . dirname ( localUrl ) )
601
599
const metaFile = path . join ( saveDir , `${ name } .meta.json` )
600
+ const { sourceCode, forceCompile, once } = options
602
601
603
602
let mod : Module
604
603
if ( this . #modules. has ( url ) ) {
@@ -757,17 +756,12 @@ export class Application implements ServerApplication {
757
756
}
758
757
759
758
mod . deps = deps . map ( ( { specifier, isDynamic } ) => {
760
- const dep : DependencyDescriptor = { url : specifier , hash : '' }
759
+ const dep : DependencyDescriptor = { url : specifier }
761
760
if ( isDynamic ) {
762
761
dep . isDynamic = true
763
762
}
764
- if ( dep . url . startsWith ( '#useDeno-' ) ) {
765
- dep . hash = util . trimPrefix ( dep . url , '#useDeno-' )
766
- if ( ! this . config . ssr ) {
767
- log . warn ( `use 'useDeno' hook in SPA mode: ${ url } ` )
768
- }
769
- } else if ( dep . url . startsWith ( '#inline-style-' ) ) {
770
- dep . hash = util . trimPrefix ( dep . url , '#inline-style-' )
763
+ if ( dep . url . startsWith ( '#useDeno-' ) && ! this . config . ssr ) {
764
+ log . warn ( `use 'useDeno' hook in SPA mode: ${ url } ` )
771
765
}
772
766
return dep
773
767
} )
@@ -778,29 +772,26 @@ export class Application implements ServerApplication {
778
772
// compile deps
779
773
for ( const dep of mod . deps . filter ( ( { url } ) => ! url . startsWith ( '#' ) ) ) {
780
774
const depMod = await this . compile ( dep . url , { once } )
781
- if ( dep . hash === '' || dep . hash !== depMod . hash ) {
782
- dep . hash = depMod . hash
783
- if ( ! util . isLikelyHttpURL ( dep . url ) ) {
784
- const relativePathname = getRelativePath (
785
- path . dirname ( toLocalUrl ( url ) ) ,
786
- trimModuleExt ( toLocalUrl ( dep . url ) )
787
- )
788
- if ( jsContent === '' ) {
789
- jsContent = await Deno . readTextFile ( mod . jsFile )
790
- }
791
- const newContent = jsContent . replace ( reHashResolve , ( s , key , spaces , ql , importPath , qr ) => {
792
- const importPathname = importPath . replace ( reHashJs , '' )
793
- if ( importPathname == dep . url || importPathname === relativePathname ) {
794
- return `${ key } ${ spaces } ${ ql } ${ importPathname } .${ dep . hash . slice ( 0 , hashShortLength ) } .js${ qr } `
795
- }
796
- return s
775
+ if ( ! util . isLikelyHttpURL ( dep . url ) ) {
776
+ const relativePathname = getRelativePath (
777
+ path . dirname ( toLocalUrl ( url ) ) ,
778
+ trimModuleExt ( toLocalUrl ( dep . url ) )
779
+ )
780
+ if ( jsContent === '' ) {
781
+ jsContent = await Deno . readTextFile ( mod . jsFile )
782
+ }
783
+ const newContent = jsContent . replace ( reHashResolve , ( s , key , spaces , ql , importPath , qr ) => {
784
+ const importPathname = importPath . replace ( reHashJs , '' )
785
+ if ( importPathname == dep . url || importPathname === relativePathname ) {
786
+ return `${ key } ${ spaces } ${ ql } ${ importPathname } .${ depMod . hash . slice ( 0 , hashShortLength ) } .js${ qr } `
797
787
}
798
- )
799
- if ( newContent !== jsContent ) {
800
- jsContent = newContent
801
- if ( ! fsync ) {
802
- fsync = true
803
- }
788
+ return s
789
+ }
790
+ )
791
+ if ( newContent !== jsContent ) {
792
+ jsContent = newContent
793
+ if ( ! fsync ) {
794
+ fsync = true
804
795
}
805
796
}
806
797
}
@@ -1033,25 +1024,22 @@ export class Application implements ServerApplication {
1033
1024
for ( const mod of this . #modules. values ( ) ) {
1034
1025
for ( const dep of mod . deps ) {
1035
1026
if ( dep . url === url ) {
1036
- if ( dep . hash !== "" && dep . hash !== hash ) {
1037
- dep . hash = hash
1038
- const relativePathname = getRelativePath (
1039
- path . dirname ( toLocalUrl ( mod . url ) ) ,
1040
- trimModuleExt ( toLocalUrl ( dep . url ) )
1041
- )
1042
- const jsContent = ( await Deno . readTextFile ( mod . jsFile ) )
1043
- . replace ( reHashResolve , ( s , key , spaces , ql , importPath , qr ) => {
1044
- const importPathname = importPath . replace ( reHashJs , '' )
1045
- if ( importPathname === dep . url || importPathname === relativePathname ) {
1046
- return `${ key } ${ spaces } ${ ql } ${ importPathname } .${ dep . hash . slice ( 0 , hashShortLength ) } .js${ qr } `
1047
- }
1048
- return s
1049
- } )
1050
- await ensureTextFile ( mod . jsFile , jsContent )
1051
- callback ( mod )
1052
- log . debug ( 'compilation side-effect:' , mod . url , colors . dim ( '<-' ) , url )
1053
- this . checkCompilationSideEffect ( mod . url , callback )
1054
- }
1027
+ const relativePathname = getRelativePath (
1028
+ path . dirname ( toLocalUrl ( mod . url ) ) ,
1029
+ trimModuleExt ( toLocalUrl ( dep . url ) )
1030
+ )
1031
+ const jsContent = ( await Deno . readTextFile ( mod . jsFile ) )
1032
+ . replace ( reHashResolve , ( s , key , spaces , ql , importPath , qr ) => {
1033
+ const importPathname = importPath . replace ( reHashJs , '' )
1034
+ if ( importPathname === dep . url || importPathname === relativePathname ) {
1035
+ return `${ key } ${ spaces } ${ ql } ${ importPathname } .${ hash . slice ( 0 , hashShortLength ) } .js${ qr } `
1036
+ }
1037
+ return s
1038
+ } )
1039
+ await ensureTextFile ( mod . jsFile , jsContent )
1040
+ callback ( mod )
1041
+ log . debug ( 'compilation side-effect:' , mod . url , colors . dim ( '<-' ) , url )
1042
+ this . checkCompilationSideEffect ( mod . url , callback )
1055
1043
break
1056
1044
}
1057
1045
}
0 commit comments