SQLite module fails to be fetched in final build #1907
Description
I'm trying to use SQLite to make some proofs of concept. I started the vanilla project with npx "@observablehq/framework@latest" create
and replaced the example-report.md
with
---
title: Example report
theme: [light, wide]
---
```js
import SQLite from "npm:@observablehq/sqlite";
```
```js
const db = FileAttachment("./data/senators.db").sqlite();
```
```js
const customers = await db.sql`SELECT * FROM Senator ORDER BY name`;
const vote = await db.sql`SELECT * FROM VOTE`;
```
The code runs ok locally with npm run dev
but if I deploy it to observable (npm run deploy
) cloud or azure storage to host it, it fails to fetch some sqlite library
TypeError: Failed to fetch dynamically imported module: https://testworkspace7.observablehq.cloud/ausentometro-frontend/_observablehq/stdlib/sqlite.5da89048.js
RuntimeError: Failed to fetch dynamically imported module: https://testworkspace7.observablehq.cloud/ausentometro-frontend/_observablehq/stdlib/sqlite.5da89048.js
And the console output is from the observable cloud workspace hosted page
Failed to load resource: the server responded with a status of 404 () _npm/sql.js@1.12.0/_esm.js:1
client.072151fd.js:1 TypeError: Failed to fetch dynamically imported module: https://testworkspace7.observablehq.cloud/ausentometro-frontend/_observablehq/stdlib/sqlite.5da89048.js
reject @ client.072151fd.js:1
client.072151fd.js:1 RuntimeError: Failed to fetch dynamically imported module: https://testworkspace7.observablehq.cloud/ausentometro-frontend/_observablehq/stdlib/sqlite.5da89048.js
at runtime.f168f711.js:7:7680
at async Promise.all (index 0)
Obviously the hostname https://testworkspace7.observablehq.cloud/ausentometro-frontend
changes depending on where it is hosted, so it doesn't seem to be a problem with the observable cloud, but rather a problem with how the final build dist
folder is handling the files.
The file _npm/sql.js@1.12.0/_esm.js
doesn't exist in the final dist
folder. The other file mentioned sqlite.5da89048.js
does exist.