Skip to content

fix(core): place a top-level imported file's leading /*! banner at the head, not the tail - #177

Merged
matthew-dean merged 2 commits into
devfrom
work/bootstrap4-parity
Sep 8, 2026
Merged

fix(core): place a top-level imported file's leading /*! banner at the head, not the tail#177
matthew-dean merged 2 commits into
devfrom
work/bootstrap4-parity

Conversation

@matthew-dean

Copy link
Copy Markdown
Member

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 at e.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 the e.depth > 0 guard 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).

…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.
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 495cdee1-0e55-467f-96ec-57fbbeabafec

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matthew-dean
matthew-dean merged commit 236f116 into dev Sep 8, 2026
7 checks passed
@matthew-dean
matthew-dean deleted the work/bootstrap4-parity branch September 8, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant