From fa804894d0de62dd710e5c1b7630df2ded2d9e13 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 3 Sep 2024 08:29:47 -0700 Subject: [PATCH] detect non-local sql tables (#1636) --- src/render.ts | 2 +- src/resolvers.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/render.ts b/src/render.ts index 926f24e19..4b2f2efe3 100644 --- a/src/render.ts +++ b/src/render.ts @@ -59,7 +59,7 @@ if (location.pathname.endsWith("/")) { import ${preview || page.code.length ? `{${preview ? "open, " : ""}define} from ` : ""}${JSON.stringify( resolveImport("observablehq:client") )};${ - files.size || data?.sql + files.size ? `\nimport {registerFile${data?.sql ? ", FileAttachment" : ""}} from ${JSON.stringify( resolveImport("observablehq:stdlib") )};` diff --git a/src/resolvers.ts b/src/resolvers.ts index 7f473607b..7b1a857f0 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -123,8 +123,11 @@ export async function getResolvers( // Add SQL sources. if (page.data.sql) { - for (const source of Object.values(page.data.sql)) { - files.add(String(source)); + for (const value of Object.values(page.data.sql)) { + const source = String(value); + if (isAssetPath(source)) { + files.add(source); + } } }