Skip to content

@swc/html fails to import on WebContainer/StackBlitz #11833

@slorber

Description

@slorber

Describe the bug

It seems it's not possible to import @swc/html in a StackBlitz WebContainer sandbox, probably due to a Wasm binding problem?

Input code

async function test1() {
  await import('@swc/core');
}

async function test2() {
  await import('@swc/html');
}

async function testAll() {
  return Promise.allSettled([test1(), test2()]);
}

testAll().then(console.log, console.error);

Config

Link to the code that reproduces this issue

https://stackblitz.com/edit/stackblitz-starters-apgxgccc?file=package.json,index.js

SWC Info output

No response

Expected behavior

@swc/html can be imported in a StackBlitz WebContainer sandbox

Actual behavior

@swc/html fails to import due to binding issues, while @swc/core can be imported successfully

node index.js
[
  { status: 'fulfilled', value: undefined },
  {
    status: 'rejected',
    reason: Error: Failed to load native binding
        at Object.eval (/home/projects/stackblitz-starters-apgxgccc/node_modules/@swc/html/binding.js:350:15)
        at Module._compile (node:internal/modules/cjs/loader:160:18351)
        at Module._extensions..js (node:internal/modules/cjs/loader:160:19092)
        at Module.load (node:internal/modules/cjs/loader:160:16623)
        at Module._load (node:internal/modules/cjs/loader:160:14286)
        at TracingChannel.traceSync (node:diagnostics_channel:26:3678)
        at wrapModuleLoad (node:internal/modules/cjs/loader:160:3949)
        at Module.require (node:internal/modules/cjs/loader:160:16804)
        at require2 (node:internal/modules/helpers:177:3120)
  }

Version

1.15.32

Additional context

StackBlitz repro: https://stackblitz.com/edit/stackblitz-starters-apgxgccc?file=package.json,index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions