{"id":24962,"library":"babel-plugin-transform-modern-regexp","title":"babel-plugin-transform-modern-regexp","description":"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.","status":"deprecated","version":"0.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/DmitrySoshnikov/babel-plugin-transform-modern-regexp","tags":["javascript","regexp","es2018","modern","xflag","lookbehind","babel"],"install":[{"cmd":"npm install babel-plugin-transform-modern-regexp","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-modern-regexp","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-modern-regexp","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for regex parsing and transformation","package":"regexp-tree","optional":false}],"imports":[{"note":"This is a CommonJS module typically used as a Babel plugin string, not imported directly.","wrong":"import plugin from 'babel-plugin-transform-modern-regexp'; // Not a typical ES module","symbol":"default","correct":"module.exports = require('babel-plugin-transform-modern-regexp'); // or in .babelrc plugins array"},{"note":"No direct named exports. Used via Babel configuration as 'transform-modern-regexp'.","symbol":"N/A"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    [\"transform-modern-regexp\", {\n      \"features\": [\"dotAll\", \"namedCapturingGroups\", \"xFlag\"]\n    }]\n  ]\n}\n\n// Input\nconst regex = /(?<name>\\w+)\\k<name>/s;\n// Output\nconst regex = /([\\0-\\uFFFF])\\1/;","lang":"javascript","description":"Shows Babel configuration enabling dotAll and named groups features, and a sample transformation."},"warnings":[{"fix":"Use native RegExp features or a more actively maintained plugin like @babel/plugin-proposal-unicode-property-regex.","message":"Package is unmaintained since 2019 and does not support modern Babel versions (7.x+).","severity":"deprecated","affected_versions":">0.0.6"},{"fix":"Manually install regexp-tree: npm install regexp-tree --save-dev.","message":"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).","severity":"gotcha","affected_versions":"0.0.6"},{"fix":"Use new RegExp(pattern, 'x') syntax for extended flag.","message":"The xFlag feature transforms extended regexes but only works with new RegExp() calls, not regex literals.","severity":"gotcha","affected_versions":">=0"},{"fix":"Use [\"transform-modern-regexp\", { ... }] structure.","message":"Plugin options are passed as an array item, not as a separate object in .babelrc plugins array.","severity":"gotcha","affected_versions":">=0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the plugin: npm install babel-plugin-transform-modern-regexp --save-dev","cause":"Babel >=7 does not find the plugin in node_modules or it's not installed.","error":"Error: Plugin transform-modern-regexp: Unknown plugin \"transform-modern-regexp\""},{"fix":"Use correct format in .babelrc: [\"transform-modern-regexp\", { \"features\": [...] }]","cause":"Plugin options are malformed; missing plugin object.","error":"TypeError: Cannot read property 'features' of undefined"},{"fix":"Run: npm install regexp-tree --save-dev","cause":"regexp-tree is a peer dependency of the plugin but not automatically installed.","error":"Error: Cannot find module 'regexp-tree'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}