WebAssembly exported function: Cannot read properties of undefined

I’m trying to run lightningcss on a WebWorker module for my JavaScript application.

I imported it as a module as follows:

import * as lightningcss from './index.mjs';

and tried using the function as below:

let code = lightningcss.transform({
    code: bufferedTextInput,
    minify: true,
    sourceMap: false
});

However, on running the script in my browser, I encountered the following error:

index.mjs:41 Uncaught TypeError: Cannot read properties of undefined (reading 'transform')
    at Module.transform (index.mjs:41:15)
    at wasm-worker.js:9:29

I tried troubleshooting on the web but to no avail. How would I go about fixing this problem?