Skip to content

Commit 2e4b4cf

Browse files
committed
single-file render also need to use the specific Map for fileInformationCache
1 parent 032a5b8 commit 2e4b4cf

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/project/project-context.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { projectResourceFiles } from "./project-resources.ts";
7171

7272
import {
7373
cleanupFileInformationCache,
74+
FileInformationCacheMap,
7475
ignoreFieldsForProjectType,
7576
normalizeFormatYaml,
7677
projectConfigFile,
@@ -107,16 +108,6 @@ import { createTempContext } from "../core/temp.ts";
107108

108109
import { onCleanup } from "../core/cleanup.ts";
109110
import { once } from "../core/once.ts";
110-
import { Cloneable } from "../core/safe-clone-deep.ts";
111-
112-
// Create a class that extends Map and implements Cloneable
113-
class FileInformationCacheMap extends Map<string, FileInformation>
114-
implements Cloneable<Map<string, FileInformation>> {
115-
clone(): Map<string, FileInformation> {
116-
// Return the same instance (reference) instead of creating a clone
117-
return this;
118-
}
119-
}
120111

121112
export async function projectContext(
122113
path: string,

src/project/project-shared.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { refSchema } from "../core/lib/yaml-schema/common.ts";
5050
import { Zod } from "../resources/types/zod/schema-types.ts";
5151
import { Brand } from "../core/brand/brand.ts";
5252
import { assert } from "testing/asserts";
53+
import { Cloneable } from "../core/safe-clone-deep.ts";
5354

5455
export function projectExcludeDirs(context: ProjectContext): string[] {
5556
const outputDir = projectOutputDir(context);
@@ -633,6 +634,15 @@ export async function projectResolveBrand(
633634
}
634635
}
635636

637+
// Create a class that extends Map and implements Cloneable
638+
export class FileInformationCacheMap extends Map<string, FileInformation>
639+
implements Cloneable<Map<string, FileInformation>> {
640+
clone(): Map<string, FileInformation> {
641+
// Return the same instance (reference) instead of creating a clone
642+
return this;
643+
}
644+
}
645+
636646
export function cleanupFileInformationCache(project: ProjectContext) {
637647
project.fileInformationCache.forEach((entry) => {
638648
if (entry?.target?.data) {

src/project/types/single-file/single-file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { MappedString } from "../../../core/mapped-text.ts";
2121
import { fileExecutionEngineAndTarget } from "../../../execute/engine.ts";
2222
import {
2323
cleanupFileInformationCache,
24+
FileInformationCacheMap,
2425
projectFileMetadata,
2526
projectResolveBrand,
2627
projectResolveFullMarkdownForFile,
@@ -49,7 +50,7 @@ export async function singleFileProjectContext(
4950
notebookContext,
5051
environment: () => environmentMemoizer(result),
5152
renderFormats,
52-
fileInformationCache: new Map(),
53+
fileInformationCache: new FileInformationCacheMap(),
5354
fileExecutionEngineAndTarget: (
5455
file: string,
5556
) => {

0 commit comments

Comments
 (0)