Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in Bun #2

Closed
devunt opened this issue Nov 17, 2024 · 3 comments
Closed

Does not work in Bun #2

devunt opened this issue Nov 17, 2024 · 3 comments

Comments

@devunt
Copy link

devunt commented Nov 17, 2024

r`\x${codePoint.toString(16).toUpperCase().padStart(2, '0')}`;

const emoji = minTargetEs2024 ? r`\p{RGI_Emoji}` : emojiRegex().source.replace(/\\u\{/g, r`\x{`);

These 2 line, specifically where it uses \x with raw string template, makes oniguruma-to-es incompatible with Bun, due to this issue oven-sh/bun#7540 on Bun's side.

Although this is Bun's fault, as oniguruma-to-es works well in latest Node.js, it would be great if this is fixed in oniguruma-to-es since it would takes a while to get fixed in their side.

A simple fix would be using double backslash as a escape character instead of using String.raw in those 2 lines, when it comes to use \x and String.raw together.

@slevithan
Copy link
Owner

Thanks for the detailed report!

Fix published in v0.4.1.

@CrossScarDev
Copy link

This still doesn't work in bun. New error (when running Astro with command bunx --bun astro dev --host):

977 |     throw new Error(r2`\xNN above 7F unsupported in Oniguruma "${raw}"`);
                            ^
error: Syntax Error
    at ./node_modules/oniguruma-to-es/dist/index.mjs:977:23

@slevithan
Copy link
Owner

@CrossScarDev I can't repro, and that error message you highlighted last appeared in Oniguruma-To-ES v0.1.2. Please upgrade to the latest version of this library (or of Shiki, if that's where you're using it). Alternatively, upgrading to the latest version of Bun should also fix it.

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

No branches or pull requests

3 participants