-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
p2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)upstream
Description
Describe the bug
When writing a TypeScript (version 5.3.3) library I need a function using RegExp, which has to use the /v flag (trimmed example in test reproduction).
According to MDN docs it should be supported in node 20.0.0+
The function on its own works all right, but when I want to test it with Vitest I receive an error:
FAIL tests/index.test.ts [ tests/index.test.ts ]
Error: Unknown regular expression flags.
❯ error node_modules/rollup/dist/es/shared/parseAst.js:337:30
❯ parseError node_modules/rollup/dist/es/shared/parseAst.js:972:9
❯ convertNode node_modules/rollup/dist/es/shared/parseAst.js:2057:12
❯ convertProgram node_modules/rollup/dist/es/shared/parseAst.js:965:12
❯ parseAstAsync node_modules/rollup/dist/es/shared/parseAst.js:2108:12
❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:54036:15
❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:53632:11
Reproduction
In a function use regex with /v flag:
export function showcaseVFlag(name: string): string[] {
const regexp = /(?:\p{RGI_Emoji})|(?:\P{Mark}(?:\p{Mark}*))/gv;
return [...name.matchAll(regexp)].flat();
}
Then test it with Vitest:
describe("showcaseVFlag", () => {
it("should separate graphemes correctly", () => {
expect(showcaseVFlag("Hello 🌍! 👋")).toStrictEqual(["H", "e", "l", "l", "o", " ", "🌍", "!", " ", "👋"]);
});
});
System Info
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics
Memory: 2.52 GB / 15.37 GB
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
npm: 9.1.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.9.2 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Edge: Chromium (121.0.2277.128)
Internet Explorer: 11.0.22621.1
npmPackages:
vite: ^5.1.3 => 5.1.3
vitest: ^1.2.2 => 1.2.2Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p2-edge-caseBug, but has workaround or limited in scope (priority)Bug, but has workaround or limited in scope (priority)upstream