How to use the @swc/core.transform function in @swc/core

To help you get started, we’ve selected a few @swc/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stefanpenner / broccoli-swc / index.js View on Github external
async processString(content, relativePath) {
    const options = {...this.swcOptions};
    options.module = {...options.module} || {};

    if (options.module.type === 'amd' && this.options.namedAmd || options.module.moduleId === true) {
      options.module.moduleId = relativePath.replace(/\.(?:js|ts)$/, '');
    }

    options.jsc = options.jsc || {};
    if (relativePath.endsWith('.ts') && options.jsc.parser === undefined) {
      options.jsc.parser = {
        "syntax": "typescript",
      }
    }
    const { code } = await swc.transform(content, options);
    return code;
  }
github theKashey / devolution / src / workers / transpile.js View on Github external
const compileSWC = async (code, minify) => {
  const {transform} = require("@swc/core");

  return (await transform(code, {
    "minify": minify,
    "module": {
      "type": "commonjs",
      "strict": false,
      "strictMode": false,
    },
    "jsc": {
      "parser": {
        "syntax": "ecmascript",
        "classProperty": true
      },
      "target": "es5",
      "transform": {
        "optimizer": undefined
      }
    }

@swc/core

Super-fast alternative for babel

Apache-2.0
Latest version published 13 days ago

Package Health Score

95 / 100
Full package analysis

Popular @swc/core functions