{"id":26181,"library":"regexpu-core","title":"regexpu-core","description":"regexpu-core is the core module of regexpu, a transpiler that converts ES2015 Unicode regular expressions (with the `u` and `v` flags) into ES5-compatible patterns. Current stable version is 6.4.0. It supports features like Unicode property escapes, dotAll flag, named capture groups, and the `v` flag (unicodeSetsFlag), with options to either pass through or transform them. Released on npm with TypeScript types, it has a steady release cadence, updated for Unicode 15.1. Key differentiator: focused on core regexp rewriting without the full regexpu CLI, used by Babel and other tools.","status":"active","version":"6.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/mathiasbynens/regexpu-core","tags":["javascript","codegen","desugaring","ecmascript","es5","es6","harmony","refactoring","typescript"],"install":[{"cmd":"npm install regexpu-core","lang":"bash","label":"npm"},{"cmd":"yarn add regexpu-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add regexpu-core","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; ESM and CJS both supported. In CJS, require returns the function directly.","wrong":"const rewritePattern = require('regexpu-core')","symbol":"rewritePattern","correct":"import rewritePattern from 'regexpu-core'"},{"note":"Named export also available since v5.1.0; both named and default exports are the same function.","wrong":"import rewritePattern from 'regexpu-core'","symbol":"rewritePattern (named)","correct":"import { rewritePattern } from 'regexpu-core'"},{"note":"Use `import type` for TypeScript interfaces to avoid runtime import.","wrong":"import { RewritePatternOptions } from 'regexpu-core'","symbol":"types","correct":"import type { RewritePatternOptions } from 'regexpu-core'"}],"quickstart":{"code":"import rewritePattern from 'regexpu-core';\n\n// Transform a Unicode regex with 'u' flag to ES5\nconst pattern = '\\\\p{ASCII_Hex_Digit}+';\nconst flags = 'u';\nconst result = rewritePattern(pattern, flags, {\n  unicodePropertyEscapes: 'transform',\n  unicodeFlag: 'transform',\n});\nconsole.log(result);\n// E.g.: '(?:[0-9A-Fa-f])+'","lang":"typescript","description":"Shows basic usage of rewritePattern to transpile a Unicode property escape regex into ES5-compatible pattern."},"warnings":[{"fix":"Remove any setting that disables 'v' flag; pattern is always parsed with 'v' flag support.","message":"v6.0.0: Always enable unicodeSetsFlag parsing. Removed option to disable 'v' flag support.","severity":"breaking","affected_versions":">=6.0.0 <6.0.0"},{"fix":"Replace 'useUnicodeFlag' with 'unicodeFlag' option.","message":"The 'useUnicodeFlag' option is deprecated since v5.0.0.","severity":"deprecated","affected_versions":">=5.0.0 <5.0.0"},{"fix":"Use `const rewritePattern = require('regexpu-core');` not `require('...').rewritePattern`.","message":"When using CommonJS require, the default export is the function, not an object.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Set `unicodeFlag: 'transform'` explicitly to get ES5-compatible output.","message":"The 'unicodeFlag' option must be 'transform' to actually transform; false leaves it as-is.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Pass `namedGroups: 'transform'` option to compile named groups.","message":"Named capture groups are not transformed by default; must set 'namedGroups' option.","severity":"gotcha","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `const rewritePattern = require('regexpu-core');`","cause":"Using named import when default export expected in CJS.","error":"TypeError: rewritePattern is not a function"},{"fix":"Do not import from internal paths; use only 'regexpu-core'.","cause":"Importing internal modules directly, not part of public API.","error":"Can't find module 'regexpu-core/data/character-class-escape-sets'"},{"fix":"Use `import type { RewritePatternOptions } from 'regexpu-core';`","cause":"Using regular import for a type-only export.","error":"TypeScript error: 'RewritePatternOptions' is a type and must be imported using a type-only import"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}