A Babel plugin that transforms ES6 imports of PrismJS to include only specified languages, plugins, and themes, enabling tree-shaking and reduced bundle sizes for syntax highlighting. Version 2.1.0 is current, with stable release cadence. Requires Babel and PrismJS v1.18+. Key differentiator: automatically configures Prism for bundlers like Webpack without manual setup. Caveats: only works with ES6 import syntax, not CommonJS (require).
npm install babel-plugin-prismjsVerified import paths — ran on the pinned version, not inferred.
Configures Babel to bundle only JavaScript, CSS, and markup languages with line-numbers plugin and twilight theme, then imports and applies Prism syntax highlighting.
Use import Prism from 'prismjs' instead of require()
Explicitly list all languages needed in the languages array
Set "css": true in plugin options if using a theme
Ensure Babel is set up and the plugin is included; if running directly in Node, use .mjs extension or type: module in package.json
Replace const Prism = require('prismjs') with import Prism from 'prismjs'