Registry / type-stubs / metro-minify-swc

metro-minify-swc

JSON →
library1.0.0-alphajsnpmunverified

A drop-in replacement minifier for Metro bundler that uses SWC (Speedy Web Compiler) for fast JavaScript minification. Version 1.0.0-alpha is experimental and may not be stable. SWC's Rust-based implementation aims to provide better performance than Metro's default minifier. Requires metro >=0.80.0. Provides TypeScript types.

npm install metro-minify-swc
INSTALL
IMPORT
SIG · METRO-MINIFY-SWC
M
metro-minify-swc
type-stubsjavascriptv1.0.0-alpha
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const minifier = require('metro-minify-swc');
import minifier from 'metro-minify-swc';
Package uses CommonJS exports; ESM import is not available.
minifier (named)
const { minifier } = require('metro-minify-swc');
import { minifier } from 'metro-minify-swc';
The default export is the minifier function, so destructuring may not work as expected. Prefer default import.
minifierPath in metro.config.js
minifierPath: 'metro-minify-swc'
minifierPath: 'metro-minify-swc/index.js'
Metro resolves the module automatically; specifying an index file is redundant and may cause resolution errors.

Shows how to configure Metro's transformer to use metro-minify-swc with custom compress and mangle options.

// metro.config.js module.exports = { transformer: { minifierPath: 'metro-minify-swc', minifierConfig: { compress: { drop_console: true, unused: true, }, mangle: { toplevel: true, }, }, }, };
Debug
Known issues
deprecatedPackage is 1.0.0-alpha and experimental; API may change without notice.
fix
Pin exact version and monitor releases for breaking changes.
affects: 1.0.0-alpha
gotchaminifierConfig must be an object; passing undefined or null can cause errors.
fix
Always provide an empty object if no configuration is needed: minifierConfig: {}.
affects: >=0.0.0
gotchaMetro's default minifier options are not automatically applied; you must specify all desired options.
fix
Explicitly set all minifier options in minifierConfig, including defaults.
affects: >=0.0.0
gotchaSWC minifier may produce slightly different output than Metro's default (Terser-based) minifier; test thoroughly.
fix
Verify bundle behavior in development and production environments.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'metro-minify-swc'
Package not installed or not in node_modules.
fix
Run npm install --save-dev metro-minify-swc (or yarn/pnpm equivalent).
Error: Minifier path not found: metro-minify-swc
Metro cannot resolve the minifier module.
fix
Ensure the package is installed and check that metro.config.js uses the correct string for minifierPath.
TypeError: Cannot read properties of undefined (reading 'compress')
minifierConfig is undefined or not an object.
fix
Set minifierConfig to an empty object or a proper configuration object.
Upgrade
Version history
1.0.0-alphalatest on npm
Audit
Dependencies
metrorequiredpeer dependency - required to be installed as the bundler that this minifier plugs into
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
metro-minify-swc — npm install metro-minify-swc · libregistry