Repository navigation
Conversation
With --only, consumer registration was skipped. A selected barrel could be deleted while a dynamic import, namespace import or non-TypeScript file still needed it. Track consumers for explicitly selected barrels, including imports inside files forced to be barrels. Register the full selection before checking its relationships so selection order does not affect preservation, and retain the correct reason for star re-exports. Supported JavaScript namespace consumers now report the same preservation reason as TypeScript consumers. The 197-test suite passed on Node 24. All 16 focused cases passed on Node 24 and compiled Node 20, including before/after execution, selection-order controls and dry-run/check behavior. Build, typecheck, lint and formatting checks passed.
webpro
left a comment
There was a problem hiding this comment.
Thanks, Éverton! I reproduced this on main: with --only barrel.ts, the barrel was deleted even when a dynamic import, a namespace import or a .vue file still used it, while discovery mode kept it in all three cases. With this PR, --only reports the same as discovery mode, and the new tests fail without the change.
One structural request, inline: track consumers in one place for both modes.
| if (ctx.only.length === 0) { | ||
| await discoverBarrels(analysis, filePath, ctx); | ||
| } else { | ||
| trackExplicitBarrelConsumers(analysis, filePath, ctx); | ||
| } |
There was a problem hiding this comment.
Discovery mode records the same consumers inside discoverBarrels, through its addDynamicConsumer and addConsumer calls, so consumers are now tracked in two places, one per mode. The bug came from that tracking living inside discoverBarrels, which --only skips. Could both modes call this function instead? The tracker ignores paths that aren't registered, so calling it after discoverBarrels records the same consumers, and those two calls in discoverBarrels can go. The full suite still passes with that change. A name without "Explicit" would then fit better.
| if (ctx.only.length === 0) { | |
| await discoverBarrels(analysis, filePath, ctx); | |
| } else { | |
| trackExplicitBarrelConsumers(analysis, filePath, ctx); | |
| } | |
| if (ctx.only.length === 0) { | |
| await discoverBarrels(analysis, filePath, ctx); | |
| } | |
| trackExplicitBarrelConsumers(analysis, filePath, ctx); |
Integrate the latest upstream main.
webpro
left a comment
There was a problem hiding this comment.
Thanks for the update! Both modes now track consumers in one place, and the --only cases still fail on main and pass with the change.
|
🚀 This pull request is included in v1.2.0. See Release 1.2.0 for release notes. |
With --only, consumer registration was skipped. A selected barrel could be deleted while a dynamic import, namespace import or non-TypeScript file still needed it.
Track consumers for explicitly selected barrels, including imports inside files forced to be barrels. Register the full selection before checking its relationships so selection order does not affect preservation, and retain the correct reason for star re-exports. Supported JavaScript namespace consumers now report the same preservation reason as TypeScript consumers.
The 197-test suite passed on Node 24. All 16 focused cases passed on Node 24 and compiled Node 20, including before/after execution, selection-order controls and dry-run/check behavior. Build, typecheck, lint and formatting checks passed.