SummerForeverCo / duck-plot

Connecting DuckDB to Observable Plot
https://summerforeverco.github.io/duck-plot/
MIT License
1 stars 0 forks source link

Run build command before other commands #13

Closed tylergaw closed 2 months ago

tylergaw commented 3 months ago

This is to help anyone working on this locally. The scripts dev, test, etc should all run build before to make sure the build files exist to avoid a first run error.

Why?

When I first cloned the repo and tried to get running locally, I ran into errors. I did this:

  1. Cloned the repo (to reproduce, delete your local directory and re-clone)
  2. npm install
  3. npm test

That results in an error:

Error: Failed to load url ../dist/index.es (resolved id: ../dist/index.es) in /Users/tylergaw/workspace/summer/duck-plot/test/duckplot.test.ts. Does the file exist?

Similar for npm run dev, that results in a similar error

[vite] Internal server error: Failed to resolve import "../dist/index.es" from "examples/index.client.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/tylergaw/workspace/summer/duck-plot/examples/index.client.js:1:27
  1  |  import { DuckPlot } from "../dist/index.es";
     |                            ^
  2  |  import "../dist/style.css";
  3  |  import * as plots from "./plots/index.js";

And that's just because the built files don't exist yet

What do?

Can throw the build command in front of the scripts something like:

"test": "npm run build && vitest run",
"dev": "npm run build && vite",

and any others that need it

If we don't want that to happen every time, we could also do a quick check with bash to see if the built files exist already, but probably not needed.

mkfreeman commented 3 months ago

This is a good idea!