-
Notifications
You must be signed in to change notification settings - Fork 5
Bundle shiki worker #190
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
Bundle shiki worker #190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| error | ||
| ); | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated worker creation attempts on failure
Medium Severity
When worker creation fails in the catch block, instance remains undefined. This causes every subsequent call to getShikiWorker() to retry creating the worker, fail again, and log another warning. Since this function is called for every large code block, this can result in console spam and unnecessary overhead. The failed initialization state needs to be tracked to prevent repeated retry attempts.
packages/components/vite.config.ts
Outdated
| import { defineConfig, type Plugin } from "vite"; | ||
| import dts from "vite-plugin-dts"; | ||
|
|
||
| function relativeWorkerPlugin(): Plugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the worker file to /utils/shiki/worker.js
can we try removing this plugin and build the project? want to see if /utils/shiki/worker.js is gone in dist folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ur right- it didn't need to be parsed like that- I set the base to be "" so we use relative paths instead and won't need a plugin... how does that look
pqoqubbw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested locally with next app, works as expected!!


Summary
bundle shiki worker because package is missing the worker when importing in projects
Test Plan
tested with storybook and didn't break anything...
Note
Medium Risk
Build/packaging changes can affect worker asset paths and bundling output in downstream consumers; runtime change is a safe fallback but may change performance/behavior when worker init fails.
Overview
Packages the Shiki web worker into the components build by adding Vite worker Rollup output settings (fixed
utils/shiki/worker.jsname,inlineDynamicImports) and settingbase: "".Updates
getShikiWorkerto wrap worker creation in atry/catch, logging a warning and returningundefinedso consumers can fall back to synchronous highlighting when the worker is unavailable.Written by Cursor Bugbot for commit 2bbfe63. This will update automatically on new commits. Configure here.