babel-plugin-transform-modern-regexp

raw JSON →
0.0.6 verified Fri May 01 auth: no javascript deprecated

Babel plugin that transpiles modern RegExp features (dotAll s-flag, named capturing groups, extended x-flag) down to ES5-compatible JavaScript. Current stable version is 0.0.6, last updated in 2019. This plugin has low maintenance cadence and is based on the regexp-tree library. It is a non-standard package, not affiliated with Babel core, and mostly useful for projects that need to support older JavaScript engines without native support for these features.

error Error: Plugin transform-modern-regexp: Unknown plugin "transform-modern-regexp"
cause Babel >=7 does not find the plugin in node_modules or it's not installed.
fix
Install the plugin: npm install babel-plugin-transform-modern-regexp --save-dev
error TypeError: Cannot read property 'features' of undefined
cause Plugin options are malformed; missing plugin object.
fix
Use correct format in .babelrc: ["transform-modern-regexp", { "features": [...] }]
error Error: Cannot find module 'regexp-tree'
cause regexp-tree is a peer dependency of the plugin but not automatically installed.
fix
Run: npm install regexp-tree --save-dev
deprecated Package is unmaintained since 2019 and does not support modern Babel versions (7.x+).
fix Use native RegExp features or a more actively maintained plugin like @babel/plugin-proposal-unicode-property-regex.
gotcha Requires regexp-tree package as a direct dependency but is not included in the plugin's package.json dependencies list (it's a peer dependency).
fix Manually install regexp-tree: npm install regexp-tree --save-dev.
gotcha The xFlag feature transforms extended regexes but only works with new RegExp() calls, not regex literals.
fix Use new RegExp(pattern, 'x') syntax for extended flag.
gotcha Plugin options are passed as an array item, not as a separate object in .babelrc plugins array.
fix Use ["transform-modern-regexp", { ... }] structure.
npm install babel-plugin-transform-modern-regexp
yarn add babel-plugin-transform-modern-regexp
pnpm add babel-plugin-transform-modern-regexp