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:
Cloned the repo (to reproduce, delete your local directory and re-clone)
npm install
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.
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:
npm install
npm test
That results in an error:
Similar for
npm run dev
, that results in a similar errorAnd 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:
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.