Native plugin seam: OjPlugin trait, compiler slot, dev and build hosts - #148
Open
raphamorim wants to merge 9 commits into
Open
raphamorim wants to merge 9 commits into
raphamorim wants to merge 9 commits into
Conversation
raphamorim
force-pushed
the
rapha/plugin-seam
branch
from
September 3, 2026 23:11
c354be3 to
c870855
Compare
Collaborator
Author
|
Review fixes pushed in the last commit:
Left as follow-ups: TanStack Start dev and build do not receive native plugins yet; |
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.
Phase 1 of a native plugin system for oj: the generic seam, with no first-party plugin yet. Design per the plugin-system memo (two tiers: compile-time Rust plugins plus the existing JS bridge; no dynamic libraries, no WebAssembly). Acceptance bar: with no native plugin registered, behavior is byte-identical and the whole existing suite passes unchanged.
What lands
oj_plugincrate:OjPlugin: rolldown_plugin::Pluginwith defaulted methods (cache_salt,replaces_js_plugins,config_section,transform_filter,pre_transform_ast,mtime_cacheable,module_seen,module_removed,css_directive,css_for_directive,virtual_css,css_parse_options,invalidates), an object-safe view, aRegistry, andModuleFilterover rolldown's own hook-filter interpreter (id, code and module-type includes and excludes, evaluated before parsing).oj_compiler::compile_module_fullruns registered pre-transformers on the oxcProgrambetween the parser and the semantic build, so passes see JSX and TypeScript; side channels come back asCompileOutput.meta.ensure_module;module_seenruns on cold compiles and on every cache-hit path (mtime, memory, persistent) so registries survive restarts;module_removedon deletion;invalidatesin the HMR decision (css-update for a url, module change, full reload); a plugin@directive;is masked through the sidecars with an oj-owned sentinel and expanded after Lightning CSS;virtual_cssis served at/@oj/<name>.css.assets/<name>-<hash>.csswith a manifest row and a page link; the directive uses the same sentinel incompile_stylesheet.CachedModule.meta(omitted when empty; older entries load), the persistent-cache salt folds every active plugin'scache_salt,mtime_cacheablegates the fast path;OjConfiggains a flatten catch-all soconfig_section(name)reads a plugin's own section;replaces_js_pluginsis unioned into the native-plugin skip list handed to the JS host.example-markerbehind the default-offexample-plugincargo feature (active only with amarkerconfig section orOJ_EXAMPLE_PLUGIN=1) exercises both archetypes the memo identified: an AST pass with a side channel, and a cross-module registry feeding a virtual sheet and a directive with css-update invalidation.Tests
36 new Rust unit tests (filters, registry, cache salt fold and meta round trip, config catch-all, directive sentinel through Lightning CSS, the example plugin), a plugin-host unit test for the skip-list union,
e2e/native-plugin-dev.mjs(rewrite, virtual sheet, directive, css-update on change, warm-restart replay ofmodule_seenfrom cached meta) ande2e/native-plugin-build.mjs(rewritten chunk, emitted sheet, manifest row, link). Full workspace tests, JS unit tests, run.mjs in both modes, start.mjs and every CI e2e pass.Deferred (documented in code and in the follow-up list)
Migrating the first builtin (the
import.meta.globfamily needs an after-transform position and a "no source map" flag), a devPluginContextfor rolldown hooks, a consumer forcss_parse_options, and the cache-salt field-flip test helper.