rollup-plugin-swc icon indicating copy to clipboard operation
rollup-plugin-swc copied to clipboard

Deno

Open DrSensor opened this issue 2 years ago • 3 comments

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)

DrSensor avatar Jan 03 '23 14:01 DrSensor

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.

SukkaW avatar Jan 17 '23 18:01 SukkaW

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

DrSensor avatar Jan 18 '23 01:01 DrSensor

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.

so1ve avatar May 22 '23 16:05 so1ve