Skip to content

Fix Zed Extension breaking when package.json is not present in workspace root#235

Merged
mizdra merged 3 commits into
mainfrom
fix-failed-to-load-ts-plugin-on-zed
Aug 10, 2025
Merged

Fix Zed Extension breaking when package.json is not present in workspace root#235
mizdra merged 3 commits into
mainfrom
fix-failed-to-load-ts-plugin-on-zed

Conversation

@mizdra
Copy link
Copy Markdown
Owner

@mizdra mizdra commented Aug 10, 2025

close: #217

Cause of the bug

When opening a workspace without package.json in zed, get_ts_plugin_root_path returns Err(_) in the following line.

let package_json = worktree.read_text_file("package.json")?;

Then, worktree.root_path() is set as the starting location for searching for ts-plugin in the following line.

"location": self.get_ts_plugin_root_path(worktree)?.unwrap_or_else(|| worktree.root_path()),

worktree.root_path() is the root directory of the workspace. However, the ts-plugin is typically not installed in that directory. The Zed Extension for css-modules-kit installs the ts-plugin in extension_work_dir (on macOS, this is ~/Library/Application Support/Zed/extensions/work/css-modules-kit).

Solution

We change it so that extension_work_dir is used as the starting location for searching for ts-plugin.

Changelog

  • feat: supports CMK_LOAD_LOCAL_TS_PLUGIN for loading local ts-plugin
  • fix: fix Zed Extension breaking when package.json is not present in workspace root

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 10, 2025

⚠️ No Changeset found

Latest commit: 5e0fffd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mizdra mizdra marked this pull request as ready for review August 10, 2025 16:46
@mizdra mizdra added the Type: Bug Bug or Bug fixes label Aug 10, 2025
@mizdra mizdra changed the title Fix failure to load ts-plugin in Zed Fix Zed Extension breaking when package.json is not present in workspace root Aug 10, 2025
@mizdra mizdra changed the title Fix Zed Extension breaking when package.json is not present in workspace root Fix Zed Extension breaking when package.json is not present in workspace root Aug 10, 2025
@mizdra mizdra merged commit e22cae6 into main Aug 10, 2025
10 checks passed
@mizdra mizdra deleted the fix-failed-to-load-ts-plugin-on-zed branch August 10, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zed Extension doesn't work in a monorepo

1 participant