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

import working in dev but not production #57

Open
FUTC-Coding opened this issue Apr 14, 2024 · 1 comment
Open

import working in dev but not production #57

FUTC-Coding opened this issue Apr 14, 2024 · 1 comment

Comments

@FUTC-Coding
Copy link

Hey there, I'm pretty new to wasm, and I don't know if this is an issue with vite-plugin-wasm or something to do with my setup, but this problem has been driving me crazy. In dev mode everything works perfectly fine, here is my vite.config.js:

import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';

export default {
    base: "/Halationify/",
    plugins: [
        wasm(),
        topLevelAwait()
    ],
    worker: {
        rollupOptions: {
            output: {
                format: "iife",
                inlineDynamicImports: true,
            }
        },
        plugins: () => {
            return [wasm(), topLevelAwait()]
        }
    },
};

I am using vite and runnning @silvia-odwyer/photon in a webworker to do some image processing. I simply import with const photon = await import('@silvia-odwyer/photon'); in the webworker.

Unfortunately, when building for production the import doesn't seem to work correctly and photon is undefined when the webworker executes, I think the wasm library isn't being bundled correctly. My project can be found here and the webworker where photon is imported can be found here. Thank you for making this plugin, and I hope somebody has a solution.

@json91-dev
Copy link

Me either .

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

No branches or pull requests

2 participants