Rollup plugin to preserve shebang and string directives (e.g., 'use strict') in bundled output. Current stable version 1.1.3, maintained actively. No external dependencies, ships TypeScript types. Key differentiator: handles shebang and directives that Rollup's tree-shaking may remove, and exposes metadata for inter-plugin communication. Renamed from rollup-swc-preserve-directives in v1.0.0.
npm install rollup-preserve-directivesVerified import paths — ran on the pinned version, not inferred.
Basic rollup.config.js configuration showing how to use the plugin to preserve shebang and directives.
Uninstall old package: npm uninstall rollup-swc-preserve-directives. Install new: npm install rollup-preserve-directives. Update import.
No change needed unless you relied on swc-specific behavior. Remove any swc options from plugin call.
Upgrade to v1.0.0+ and rename package.
Ensure your config file uses ES module syntax (export default) and has .mjs extension or package.json type: module.
Use this.getModuleInfo or moduleParsed hook to check directives metadata.
Use import syntax or rename config file to .mjs.
Run npm install rollup-preserve-directives.
Use import preserveDirectives from 'rollup-preserve-directives' (default import).
No dependency data recorded yet.