@@ -83,7 +83,7 @@ export const builtins = new Map<string, string>([
83
83
* them to any files referenced by static HTML.
84
84
*/
85
85
export async function getResolvers ( page : MarkdownPage , config : ResolversConfig ) : Promise < Resolvers > {
86
- const { root , path, globalStylesheets : defaultStylesheets , loaders} = config ;
86
+ const { path, globalStylesheets : defaultStylesheets , loaders} = config ;
87
87
const hash = createHash ( "sha256" ) . update ( page . body ) . update ( JSON . stringify ( page . data ) ) ;
88
88
const assets = new Set < string > ( ) ;
89
89
const files = new Set < string > ( ) ;
@@ -131,7 +131,7 @@ export async function getResolvers(page: MarkdownPage, config: ResolversConfig):
131
131
// Compute the content hash.
132
132
for ( const f of assets ) hash . update ( loaders . getSourceFileHash ( resolvePath ( path , f ) ) ) ;
133
133
for ( const f of files ) hash . update ( loaders . getSourceFileHash ( resolvePath ( path , f ) ) ) ;
134
- for ( const i of localImports ) hash . update ( getModuleHash ( root , resolvePath ( path , i ) ) ) ;
134
+ for ( const i of localImports ) hash . update ( loaders . getModuleHash ( resolvePath ( path , i ) ) ) ;
135
135
if ( page . style && isPathImport ( page . style ) ) hash . update ( loaders . getSourceFileHash ( resolvePath ( path , page . style ) ) ) ;
136
136
137
137
// Add implicit imports for standard library built-ins, such as d3 and Plot.
@@ -332,7 +332,7 @@ async function resolveResolvers(
332
332
333
333
function resolveImport ( specifier : string ) : string {
334
334
return isPathImport ( specifier )
335
- ? relativePath ( path , resolveImportPath ( root , resolvePath ( path , specifier ) ) )
335
+ ? relativePath ( path , loaders . resolveImportPath ( resolvePath ( path , specifier ) ) )
336
336
: builtins . has ( specifier )
337
337
? relativePath ( path , builtins . get ( specifier ) ! )
338
338
: specifier . startsWith ( "observablehq:" )
@@ -435,11 +435,12 @@ export async function getModuleStaticImports(root: string, path: string): Promis
435
435
export function getModuleResolver (
436
436
root : string ,
437
437
path : string ,
438
- servePath = `/${ join ( "_import" , path ) } `
438
+ servePath = `/${ join ( "_import" , path ) } ` ,
439
+ getHash ?: ( path : string ) => string
439
440
) : ( specifier : string ) => Promise < string > {
440
441
return async ( specifier ) => {
441
442
return isPathImport ( specifier )
442
- ? relativePath ( servePath , resolveImportPath ( root , resolvePath ( path , specifier ) ) )
443
+ ? relativePath ( servePath , resolveImportPath ( root , resolvePath ( path , specifier ) , getHash ) )
443
444
: builtins . has ( specifier )
444
445
? relativePath ( servePath , builtins . get ( specifier ) ! )
445
446
: specifier . startsWith ( "observablehq:" )
@@ -456,8 +457,8 @@ export function resolveStylesheetPath(root: string, path: string): string {
456
457
return `/${ join ( "_import" , path ) } ?sha=${ getFileHash ( root , path ) } ` ;
457
458
}
458
459
459
- export function resolveImportPath ( root : string , path : string ) : string {
460
- return `/${ join ( "_import" , path ) } ?sha=${ getModuleHash ( root , path ) } ` ;
460
+ export function resolveImportPath ( root : string , path : string , getHash ?: ( name : string ) => string ) : string {
461
+ return `/${ join ( "_import" , path ) } ?sha=${ getModuleHash ( root , path , getHash ) } ` ;
461
462
}
462
463
463
464
// Returns any inputs that are not declared in outputs. These typically refer to
0 commit comments