You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: accept readonly arrays for build candidates and Scanner sources - #20708
build() only iterates its candidates, and Scanner only reads its sources, but their public types required mutable arrays. Code holding either as a readonly array had to copy it into a mutable one first.
packages/tailwindcss/src/index.ts: build() now takes readonly string[] in both compile() and compileAst().
crates/node/src/lib.rs: ScannerOptions.sources is generated as ReadonlyArray<SourceEntry> via #[napi(ts_type = ...)].
Added type-level regression tests for both public types.
Added a changelog entry.
Mutable arrays remain assignable to readonly arrays, so this is backwards compatible.
Test plan
pnpm exec vitest run packages/tailwindcss/src/index.test.ts — 268 passed.
Built @tailwindcss/oxide and confirmed the generated crates/node/index.d.ts now declares sources?: ReadonlyArray<SourceEntry>.
The new type-level tests assign readonly arrays to both APIs, so they fail to type-check against the previous mutable signatures and pass with this change.
Notes
The #[napi(ts_type = ...)] attribute only changes the generated TypeScript declaration; the Rust field remains Option<Vec<SourceEntry>>, so there is no runtime change.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c219e3e3-6610-412a-80da-9d4d4004a3c5
Commits
Reviewing files that changed from the base of the PR and between f4a706f and 8a911d7.
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
No actionable comments were generated in the recent review.
Walkthrough
The build() methods now accept readonly candidate arrays, and ScannerOptions.sources is annotated to accept a readonly array. The added type tests cover both inputs. The changelog records the update.
Severity of issue fixed: Medium
Merge Risk: Minimal · previous review f4a70
This change lets TypeScript callers pass readonly arrays for build candidates and scanner sources, with no runtime change. The only effect is that code mutating ScannerOptions.sources through the type may need a small adjustment. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main changes: readonly arrays for build candidates and for Scanner sources. The changeset makes these type changes in packages/tailwindcss/src/index.ts and crates/node/src/lib.…
Description check
The description states the purpose of the change: build() and Scanner only read their inputs, but their public types required mutable arrays. It lists the modified files (index.ts, crates/node/src/lib…
Linked Issues check
Issue #20706 has two coding requirements. (1) build(candidates) must accept readonly string[]. The whole-PR summary (merge base to head) shows build changed from string[] to `readonly string[]…
Out of Scope Changes check
All changed files in the whole-PR summary relate to #20706. The index.ts changes are the two build signature updates. The lib.rs change is one ts_type annotation on ScannerOptions.sources. T…
Full details: Title check
Explanation
The title names the two main changes: readonly arrays for build candidates and for Scanner sources. The changeset makes these type changes in packages/tailwindcss/src/index.ts and crates/node/src/lib.rs, so the title matches the main change. The 'fix:' prefix is a conventional commit type and the title is 68 characters long.
Full details: Description check
Explanation
The description states the purpose of the change: build() and Scanner only read their inputs, but their public types required mutable arrays. It lists the modified files (index.ts, crates/node/src/lib.rs), the added type-level regression tests, the changelog entry, validation steps, and a backward-compatibility note. It is directly related to the changeset.
Full details: Linked Issues check
Explanation
Issue #20706 has two coding requirements. (1) build(candidates) must accept readonly string[]. The whole-PR summary (merge base to head) shows build changed from string[] to readonly string[] in both compileAst() and compile() in packages/tailwindcss/src/index.ts, with implementation bodies unchanged. (2) ScannerOptions.sources must accept readonly SourceEntry[]. The summary shows #[napi(ts_type = ...)] on pub sources in crates/node/src/lib.rs, which generates ReadonlyArray<SourceEntry> in the declaration. The Rust field and runtime behavior are unchanged. Mutable arrays remain assignable to readonly parameters, as the issue requires. Type-level regression tests in packages/tailwindcss/src/index.test.ts cover both APIs. The head moved since the previous review. The whole-PR summary remains consistent with the earlier conclusion, so it is retained. The incremental diff was not independently read. The author-reported checks were not rerun, and the reproduction project was not inspected.
Full details: Out of Scope Changes check
Explanation
All changed files in the whole-PR summary relate to #20706. The index.ts changes are the two build signature updates. The lib.rs change is one ts_type annotation on ScannerOptions.sources. The test file adds type-level coverage for both APIs. The changelog entry documents the fix. The summary reports no runtime, dependency, or refactoring changes. The changelog and test file were assessed from the summary only. The incremental diff since the previous reviewed heads was not independently read.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0d2fa357-97ec-484c-a9d6-e0585ddddc4d
Commits
Reviewing files that changed from the base of the PR and between e907051 and f4a706f.
Files selected for processing: 1
crates/node/src/lib.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
crates/node/src/lib.rs-92-92: 1
92-92: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve mutable access through ScannerOptions.
Existing code such as options.sources!.push(entry) no longer type-checks when options has type ScannerOptions. This can break consumer builds even though mutable arrays remain valid constructor inputs. Consider a separate readonly constructor-input type while preserving the existing mutable ScannerOptions contract.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 089e5720-1d70-4774-9ab4-1c445e4a00e0
Commits
Reviewing files that changed from the base of the PR and between b08bf83 and 0303828.
Files selected for processing: 4
.changelog/readonly-build-candidates.md
crates/node/src/lib.rs
packages/tailwindcss/src/index.test.ts
packages/tailwindcss/src/index.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Thanks for flagging this — I considered that tradeoff.
ReadonlyArray<SourceEntry> on ScannerOptions.sources allows both mutable and readonly arrays to be passed (which addresses #20706), but it does make options.sources read-only when accessed through the ScannerOptions type (so options.sources.push(...) would no longer type-check). At runtime the underlying value can still be a mutable array, but the declared type becomes stricter.
If you’d prefer to preserve mutable access via ScannerOptions.sources while still accepting readonly inputs, I can adjust this (e.g. by keeping the property mutable in the public type and using a separate/compatible input type for construction, if that fits napi-rs typing here). Happy to update based on maintainer preference.
`build()` only iterates its candidates and `Scanner` only reads its
sources, but both public types required mutable arrays. Code that holds
either as a `readonly` array had to copy it first.
- `packages/tailwindcss/src/index.ts`: type `build()` candidates as
`readonly string[]` for both `compile()` and `compileAst()`.
- `crates/node/src/lib.rs`: emit `ReadonlyArray<SourceEntry>` for
`ScannerOptions.sources` via `#[napi(ts_type = ...)]`.
- Add type-level regression tests for both public types.
Fixestailwindlabs#20706
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
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
Fixes #20706.
build()only iterates its candidates, andScanneronly reads its sources, but their public types required mutable arrays. Code holding either as areadonlyarray had to copy it into a mutable one first.packages/tailwindcss/src/index.ts:build()now takesreadonly string[]in bothcompile()andcompileAst().crates/node/src/lib.rs:ScannerOptions.sourcesis generated asReadonlyArray<SourceEntry>via#[napi(ts_type = ...)].Mutable arrays remain assignable to
readonlyarrays, so this is backwards compatible.Test plan
pnpm exec vitest run packages/tailwindcss/src/index.test.ts— 268 passed.tsc -p packages/tailwindcss/tsconfig.check.json --noEmit— clean (package-scoped check).rustfmt --check --edition 2021 crates/node/src/lib.rs— clean.node ./scripts/changelog.mjs check— clean.@tailwindcss/oxideand confirmed the generatedcrates/node/index.d.tsnow declaressources?: ReadonlyArray<SourceEntry>.readonlyarrays to both APIs, so they fail to type-check against the previous mutable signatures and pass with this change.Notes
The
#[napi(ts_type = ...)]attribute only changes the generated TypeScript declaration; the Rust field remainsOption<Vec<SourceEntry>>, so there is no runtime change.