Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

copy crates failed with solidstart/vinxi solution #35

Open
zhengkyl opened this issue Jul 10, 2024 · 0 comments
Open

copy crates failed with solidstart/vinxi solution #35

zhengkyl opened this issue Jul 10, 2024 · 0 comments

Comments

@zhengkyl
Copy link

I'm using solid-start and trying to load a local package.

If the node_modules/mypackage folder doesn't exist or it exists but isn't empty, I get the error.

I know this part of the buildStart() hook is where the error happens.

try {
await fs.copy(pkgPath, path.join('node_modules', crateName));
} catch (error) {
this.error(`copy crates failed: ${error}`);
}

The buildStart() gets called 3 times because vinxi (used by solidstart) starts 3 apps with the same vite config as explained here (nksaraf/vinxi#262 (comment))

It makes sense that running await fs.copy 3 times at once causes issues. And the comment suggests this as a solution which worked for me.

import { defineConfig } from "@solidjs/start/config";
import wasmpack from "vite-plugin-wasm-pack";

export default defineConfig({
  vite({ router }) {
    return {
      plugins: router === "client" ? [wasmpack("./mypackage")] : []
    }
  }
})

I don't know if this is something this plugin could/should address, but I hope this solution helps someone else.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant