Repository navigation
Resolve tree-shaking issues with inlineConst - #87
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`optimization.inlineConst` replaces imported class name constants with their values at the call site, which can leave the module that declared them without a single used export. The whole module is then dropped — injected stylesheet import included — as soon as anything declares it side-effect free, be it `sideEffects: false` in the nearest `package.json` (as in this repo, which the fixtures inherit) or a `treeshake.moduleSideEffects` setting, and the build silently ships unstyled markup. Report the injected import for what it is by returning `moduleSideEffects: true` from `transform`, which outranks both of those, and declare the same on the virtual stylesheet modules in `resolveId`, where the existing comment already claimed it. The `resolveId` branch that re-resolved source files with extractions never fired: the hook receives import specifiers, never the absolute ids the parse cache is keyed by. It is dropped rather than kept alongside the above. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`moduleSideEffects` now keeps those modules in the bundle, so the stale comment credited these imports with work they no longer do. Disabling them and running the suite shows what they are actually still worth: no CSS goes missing, but the dependency's stylesheet moves after the CSS that references it, because ecij prepends its imports above the module's own. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`optimization.inlineConst` inlines string constants into the modules using them, which leaves the module that declared a class name with no used export. Under a `sideEffects: false` package it is then dropped along with its prepended stylesheet import, and the build silently ships unstyled markup. A template literal with no substitutions is not treated as an inlinable constant, so the binding survives tree-shaking; minification folds it back to a plain string, leaving production output unchanged. This replaces the `moduleSideEffects: true` marking, which only covered a direct import. Rolldown discards a plugin's `moduleSideEffects` across a re-export hop once inlining empties the chain — reproducible in plain rolldown with no ecij — so a class name reached through a barrel still lost its CSS. The marking also over-retained, making a barrel that declares its own class ship every re-exported module's CSS. Both are covered by the new barrel test. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
nstepien
marked this pull request as ready for review
September 6, 2026 02:52
nstepien
added a commit
that referenced
this pull request
Oct 17, 2026
main took in the first slice of this PR (#79) and solved several of its other problems differently since August, so the merge ports the rest of this branch onto main's design instead of keeping both: - Values, class names included, come from the parse of each module, and const initializers resolve lazily (#79). Re-exports, `export *`, default and namespace imports, and `export default` resolve through the same evaluator, with ESM precedence and ambiguity. - Cycles are handled by main's pendingLoads and isWaitingFor (#102), so the wait graph, the deferred same-file passes, and the import-last ordering are gone, along with the guard against inlining the class names of skipped templates, which needed the imported modules' transforms. - Class names are IIFEs (#87, #98), so `moduleSideEffects: true` is gone. - Vite's dev server keeps main's behavior (#104) and does not transform imported modules through transformRequest. There, the code of modules that no file holds comes from their `load` hooks. - UNREADABLE_MODULE and UNPARSEABLE_MODULE are gone: a module whose code cannot be read exports nothing, and modules are parsed as the language Rolldown assigned them. - Kept: raw TypeScript bindings, `meta.moduleType` parsing, prologue-safe imports, query-variant module identity, skipping external modules, and resolving each import once per transform. Tests: main's suite, plus this branch's tests of the kept features, with new cases for the paths that no fixture reached. The tests of the removed behavior, and the cycle test that main already has, are dropped. basic.input.ts is restored for main's inlineConst tests, and this branch's barrel.ts is now barrel-index.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 17, 2026
nstepien
added a commit
that referenced
this pull request
Oct 17, 2026
) Removing the `main` field in #85 also dropped `index.js` from the tarball, as `files` only lists `dist` and `index.d.ts`. The plugin leaves the `ecij` import in place, so builds still resolve it. Packing `main` and installing it in react-data-grid breaks `vp build`: ``` Error: [vite+]: Rolldown failed to resolve import "ecij" from ".../website/routes/ColumnSpanning.tsx". ``` This adds `index.js` to `files` and adds [publint](https://publint.dev/) as `node --run lint:package` (`publint --strict`), which checks every file referenced by `package.json` against the files `npm pack` would publish. CI and the release workflow run it after the build, so a missing entry point now fails CI and stops a release. ## Verification - `npm pack --dry-run` lists `index.js` again (7 files). - Without the `files` change, publint fails with `pkg.exports["."].default is ./index.js but the file is not published. Is it specified in pkg.files?`, with both npm 11 and npm 12. With it, publint reports `All good!`. - With the packed tarball installed in react-data-grid (`f7d4e272`), `vp pack` and `vp build` pass, and all of its tests pass (544 passed, 3 skipped). - Compared with ecij 0.5.0, the CSS is byte-identical and the class names are the same. The only JS change is the IIFE class names from #87 in the unminified `lib/index.js`, which minifiers fold back into strings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
No description provided.