Repository navigation
oj dev: an editor's source-tagging plugin runs natively - #825
Closed
raphamorim wants to merge 1 commit into
Closed
raphamorim wants to merge 1 commit into
raphamorim wants to merge 1 commit into
Conversation
Config extraction asks the instance what it does: its resolveId and load for react/jsx-dev-runtime, and whether its configureServer watches the Tailwind config. In a serve the plugin host leaves it out and oj does both: the JSX dev runtime import goes to the plugin's module at Vite's URL for its virtual id, compiled like any module so its own import of the runtime reaches the pre-bundle; and the app's resolved Tailwind theme is written to src/tailwind.config.lov.json at boot and on a Tailwind config change, by an engine job with the app's own @tailwindcss/node (v4) or esbuild and tailwindcss/resolveConfig (v3), off the boot's path. An app whose other plugins are React's boots no plugin host. An instance with a hook oj does not know, and every build, keep the host as before.
Collaborator
Author
|
Closing in favour of emitting source tags in oj's own JSX transform (the |
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.
What
oj devruns an editor's source-tagging plugin natively. The one oj knows is thelovable-taggerpackage'slovable-plugin(1.3.x), apreplugin whose work in a serve is two things:react/jsx-dev-runtimewith a virtual module of its own, a wrapper of React'sjsxDEVthat records each element's source on its DOM node for the editor (resolveId+load);src/tailwind.config.lov.jsonat boot and whentailwind.config.tsor a v4 CSS entry changes, for the editor's color picker (buildStart+configureServer).With this PR the plugin host leaves that plugin out and oj does both. A React app whose only other plugins are React's boots no plugin host at all.
How
sourceTagginginvite-extract.mjs), so no version of the plugin is assumed: itsresolveIdis called forreact/jsx-dev-runtimefrom an importer of the app's and itsloadfor the answer, and itsconfigureServeris called with a stand-in server whose watcher records whether achangelistener is registered (the Tailwind feature's only effect there). The answers travel in the extraction (ViteValues.source_tagging, cached with the config like every other value) toOjConfig.vite_source_taggingand the server state.isSourceTaggingPlugininnative-plugins.mjs: name, enforce, configResolved, buildStart, configureServer, resolveId, load). One with more, a later version'stransformsay, stays hosted. A build hosts it as before: the native path is forserve.react/jsx-dev-runtimefrom every module but the plugin's own to/@id/__x00__jsx-source/jsx-dev-runtime, Vite's URL for the\0id, ahead of the pre-bundle as apreplugin's resolveId runs ahead ofvite:resolve. The server compiles the plugin's code like any module under a synthetic file, so its own import of the runtime reaches the pre-bundle.source-tagging-theme.mjsis the plugin'srun()as an engine job with the app's own packages, resolved from the plugin's package first (esbuild and tailwindcss are its dependencies) and the app second: Tailwind v4 through@tailwindcss/node's design system withvar()s resolved from:root, else v3 by bundlingtailwind.config.tswith esbuild andtailwindcss/resolveConfig. It runs on a thread off the boot's path (the plugin'sbuildStartran before Vite listened, but an editor reads the file on demand) and again after a change to a watched file, from the watch feed.Tests
Each fails without the change.
vite_values_tests: the fact reaches the config;nullleaves it unset.engine_extraction_tests: a plugin of the known shape is asked (id, code, package, the Tailwind watch) and counts as native in a serve, hosted in a build; one with its features off is native with nothing to do; one with a hook oj does not know stays hosted.host_filter_tests: a serve host leaves the plugin out and keeps a lookalike with atransformand the user's plugin; a build host keeps all three.tests/dev/source_tagging: the served JSX module imports the plugin's URL, that URL serves the plugin's code with its runtime import on the pre-bundle, and no host boots; the v4 theme is written at boot and rewritten after a CSS edit (the fixture's Tailwind 4 and@tailwindcss/node); a v3 config with a relative import and arequireis bundled by the fixture's esbuild and resolved by aresolveConfigstand-in, and the bundled file is removed.Not in this PR
oj dev --ssr, a TanStack Start app) does not redirect the runtime; the known plugin's wrapper passes through on the server anyway, and the configs that carry it are client apps.vite-plugin-component-tagger(1.1.x), which tags elements with a transform: hosted as before.