Skip to main content

Experimental swc support

Packemon has experimental support for swc, a Rust based compiler, and a drop-in replacement for Babel. If you want improved performance for less features, we suggest swc.

Enabling swc

There are 3 ways to enable swc:

Define the PACKEMON_SWC environment variable.

PACKEMON_SWC=true packemon build

Enable for all packages through a root packemon.config.{js,ts} (requires --loadConfigs).

module.exports = {
swc: true,

Enable for individual packages through a .packemon.{js,ts} in each package. (requires --loadConfigs).

module.exports = {
swc: true,

Unsupported features

Compared to the Babel implementation, our swc implementation does not support the following features.

  • Flow syntax parsing and transforming.
  • UMD namespace (swc uses the filename as the namespace).
  • Bundled helpers like Babel (swc inlines them in each file).
  • Granular plugin control like Babel.
  • Equivalent custom plugins:
    • babel-plugin-cjs-esm-interop
    • babel-plugin-conditional-invariant

Differences between Babel

  • Env constants (__DEV__, __PROD__, and __TEST__) use jsc.transform.optimizer.globals to substitute conditionals. Since we can't use a real plugin, the scenarios in which these constants are replaced may differ between the Babel version.