Skip to content

import working in dev but not production #57

Open
@FUTC-Coding

Description

@FUTC-Coding

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.

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