Skip to content

copy crates failed with solidstart/vinxi solution #35

@zhengkyl

Description

@zhengkyl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions