Vite plugins: cx-scss-manifest + transform-cx-imports, Vite-based litmus setup - #1318
Merged
Conversation
…-modules transpilers
mstijak
force-pushed
the
feat/scss-manifest-vite-plugin
branch
from
August 4, 2026 08:22
d77dc75 to
97af1c0
Compare
…undled cx
vite-plugin-cx-scss-manifest
- collect deep imports through an enforce:"pre" resolveId hook, so with the
rewrite plugin active no source parsing is needed at all
- record every manifest key backed by an imported file (Select.js -> Select
and Option), which also covers styles the name-based scan used to miss
- only run es-module-lexer for modules that still contain a barrel import
- warn once per file on parse failures; guard the debounced write
vite-plugin-transform-cx-imports
- in dev, rewrite only when Vite does not pre-bundle cx (aliased, linked or
excluded); pre-bundled cx would otherwise desync from the dependency scanner
- new `dev` option ("auto" | boolean); drop the inert `scss` option
- skip the lexer when no barrel import is present, warn on parse failures,
swallow the trailing semicolon, use boundary source maps
litmus registers the rewrite plugin before the manifest plugin.
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.
Summary
Adds two Vite plugins — vite-plugin-cx-scss-manifest and vite-plugin-transform-cx-imports — and converts litmus to optionally run on Vite 8 to prove them out end-to-end.
packages/vite-plugin-cx-scss-manifestVite counterpart of
cx-scss-manifest-webpack-plugin.es-module-lexerin thetransformhook, validates candidates againstcx/manifest.js, and generates the samemanifest.scssformat as the webpack plugin (files are interchangeable between the two).Repeaterfromcx/widgets→ui/Repeater), deep imports, and skipsimport typestatements andnode_modules.manifest.scssas a sass dependency, so new widget styles hot-reload without a page refresh.packages/vite-plugin-transform-cx-importsVite counterpart of
babel-plugin-transform-cx-imports. Rewrites namespace barrel imports into direct file imports usingcx/manifest.js:import type, namespace, default, and dynamic imports are left untouched. Sourcemaps preserved viamagic-string.scssflag mirrors the babel plugin's sass option (currently dormant — the shipped manifest has no scss entries).es-module-lexerVite itself runs on every module during import-analysis, gated behind node_modules/extension/indexOf("cx/")checks — measured build overhead of both plugins together is ~15ms (within noise).fix(cx): type-only re-exportsThree type-only names were re-exported as values (
AccessorChaininui/index.ts,JSXinjsx-dev-runtime.ts,GridRowConfiginGrid.tsx). Babel tolerated this, but any isolated-modules transpiler (esbuild/oxc/swc) keeps the import and fails at runtime — this breaks alljsxImportSource: "cx"source-consuming setups, not just litmus. Fixed withexport type(verified viatsc --isolatedModules, which now reports no TS1205 errors).feat(litmus): Vite setup alongside webpackyarn start:vite(port 8090) /yarn build:vite; the webpack workflow is untouched.cx/*topackages/cx/src— framework source edits hot-reload directly, no compile step.jsxImportSource: "cx"(no babel). Legacy.jsdemos containing JSX go through a small esbuild bridge plugin, since rolldown's built-in transform doesn't allow enabling JSX for.js(itsTransformOptions.langis ignored in the native plugin). The active demo is renamed to.tsxas the migration path — pure oxc handles those.Testing
yarn check-typesclean;yarn test— 535 passing, 1 pre-existing failure on master (babel-plugin-transform-cx-importsvs. staledist/manifest.jsafter thecx/widgetsbarrel refactor, unrelated to this PR).