fix(core): place a top-level imported file's leading /*! banner at the head, not the tail - #177
Merged
Merged
Conversation
…nt at the import site A leading block comment (e.g. a /*! license banner) that opens an IMPORTED document was emitted at the correct place only for nested imports (e.depth > 0); a TOP-LEVEL import left it unemitted at the splice and it was swept to the output tail. The importing document's own leading-comment pass reads the importer's trivia, never the loaded file's, so the guard must not exclude depth 0. This is the bootstrap4 shape: a one-line entry that only imports a framework whose entry file opens with the /*! Bootstrap … */ banner followed by more imports. The banner now renders as line 1 instead of at the end of the output.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
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.
While measuring bootstrap4 render parity, the license banner came out at the end of the output instead of line 1.
Root cause: a leading block comment that opens an imported document is spliced at the import site only when the import is nested (
e.depth > 0). A top-level@import(bootstrap4's entry is a single@import "bootstrap-less-port/less/bootstrap", and that file opens with the/*! Bootstrap v4.1.1 … */banner) is ate.depth === 0, so the banner was left unemitted at the splice and swept to the output tail. The importing document's own leading-comment pass reads the importer's trivia, never the loaded file's, so thee.depth > 0guard was wrong.Fix: emit the imported document's leading block comment at the splice for depth 0 too (still gated to non-reference imports). Banner now renders as line 1.
Regression test:
imported-leading-comment.test.ts(top-level import of a file whose leading/*!banner must appear at the head, exactly once). Full core (3296) and jess suites stay green.Context: this is the one genuine parity gap found in the bootstrap4 render triage — the remaining diff vs the lessc 4.x oracle is the intentional v5
:is()compaction and the settled V7 number precision (owner-confirmed accepted divergences).