Rollup plugin that uses SWC to preserve directives such as shebang and string directives (e.g., 'use strict', 'use asm') in bundled output. Version 0.7.0 is the latest stable; updated on demand. It integrates with Rollup build pipeline to ensure important code-level annotations are not stripped during minification or transformation, unlike naive bundlers. Differentiates itself by being SWC-based (fast, Rust-powered) and designed specifically for directive preservation.
npm install rollup-swc-preserve-directivesVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of rollup-swc-preserve-directives plugin in a Rollup config to preserve directives during bundling.
Use @swc/core version compatible with the SWC version used by this plugin; check package.json peerDependencies.
Upgrade Rollup to ^4.0.0 if encountering issues, or pin to older plugin version.
Use @rollup/plugin-typescript or @rollup/plugin-sucrase for TS before this plugin.
Run `npm install @swc/core` in your project directory.
Use `import swcPreserveDirectives from 'rollup-swc-preserve-directives'` (no curly braces).