Skip to content

fix(engine-javascript): resolve regex engine limitations and discrepa…#1244

Open
crazylogic03 wants to merge 7 commits intoshikijs:mainfrom
crazylogic03:fix/engine-javascript-regex-issues
Open

fix(engine-javascript): resolve regex engine limitations and discrepa…#1244
crazylogic03 wants to merge 7 commits intoshikijs:mainfrom
crazylogic03:fix/engine-javascript-regex-issues

Conversation

@crazylogic03
Copy link
Copy Markdown
Contributor

This PR addresses critical regressions and discrepancies in the engine-javascript package where it failed to match the behavior of the WASM engine, particularly for complex grammars like SQL.

What this PR solves:

Fixes SQL Grammar Failures: Resolves issues where large regex patterns (e.g., extensive keyword alternations) caused V8 regex engine limitations or incorrect matches.
Corrects Capture Group Indexing: Implements logic to correctly handle capture groups when patterns are split. Previously, splitting large patterns caused "Expected X groups, received Y" errors.
Fixes Regex Flag Incompatibility: Resolves a specific issue where the default v flag (ES2024) caused faulty emulation of word boundaries (\b) when combined with case-insensitivity ((?i)).

…ncies

- Implement pattern splitting for large SQL regexes to bypass V8 limits
- Add capture group padding to match Oniguruma behavior
- Enforce ES2018 target to fix `\b` emulation issues with `v` flag
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 16, 2026

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit bafbd57
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/6992b7dddb85fa0008a1aa17
😎 Deploy Preview https://deploy-preview-1244--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 16, 2026

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit bafbd57
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/6992b7dd4dba440008e874be
😎 Deploy Preview https://deploy-preview-1244--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 96.52174% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.41%. Comparing base (213f19b) to head (bafbd57).

Files with missing lines Patch % Lines
packages/engine-javascript/src/scanner.ts 96.50% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1244      +/-   ##
==========================================
+ Coverage   95.25%   95.41%   +0.16%     
==========================================
  Files          92       92              
  Lines        8008     8186     +178     
  Branches     1704     1787      +83     
==========================================
+ Hits         7628     7811     +183     
+ Misses        374      369       -5     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@crazylogic03
Copy link
Copy Markdown
Contributor Author

@antfu Please review the PR 🙂 and All Checks Have Been Passed

@crazylogic03
Copy link
Copy Markdown
Contributor Author

@antfu all check have passed please have time to review and merge this PR🙂

@crazylogic03
Copy link
Copy Markdown
Contributor Author

@antfu Please Review This PR

@antfu
Copy link
Copy Markdown
Member

antfu commented Feb 25, 2026

Would you consider contributing to https://github.com/slevithan/oniguruma-to-es instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants