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

Demo page not working: function import requires a callable #547

Closed
ExpandOcean opened this issue Jun 28, 2024 · 2 comments
Closed

Demo page not working: function import requires a callable #547

ExpandOcean opened this issue Jun 28, 2024 · 2 comments

Comments

@ExpandOcean
Copy link

Hello, thanks for this awesome project!

I am working on a simple demo but the wasm loading always failed.
Even the demo page failed. Does a mismatch between js and wasm cause this?

LinkError: WebAssembly.instantiate(): Import #3 "wbg" "__wbg_set_f975102236d3c502": function import requires a callable
image

@Myriad-Dreamin
Copy link
Owner

Myriad-Dreamin commented Jun 28, 2024

Seems that npm doesn't cache it correctly (since I published it recently). You can try to add a version after the package names to align the version of these packages:

    <script
      type="module"
      src="https://cdn.jsdelivr.net/npm/@myriaddreamin/[email protected]/dist/esm/contrib/all-in-one-lite.bundle.js"
      id="typst"
    ></script>
     ... long source code then ...
    <script>
     ... long source code then ...
      document.getElementById('typst').addEventListener('load', function () {
        $typst.setCompilerInitOptions({
          getModule: () =>
            'https://cdn.jsdelivr.net/npm/@myriaddreamin/[email protected]/pkg/typst_ts_web_compiler_bg.wasm',
        });
        $typst.setRendererInitOptions({
          getModule: () =>
            'https://cdn.jsdelivr.net/npm/@myriaddreamin/[email protected]/pkg/typst_ts_renderer_bg.wasm',
        });
    </script>

@ExpandOcean
Copy link
Author

It works! Thanks!

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