Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swc-plugin-transform-cx-imports

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swc-plugin-transform-cx-imports

Rewrite Cx imports for simplicity and optimal output size.

  • 24.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
166
increased by22.06%
Maintainers
3
Weekly downloads
 
Created
Source

swc-plugin-transform-cx-imports

Having improved performance, this plugin replaces babel-plugin-transform-cx-imports.

What is this plugin used for?

  1. Rewrites Cx imports to use src files which may result in smaller builds:

import { TextField } from 'cx/widgets'

becomes

import { TextField } from 'cx/src/form/TextField'

  1. Includes SCSS files for imported components (experimental):

import { TextField } from 'cx/widgets'

also adds

import 'cx/src/form/TextField.scss'

Installation

  1. Install the package using the yarn add swc-plugin-transform-cx-imports command. This plugin requires another plugin, which you can install using the yarn add swc-plugin-transform-cx-jsx.

  2. Inside the webpack.config.js file, import manifest from 'cx/manifest' - const manifest = require('cx/manifest');, and replace babel-loader with swc-loader:

{
  loader: 'swc-loader',
  options: {
    jsc: {
        loose: true,
        target: 'es2022',
        parser: {
          syntax: 'typescript',
          decorators: true,
          tsx: true,
        },
        experimental: {
          plugins: [
              [
                require.resolve('swc-plugin-transform-cx-jsx/swc_plugin_transform_cx_jsx_bg.wasm'),
                { trimWhitespace: true, autoImportHtmlElement: true },
              ],
              [
                require.resolve('swc-plugin-transform-cx-imports/swc_plugin_transform_cx_imports_bg.wasm'),
                { manifest, useSrc: true },
              ],
          ],
        },
        transform: {
          react: {
              pragma: 'VDOM.createElement',
          },
        },
    },
  },
}

Keywords

FAQs

Package last updated on 10 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc