rsms / markdown-wasm

Very fast Markdown parser and HTML generator implemented in WebAssembly, based on md4c
https://rsms.me/markdown-wasm/
MIT License
1.51k stars 62 forks source link

TypeError: Cannot set property exports of undefined #18

Open aminya opened 3 years ago

aminya commented 3 years ago

I am trying to use this package inside Atom, which is an Electron app. I used the following code to load and instantiate the wasm module asynchronously because Electron doesn't allow compiling large wasm files on the main thread.

  if (markdown_parse === undefined) {
    // wasm should be loaded async
    // @ts-ignore
    const markdown_wasm = (await import("markdown-wasm/dist/markdown.es")) as typeof import("markdown-wasm") & {
      ready: Promise<void>
    }
    // instantiate wasm
    await markdown_wasm.ready
    markdown_parse = markdown_wasm.parse
  }

I use Rollup as my compiler.

However, when I bundle the application I get these errors:

TypeError: Cannot set property exports of undefined

image

image

image