fix: add denoteStyles() Vite plugin to fix Tailwind scanning for JSR packages - #74
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tailwind v4's
@sourcedirective assumes dependencies live in node_modules. JSR packages don't — Deno caches them in its own module cache. This meant@source "node_modules/@denote/core/"silently pointed nowhere, so all framework Tailwind classes were dropped from user builds.A second problem:
@import "@denote/core/styles.css"in user CSS couldn't be resolved because @tailwindcss/vite processes CSS@importstatements with its own internal resolver that bypasses Vite's resolveId plugin chain entirely.Fix
Adds denoteStyles() to @denote/core/vite. The plugin runs with enforce: "pre" and a transform hook on CSS files, intercepting both issues before @tailwindcss/vite sees the file:
@import "@denote/core/styles.css"with the actual package CSS content (loaded via import.meta.url, which points to the real location in Deno's cache)@source "node_modules/@denote/core/"to the actual package directory derived from import.meta.urlThe scaffolder (@denote/init) now generates vite.config.ts with denoteStyles() included. The docs site is updated to use the same pattern, dogfooding the plugin.
Also fixes implicit any type errors in mcp.ts resource callbacks (uri: URL, { slug }: Variables).