Skip to content

Conversation

@lindsayzhng
Copy link
Contributor

@lindsayzhng lindsayzhng commented Feb 4, 2026

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.js name, inlineDynamicImports) and setting base: "".

Updates getShikiWorker to wrap worker creation in a try/catch, logging a warning and returning undefined so 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.

@lindsayzhng lindsayzhng requested a review from pqoqubbw February 4, 2026 01:55
Copy link

@cursor cursor bot left a 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;
}
Copy link

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.

Fix in Cursor Fix in Web

import { defineConfig, type Plugin } from "vite";
import dts from "vite-plugin-dts";

function relativeWorkerPlugin(): Plugin {
Copy link
Contributor

@dks333 dks333 Feb 4, 2026

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

Copy link
Contributor Author

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

Copy link
Contributor

@pqoqubbw pqoqubbw left a 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!!

@lindsayzhng lindsayzhng requested a review from dks333 February 4, 2026 17:38
@lindsayzhng lindsayzhng merged commit 4b97f1b into main Feb 4, 2026
3 checks passed
@lindsayzhng lindsayzhng deleted the lindsay/eng-6095-bundle-worker branch February 4, 2026 17:38
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.

4 participants