Next.js Discord

Discord Forum

unicode aware regex `/u` lead to crash

Unanswered
piscopancer posted this in #help-forum
Open in Discord
const nonChRegex = /\P{Han}/gu

the error
./src/components/search/tools/scanner.tsx
Module parse failed: Invalid regular expression: /\P{Han}/: Invalid property name (9:20)
| import { TbX } from "__barrel_optimize__?names=TbX!=!react-icons/tb";
| import { createWorker } from "tesseract.js";
> const nonChRegex = /\P{Han}/u;
| export default function Scanner({ props, ...attr }) {
|     const [worker, setWorker] = useState(undefined);

configs
ts
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next",
      },
    ],
    "paths": {
      "@/*": ["./src/*"],
    },
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"],
}

1 Reply

I realize nextjs might not be the root of the problem itself, most likely something else, but I have no idea what can cause this issue