0.0.2 • Published 3 years ago

rollup-plugin-swc2 v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

rollup-plugin-swc2

A rollup plugin that uses swc compiler to transform your codes

install

@swc/core as a peerDependency, you should also install it

npm i -D rollup-plugin-swc2 @swc/core
yarn add -D rollup-plugin-swc2 @swc/core

how to use

// options can pass
export interface Options {
  include?: FilterPattern;
  exclude?: FilterPattern; // default /node_modules/
  swcTransformOptions?: swc.Options; // @swc/core config
}

check https://swc.rs/docs/configuring-swc to see all @swc/core configuration

// in your rollup.config.ts
// demo below

import swc from "rollup-plugin-swc2";
import imp from "rollup-plugin-imp";

const config = {
  plugins: [
    nodeResolve(),
    commonjs(),
    imp({
      libList: [
        {
          libName: "akagami-ui",
          libDirectory: "lib",
          camel2DashComponentName: true, // required => TableColumn - table-column
          style(name) {
            return `akagami-ui/lib/${name}/style/index.css`;
          },
        },
      ],
    }),
    swc({
      // demo config
      swcTransformOptions: {
        jsc: {
          externalHelpers: true,
          parser: {
            syntax: "typescript",
            tsx: true,
            dynamicImport: true
          },
          transform: {
            react: {
              pragma: "React.createElement",
              pragmaFrag: "React.Fragment",
              throwIfNamespace: true,
              development: false,
              useBuiltins: false,
            },
          },
        },
      },
    }),
    postcss({
      minimize: false,
      autoModules: true,
    }),
  ],
};
0.0.2

3 years ago

0.0.1

3 years ago