@@ -83,7 +83,7 @@ export const builtins = new Map<string, string>([
8383 * them to any files referenced by static HTML.
8484 */
8585export async function getResolvers ( page : MarkdownPage , config : ResolversConfig ) : Promise < Resolvers > {
86- const { root , path, globalStylesheets : defaultStylesheets , loaders} = config ;
86+ const { path, globalStylesheets : defaultStylesheets , loaders} = config ;
8787 const hash = createHash ( "sha256" ) . update ( page . body ) . update ( JSON . stringify ( page . data ) ) ;
8888 const assets = new Set < string > ( ) ;
8989 const files = new Set < string > ( ) ;
@@ -131,7 +131,7 @@ export async function getResolvers(page: MarkdownPage, config: ResolversConfig):
131131 // Compute the content hash.
132132 for ( const f of assets ) hash . update ( loaders . getSourceFileHash ( resolvePath ( path , f ) ) ) ;
133133 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 ) ) ) ;
135135 if ( page . style && isPathImport ( page . style ) ) hash . update ( loaders . getSourceFileHash ( resolvePath ( path , page . style ) ) ) ;
136136
137137 // Add implicit imports for standard library built-ins, such as d3 and Plot.
@@ -332,7 +332,7 @@ async function resolveResolvers(
332332
333333 function resolveImport ( specifier : string ) : string {
334334 return isPathImport ( specifier )
335- ? relativePath ( path , resolveImportPath ( root , resolvePath ( path , specifier ) ) )
335+ ? relativePath ( path , loaders . resolveImportPath ( resolvePath ( path , specifier ) ) )
336336 : builtins . has ( specifier )
337337 ? relativePath ( path , builtins . get ( specifier ) ! )
338338 : specifier . startsWith ( "observablehq:" )
@@ -435,11 +435,12 @@ export async function getModuleStaticImports(root: string, path: string): Promis
435435export function getModuleResolver (
436436 root : string ,
437437 path : string ,
438- servePath = `/${ join ( "_import" , path ) } `
438+ servePath = `/${ join ( "_import" , path ) } ` ,
439+ getHash ?: ( path : string ) => string
439440) : ( specifier : string ) => Promise < string > {
440441 return async ( specifier ) => {
441442 return isPathImport ( specifier )
442- ? relativePath ( servePath , resolveImportPath ( root , resolvePath ( path , specifier ) ) )
443+ ? relativePath ( servePath , resolveImportPath ( root , resolvePath ( path , specifier ) , getHash ) )
443444 : builtins . has ( specifier )
444445 ? relativePath ( servePath , builtins . get ( specifier ) ! )
445446 : specifier . startsWith ( "observablehq:" )
@@ -456,8 +457,8 @@ export function resolveStylesheetPath(root: string, path: string): string {
456457 return `/${ join ( "_import" , path ) } ?sha=${ getFileHash ( root , path ) } ` ;
457458}
458459
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 ) } ` ;
461462}
462463
463464// Returns any inputs that are not declared in outputs. These typically refer to
0 commit comments