evidence-dev / evidence

Business intelligence as code: build fast, interactive data visualizations in pure SQL and markdown
https://evidence.dev
MIT License
4.47k stars 215 forks source link

fix: validate plugins using node module resolution #2803

Open mnahkies opened 5 days ago

mnahkies commented 5 days ago

Description

in a similar vein to https://github.com/evidence-dev/evidence/pull/2755 resolve the location of plugins using createRequire such that packages hoisted by yarn can be discovered in a mono repo using yarn workspaces

solves errors like:

[!] "@evidence-dev/core-components" could not be found in your node_modules. Check for spelling errors or try running npm install.
[!] "@evidence-dev/bigquery" could not be found in your node_modules. Check for spelling errors or try running npm install.
[!] "@evidence-dev/csv" could not be found in your node_modules. Check for spelling errors or try running npm install.

with this change I can almost get the sample project to work as a yarn workspace

Checklist

mnahkies commented 4 days ago

with this change I can almost get the sample project to work as a yarn workspace

With these changes I can get the sample project to work as a yarn workspace, if I:

Added dependencies:

{
    "@evidence-dev/trino": "^1.0.8",
    "@sveltejs/kit": "2.5.4",
    "@sveltejs/vite-plugin-svelte": "^3.0.0",
    "autoprefixer": "^10.4.20",
    "debounce": "^1.2.1",
    "git-remote-origin-url": "^4.0.0",
    "postcss": "^8.4.49",
    "postcss-load-config": "^4.0.1",
    "svelte": "4.2.19",
    "svelte-preprocess": "5.1.3",
    "svelte2tsx": "0.7.4",
    "tailwindcss": "^3.4.15",
    "unist-util-visit": "4.1.2",
    "vite": "^5.4.11"
}

I'm not sure why npx isn't working for the vite commands yet, I can't spot any obvious reason this would work with the same project by itself, but not in a yarn workspace.

ItsMeBrianD commented 4 days ago

Hey @mnahkies!

Thanks for the second PR here, appreciate you looking into yarn monorepo support! I've actually just merged #2801 which completely removes the plugin connector (it's been deprecated for a little while in favor of the SDK).

Would you mind taking another look here to see what is missing in the SDK version of this functionality? It would also be helpful to have an example yarn workspace that you are trying to work in - I haven't used yarn and would love to capture this for testing internally as well.