Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add an example using vite as a JS/TS build tool #172

Open
nmrshll opened this issue Jan 7, 2024 · 2 comments · May be fixed by #173
Open

Add an example using vite as a JS/TS build tool #172

nmrshll opened this issue Jan 7, 2024 · 2 comments · May be fixed by #173

Comments

@nmrshll
Copy link
Contributor

nmrshll commented Jan 7, 2024

For a few reasons it was a bit harder than expected adapting the examples to work with Vite (+solid-js): I hit a few problems which weren't obvious to troubleshoot.

I'm planning on adding a web target to the counter example, using Vite and SolidJs.

@nmrshll nmrshll linked a pull request Jan 8, 2024 that will close this issue
@charypar
Copy link
Member

Thanks for this!

For posterity, would you mind elaborating on the issues you hit, in case some other frameworks face similar problems?

@nmrshll
Copy link
Contributor Author

nmrshll commented Feb 16, 2024

Ah sorry I had missed your message, and I've since then forgotten the details of the problems I ran into.

From vague memory, I had two problems, with the javascript tooling stack rather than the code itself:

  1. in the package.json dependencies, using link:... for the shared libraries didn't work for some reason (the wasm would fail loading at runtime in the browser). Using file:... instead worked:
    "shared": "file:../shared/pkg",
    "shared_types": "file:../shared_types/generated/typescript",
  1. In the vite.config.ts file (default file provided with the official solidjs/vite template), I needed to explicitly tell vite to not optimize the shared wasm dependency:
export default defineConfig({
  plugins: [solid()],
  optimizeDeps: {
    exclude: ["shared"],
  },
});

Otherwise, if I remember right, the wasm would have missing symbols when called at runtime.

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

Successfully merging a pull request may close this issue.

2 participants