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

Deno #30

Open
DrSensor opened this issue Jan 3, 2023 · 3 comments
Open

Deno #30

DrSensor opened this issue Jan 3, 2023 · 3 comments

Comments

@DrSensor
Copy link

DrSensor commented Jan 3, 2023

Hi, is there an option to swap the SWC internal with wasm version instead of the default node addon?

Something like

import { rollup } from "npm:rollup"
import { swc } from "npm:rollup-plugin-swc3"

const build = await rollup({
  input: ["main.ts", "lib.mts"],
  plugins: [
    swc({
      wasm: "https://esm.sh/@swc/wasm-web/wasm_bg.wasm"
    }),
  ],
})
await build.write({ dir: "dist", format: "es" })
Just got an error with the default one since Deno doesn't support Node native addons
Error: Failed to convert napi value into rust type `Option<T>`
    at Compiler.<anonymous> (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/@swc/core/1.3.24/index.js:216:33)
    at (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/@swc/core/1.3.24/index.js:34:71)
    at __awaiter (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/@swc/core/1.3.24/index.js:30:12)
    at Compiler.transform (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/@swc/core/1.3.24/index.js:202:16)
    at transform (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/@swc/core/1.3.24/index.js:344:21)
    at Object.transform (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/rollup-plugin-swc3/0.8.0/dist/index.mjs:129:20)
    at (file:///home/wildan/.cache/deno/npm/registry.npmjs.org/rollup/3.9.1/dist/es/shared/rollup.js:23660:40)
@SukkaW
Copy link
Owner

SukkaW commented Jan 17, 2023

Hi, is there an option to swap the SWC internal with wasm version instead of the default node addon?

I am still figuring out how to fallback from @swc/core to @swc/wasm.

Generally, I'd prefer @swc/core whenever possible. @swc/core is significantly faster than @swc/wasm.

@DrSensor
Copy link
Author

I've done some experiment to integrate @swc/wasm with es-module-shims in the past.
Hope that can help.

@so1ve
Copy link

so1ve commented May 22, 2023

Hi, is there an option to swap the SWC internal with wasm version instead of the default node addon?

I am still figuring out how to fallback from @swc/core to @swc/wasm.

Generally, I'd prefer @swc/core whenever possible. @swc/core is significantly faster than @swc/wasm.

There is a hack: map @swc/core to @swc/wasm in deno's import map.

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

3 participants