FYI, Vite development mode, stalls on Generating Clusters...
Weirdly if you don't add
optimizeDeps: {
exclude: ["embedding-atlas"],
},
to the vite config, the generate clusters functionality doesn't work and stays with the statusMessage of Generating Clusters... forever.
Just wanted to note that here in case anyone else has run into this issue and needs a solution for vite development.
Minimal reproduction in this repo: https://github.com/xnought/test-embedding-atlas/blob/main/vite.config.js#L8
Shoot ran into a separate issue: In a separate project the embedding-atlas workers are being blocked by Cross-Origin-Embedder-Policy. If you have any tips, would be very thankful!
update: can solve this by adding correct headers onto workers as a vite plugin (my case using svelte-kit). Gnarly though
function coepHeadersPlugin() {
return {
name: 'coep-headers',
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url?.includes('worker.js')) {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
}
next();
});
}
};
}
The issue regarding optimizeDeps might be related to the fact that Vite bundles the dependencies in the process. See this: https://github.com/vitejs/vite/issues/10839#issuecomment-1345193175
We are already using a standard way of importing the worker in the released package:
new Worker(new URL("./clustering.worker.js", import.meta.url), { type: "module" })
If this causes many problems maybe we should consider inlining the worker (aka., use a dataurl instead of importing from a file)?
Oh I see. yeah It's probably because I'm running bun workspaces so the worker file is outside the scope of the vite server (node_modules in parent) so my browser thinks its a cross origin resource or something.
Yeah this is probably just a me problem. So no worries! Thank you though, I appreciate the response. I'm really loving embedding atlas!