Skip to content

fix(debarrel): Harden alias resolution, type imports, and namespace barrel preservation - #36

Merged
codemod-com-bot merged 13 commits into
mainfrom
fix/debarrel-barrel-reexports-and-type-imports
Jul 4, 2026
Merged

fix(debarrel): Harden alias resolution, type imports, and namespace barrel preservation#36
codemod-com-bot merged 13 commits into
mainfrom
fix/debarrel-barrel-reexports-and-type-imports

Conversation

@alexbit-codemod

Copy link
Copy Markdown
Contributor

Debarrel 0.7.4–0.7.10 fixes a cluster of failures discovered while running the codemod against the Sentry frontend. The package-boundary guard, tsconfig alias handling, type-import rewriting, and namespace-barrel detection were each too conservative or incomplete on their own; together they left consumers pointing at deleted barrels, emitted invalid TypeScript, or removed barrels that Storybook and MDX still namespace-import.

This PR bumps debarrel from 0.7.3 → 0.7.10 and adds 14 new JSSG test fixtures (including Sentry-shaped sentry/stories and sentry/icons layouts) that lock in the corrected behavior.

Tsconfig and package-boundary alias resolution (0.7.4)

The package-boundary guard previously treated every import whose prefix matched the workspace package.json name as a root package import and skipped rewriting. That broke subpath aliases like myapp/widgets when the package is named myapp, leaving consumers pointing at deleted barrel files after debarreling.

  • Distinguish package-root imports (myapp, @acme/ui) from subpath aliases (myapp/widgets, @acme/ui/internal) via isPackageRootImport.
  • Resolve tsconfig paths aliases to absolute module files (resolveAliasImportPath, resolveModuleImportPath).
  • Follow alias mappings when walking export * chains and when semantic analysis resolves through a barrel to the source file.

Default re-exports and inline type specifiers (0.7.5)

  • Walk explicit export { … } from "./y" re-exports before falling back to export * chains (findSymbolViaBarrelReexports).
  • Rewrite default imports that flow through export { Foo as default } barrels when the semantic analyzer cannot resolve the binding.
  • Preserve inline import { type Foo } specifiers when splitting partial barrel imports across paths (compatible with verbatimModuleSyntax).

Namespace barrel preservation (0.7.6)

Namespace imports (import * as Ns from "…") cannot be debarreled to a single module, so barrels with namespace consumers must be kept.

  • Skip barrel deletion when barrelHasNamespaceImporters finds any workspace file namespace-importing the barrel path.
  • Fix invalid import type { type Foo } output: inline type qualifiers on specifiers are now only emitted for mixed value/type imports split across paths, not for top-level import type statements.

Same-pass ordering and relative folder imports (0.7.7)

  • Resolve imports against index.barrel.bak.* when a barrel was already renamed earlier in the same migration pass, so later consumers still rewrite correctly.
  • Recognize renamed barrels via isBarrelFile (index.barrel.bak.ts pattern).
  • Match namespace-importer barrels by directory path, not only exact barrel file path.
  • Rewrite relative folder imports (e.g. ../textarea) to the concrete module when the directory barrel is removed.
  • Fix double type keyword in rewritten import type { … } when specifiers carry inline type qualifiers.

Aliased imports and JSSG-safe path helpers (0.7.8)

  • Resolve barrel symbols using the imported name (Foo in import { Foo as Bar }), not the local alias, so folder barrels and wildcard aliases debarrel correctly (getImportSpecifierNames).
  • Replace path.relative with portable relativePath / relativePathFromDir helpers for the JSSG runtime when computing export paths.
  • Normalize barrel paths during namespace-importer detection.

Package-name tsconfig aliases and MDX scanning (0.7.9)

Sentry-style layouts map sentry/*./static/app/*, so consumers import sentry/stories rather than a relative path. The namespace-importer scan must understand those aliases.

  • Inverse-map tsconfig path aliases to import strings that resolve to a barrel (getAliasImportPathsForBarrel).
  • Scan .mdx files for namespace imports when deciding whether to keep a barrel (fileHasMdxNamespaceImportFrom).
  • Resolve tsconfig and workspace roots with absolute paths during namespace-importer detection (findWorkspaceSourceRoot, normalizeAbsolutePath).

Barrel rename commit and Sentry fixtures (0.7.10)

  • Commit barrel renames even when a pure barrel file has no import edits (fixes .tsx barrels being skipped when edits is empty).
  • Add Sentry-shaped test fixtures for sentry/stories and sentry/icons namespace barrel preservation.

New test fixtures

Fixture What it covers
package-name-subpath-alias Subpath alias whose prefix matches package.json name
default-reexport-as-default Default import through export { Foo as default }
inline-type-only-import / full-type-only-import Top-level and inline type-only import rewriting
namespace-barrel-import Namespace-imported barrel is preserved
barrel-processing-order Consumer processed after barrel rename in same pass
relative-folder-import / alias-relative-folder-import Folder barrel removal rewrites to concrete module
alias-wildcard-folder-import / wildcard-scraps-alias Wildcard tsconfig aliases and aliased named imports
package-name-alias-namespace-barrel sentry/*-style alias + namespace barrel preservation
sentry-static-app-namespace-barrels Full Sentry static/app layout with stories, icons, MDX
sentry-icons-namespace-barrel sentry/icons namespace barrel
sentry-stories-mdx-namespace-barrel MDX namespace import of sentry/stories

Review focus

Start with scripts/utils/paths.ts and scripts/utils/exportStar.ts for the alias and namespace-importer logic, then scripts/utils/specifiers.ts and scripts/utils/imports.ts for import rewriting. The test fixtures under tests/ are the behavioral contract for the Sentry migration failures that motivated this work.

Made with Cursor

alexbit-codemod and others added 7 commits July 2, 2026 19:28
Package-boundary guard previously skipped every import whose prefix matched
the workspace package.json name, which left consumers pointing at deleted
barrels when the import was actually a tsconfig/webpack subpath alias.
Also teach path resolution to follow alias mappings when walking export *
chains and when semantic analysis resolves through a barrel file.

Co-authored-by: Cursor <cursoragent@cursor.com>
Walk explicit `export { … } from` re-exports before falling back to export *
chains so default imports through `export { Foo as default }` barrels are
rewritten when semantic analysis punts. Preserve inline `import { type Foo }`
specifiers when splitting partial barrel imports to stay compatible with
verbatimModuleSyntax.

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop emitting invalid `import type { type Foo }` when rewriting top-level
type-only imports, and skip barrel deletion when the workspace still
namespace-imports the barrel path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fix double `type` in rewritten type-only imports, resolve barrels already
renamed in the same pass, match namespace barrels by directory, and add
test fixtures for the Sentry migration failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
Look up barrel symbols by imported name (not local alias) so folder
barrels and wildcard aliases debarrel correctly, and replace path.relative
with JSSG-safe helpers for export path computation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Inverse-map tsconfig path aliases and scan MDX files so barrels like
sentry/stories are kept when consumers use namespace imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure pure barrels rename even with no import edits, and add test
fixtures mirroring sentry/stories and sentry/icons namespace imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexbit-codemod
alexbit-codemod requested review from Copilot, mohebifar and sahilmob and removed request for mohebifar July 3, 2026 08:30
@alexbit-codemod
alexbit-codemod requested review from mohebifar and sahilmob and removed request for sahilmob July 3, 2026 08:31
Add the missing SgNode import so check-types passes in CI.

Co-Authored-By: Cursor <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the debarrel codemod to handle real-world TS/JS import patterns more robustly (tsconfig paths aliases, default re-exports-as-default, inline type specifiers, namespace-imported barrels, and same-pass barrel renames), and adds fixtures modeled after Sentry’s frontend layout to lock in the behavior across 0.7.4–0.7.10.

Changes:

  • Harden import resolution by following tsconfig alias mappings (including wildcard aliases) and recognizing same-pass renamed barrels (index.barrel.bak.*).
  • Fix import rewriting edge cases (default re-export-as-default, inline type specifiers, relative folder imports) and preserve barrels when they have namespace importers (including in .mdx).
  • Bump debarrel version to 0.7.10 and add multiple new JSSG test fixtures covering the above behaviors.

Reviewed changes

Copilot reviewed 203 out of 203 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
codemods/debarrel/scripts/codemod.ts Integrates type-specifier tracking, namespace-barrel preservation, and ensures barrel renames commit even without import edits.
codemods/debarrel/scripts/utils/specifiers.ts Improves specifier resolution (aliases, default re-export handling, export-walk fallback) for debarreling rewrites.
codemods/debarrel/scripts/utils/paths.ts Adds alias/module resolution helpers, portable relative-path helpers, and workspace scanning utilities.
codemods/debarrel/scripts/utils/exportStar.ts Adds explicit re-export walking and namespace-importer detection (including MDX + alias awareness).
codemods/debarrel/scripts/utils/imports.ts Fixes invalid import type { type Foo } generation and improves type-only import emission.
codemods/debarrel/scripts/utils/barrel.ts Extends barrel export parsing to support default-import consumers through export { X as default }.
codemods/debarrel/scripts/utils/ast.ts Adds helper to distinguish imported name vs local alias for import { Foo as Bar }.
codemods/debarrel/package.json Bumps package version to 0.7.10.
codemods/debarrel/codemod.yaml Bumps codemod version metadata to 0.7.10.
codemods/debarrel/CHANGELOG.md Documents 0.7.4–0.7.10 fixes and newly added fixtures.
codemods/debarrel/tests/wildcard-scraps-alias/metrics.json Adds fixture metrics for wildcard alias debarreling behavior.
codemods/debarrel/tests/wildcard-scraps-alias/input/tsconfig.json Adds fixture tsconfig with wildcard paths alias.
codemods/debarrel/tests/wildcard-scraps-alias/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/wildcard-scraps-alias/input/src/core/badge/tag.ts Adds fixture module export used through a barrel.
codemods/debarrel/tests/wildcard-scraps-alias/input/src/core/badge/index.ts Adds fixture barrel file re-exporting a symbol.
codemods/debarrel/tests/wildcard-scraps-alias/input/src/App.ts Adds fixture consumer using wildcard alias import.
codemods/debarrel/tests/wildcard-scraps-alias/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/wildcard-scraps-alias/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/wildcard-scraps-alias/expected/src/core/badge/tag.ts Expected source module preserved.
codemods/debarrel/tests/wildcard-scraps-alias/expected/src/core/badge/index.barrel.bak.ts Expected renamed barrel after debarreling.
codemods/debarrel/tests/wildcard-scraps-alias/expected/src/App.ts Expected rewritten consumer import to concrete module path.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/metrics.json Adds fixture metrics for MDX namespace-import barrel preservation.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/tsconfig.json Adds Sentry-style sentry/* alias mapping to static/app/*.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/static/app/stories/storybook.ts Adds fixture storybook module.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/static/app/stories/index.tsx Adds fixture barrel re-export used by MDX namespace import.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/static/app/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/static/app/components/button.mdx Adds MDX namespace import that should preserve the barrel.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/input/package.json Adds fixture package metadata (package name sentry).
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/static/app/stories/storybook.ts Expected module preserved.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/static/app/stories/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/static/app/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/static/app/components/button.mdx Expected MDX unchanged (still namespace-importing barrel).
codemods/debarrel/tests/sentry-stories-mdx-namespace-barrel/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/metrics.json Adds fixture metrics for Sentry-shaped workspace with namespace barrels.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/tsconfig.json Adds fixture tsconfig with both @sentry/scraps/* and sentry/* aliases.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/stories/view/storyHeader.tsx Adds fixture consuming both sentry/icons and namespace sentry/stories.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/stories/storybook.ts Adds fixture storybook implementation.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/stories/index.tsx Adds fixture barrel that must be preserved due to namespace importers.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/stories/demo.ts Adds fixture export used under Storybook namespace.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/icons/index.tsx Adds fixture icons barrel (namespace-imported by stories).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/icons/icons.stories.tsx Adds fixture namespace importer for sentry/icons.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/icons/iconAdd.ts Adds fixture icon module.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/components/Page.tsx Adds fixture consumer using wildcard alias import.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/components/core/button/button.mdx Adds MDX namespace importer for sentry/stories.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/components/core/alert/index.ts Adds fixture barrel expected to be renamed (no namespace importers).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/static/app/components/core/alert/alert.ts Adds fixture alert module.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/input/package.json Adds fixture package metadata (package name sentry).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/stories/view/storyHeader.tsx Expected TSX preserved (barrels preserved where needed).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/stories/storybook.ts Expected module preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/stories/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/stories/demo.ts Expected module preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/icons/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/icons/icons.stories.tsx Expected consumer unchanged (still namespace-importing).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/icons/iconAdd.ts Expected module preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/components/Page.tsx Expected alias import rewrite output preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/components/core/button/button.mdx Expected MDX unchanged (still namespace-importing barrel).
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/components/core/alert/index.barrel.bak.ts Expected renamed barrel output.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/static/app/components/core/alert/alert.ts Expected module preserved.
codemods/debarrel/tests/sentry-static-app-namespace-barrels/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/sentry-icons-namespace-barrel/metrics.json Adds fixture metrics for sentry/icons namespace barrel preservation.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/tsconfig.json Adds fixture tsconfig alias mapping sentry/* to static/app/*.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/static/app/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/static/app/icons/index.tsx Adds fixture icons barrel.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/static/app/icons/icons.stories.tsx Adds fixture namespace importer for icons barrel.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/static/app/icons/iconAdd.ts Adds fixture icon module.
codemods/debarrel/tests/sentry-icons-namespace-barrel/input/package.json Adds fixture package metadata.
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/static/app/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/static/app/icons/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/static/app/icons/icons.stories.tsx Expected consumer unchanged (still namespace-importing).
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/static/app/icons/iconAdd.ts Expected module preserved.
codemods/debarrel/tests/sentry-icons-namespace-barrel/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/relative-folder-import/metrics.json Adds fixture metrics for relative folder import rewriting.
codemods/debarrel/tests/relative-folder-import/input/tsconfig.json Adds fixture tsconfig for relative import case.
codemods/debarrel/tests/relative-folder-import/input/src/textarea/textarea.ts Adds fixture module exported through a folder barrel.
codemods/debarrel/tests/relative-folder-import/input/src/textarea/index.ts Adds fixture folder barrel.
codemods/debarrel/tests/relative-folder-import/input/src/input/metrics.json Adds fixture input metrics for consumer folder.
codemods/debarrel/tests/relative-folder-import/input/src/input/inputGroup.ts Adds fixture consumer using relative folder imports.
codemods/debarrel/tests/relative-folder-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/relative-folder-import/expected/src/textarea/textarea.ts Expected module preserved.
codemods/debarrel/tests/relative-folder-import/expected/src/textarea/index.barrel.bak.ts Expected renamed folder barrel.
codemods/debarrel/tests/relative-folder-import/expected/src/input/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/relative-folder-import/expected/src/input/inputGroup.ts Expected rewritten relative imports to concrete module.
codemods/debarrel/tests/partial-with-type-specifiers/expected/src/consumer.ts Updates expected output to keep rewritten type imports as import type.
codemods/debarrel/tests/package-name-subpath-alias/metrics.json Adds fixture metrics for package-name-prefix subpath alias rewriting.
codemods/debarrel/tests/package-name-subpath-alias/input/tsconfig.json Adds fixture tsconfig alias myapp/*.
codemods/debarrel/tests/package-name-subpath-alias/input/src/widgets/Widget.ts Adds fixture module exported through barrel.
codemods/debarrel/tests/package-name-subpath-alias/input/src/widgets/index.ts Adds fixture barrel.
codemods/debarrel/tests/package-name-subpath-alias/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/package-name-subpath-alias/input/src/App.ts Adds fixture consumer importing via subpath alias.
codemods/debarrel/tests/package-name-subpath-alias/input/package.json Adds fixture package name matching alias prefix.
codemods/debarrel/tests/package-name-subpath-alias/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/package-name-subpath-alias/expected/src/widgets/Widget.ts Expected module preserved.
codemods/debarrel/tests/package-name-subpath-alias/expected/src/widgets/index.barrel.bak.ts Expected renamed barrel.
codemods/debarrel/tests/package-name-subpath-alias/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/package-name-subpath-alias/expected/src/App.ts Expected rewritten import path into concrete module.
codemods/debarrel/tests/package-name-subpath-alias/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/tsconfig.json Adds fixture with alias sharing package name and namespace barrels.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/z-widget.stories.tsx Adds TSX namespace importer of aliased barrel.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/stories/storybook.ts Adds fixture story function implementation.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/stories/index.tsx Adds fixture barrel that must be preserved.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/stories/demo.ts Adds fixture story export.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/icons/index.tsx Adds fixture icons barrel.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/icons/iconAdd.ts Adds fixture icon export.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/icons.stories.tsx Adds fixture namespace importer for icons barrel.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/src/docs/widget.mdx Adds MDX namespace importer for aliased barrel.
codemods/debarrel/tests/package-name-alias-namespace-barrel/input/package.json Adds fixture package metadata (package name sentry).
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/z-widget.stories.tsx Expected namespace import unchanged.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/stories/storybook.ts Expected module preserved.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/stories/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/stories/demo.ts Expected module preserved.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/icons/index.tsx Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/icons/iconAdd.ts Expected module preserved.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/icons.stories.tsx Expected namespace import unchanged.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/src/docs/widget.mdx Expected MDX unchanged.
codemods/debarrel/tests/package-name-alias-namespace-barrel/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/namespace-barrel-import/input/tsconfig.json Adds fixture for namespace import requiring barrel preservation.
codemods/debarrel/tests/namespace-barrel-import/input/src/stories/storybook.ts Adds fixture story module.
codemods/debarrel/tests/namespace-barrel-import/input/src/stories/index.ts Adds fixture barrel module.
codemods/debarrel/tests/namespace-barrel-import/input/src/stories/demo.ts Adds fixture demo module.
codemods/debarrel/tests/namespace-barrel-import/input/src/consumer.ts Adds fixture consumer using namespace import.
codemods/debarrel/tests/namespace-barrel-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/namespace-barrel-import/expected/src/stories/storybook.ts Expected module preserved.
codemods/debarrel/tests/namespace-barrel-import/expected/src/stories/index.ts Expected barrel preserved (namespace-imported).
codemods/debarrel/tests/namespace-barrel-import/expected/src/stories/demo.ts Expected module preserved.
codemods/debarrel/tests/namespace-barrel-import/expected/src/consumer.ts Expected consumer unchanged (namespace import cannot be debarreled).
codemods/debarrel/tests/inline-type-only-import/metrics.json Adds fixture metrics for inline type-only import handling.
codemods/debarrel/tests/inline-type-only-import/input/tsconfig.json Adds fixture tsconfig for type-only import cases.
codemods/debarrel/tests/inline-type-only-import/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/inline-type-only-import/input/src/lib/index.ts Adds fixture barrel exporting only a type via inline type.
codemods/debarrel/tests/inline-type-only-import/input/src/lib/config.ts Adds fixture type definition module.
codemods/debarrel/tests/inline-type-only-import/input/src/App.ts Adds fixture consumer using inline type-only import from barrel.
codemods/debarrel/tests/inline-type-only-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/inline-type-only-import/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/inline-type-only-import/expected/src/lib/index.barrel.bak.ts Expected renamed barrel after debarreling.
codemods/debarrel/tests/inline-type-only-import/expected/src/lib/config.ts Expected module preserved.
codemods/debarrel/tests/inline-type-only-import/expected/src/App.ts Expected rewrite to import type from the concrete module.
codemods/debarrel/tests/full-type-only-import/metrics.json Adds fixture metrics for top-level import type rewriting.
codemods/debarrel/tests/full-type-only-import/input/tsconfig.json Adds fixture tsconfig for top-level import type.
codemods/debarrel/tests/full-type-only-import/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/full-type-only-import/input/src/components/index.ts Adds fixture barrel exporting only a type.
codemods/debarrel/tests/full-type-only-import/input/src/components/button.ts Adds fixture type definition module.
codemods/debarrel/tests/full-type-only-import/input/src/App.ts Adds fixture consumer using import type from barrel.
codemods/debarrel/tests/full-type-only-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/full-type-only-import/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/full-type-only-import/expected/src/components/index.barrel.bak.ts Expected renamed barrel after debarreling.
codemods/debarrel/tests/full-type-only-import/expected/src/components/button.ts Expected module preserved.
codemods/debarrel/tests/full-type-only-import/expected/src/App.ts Expected rewrite to import type from the concrete module.
codemods/debarrel/tests/default-reexport-as-default/metrics.json Adds fixture metrics for default re-export-as-default handling.
codemods/debarrel/tests/default-reexport-as-default/input/tsconfig.json Adds fixture tsconfig with wildcard alias.
codemods/debarrel/tests/default-reexport-as-default/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/default-reexport-as-default/input/src/core/interactionStateLayer/interactionStateLayer.ts Adds fixture source module export.
codemods/debarrel/tests/default-reexport-as-default/input/src/core/interactionStateLayer/index.ts Adds fixture barrel re-exporting named symbol as default.
codemods/debarrel/tests/default-reexport-as-default/input/src/App.ts Adds fixture consumer default-importing from barrel.
codemods/debarrel/tests/default-reexport-as-default/input/package.json Adds fixture package metadata.
codemods/debarrel/tests/default-reexport-as-default/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/default-reexport-as-default/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/default-reexport-as-default/expected/src/core/interactionStateLayer/interactionStateLayer.ts Expected module preserved.
codemods/debarrel/tests/default-reexport-as-default/expected/src/core/interactionStateLayer/index.barrel.bak.ts Expected renamed barrel after debarreling.
codemods/debarrel/tests/default-reexport-as-default/expected/src/App.ts Expected rewrite from default import to named import at concrete path.
codemods/debarrel/tests/default-reexport-as-default/expected/package.json Expected package metadata preserved.
codemods/debarrel/tests/barrel-processing-order/metrics.json Adds fixture metrics for same-pass rename ordering.
codemods/debarrel/tests/barrel-processing-order/input/tsconfig.json Adds fixture tsconfig for ordering case.
codemods/debarrel/tests/barrel-processing-order/input/src/z-consumer.ts Adds consumer processed after barrel rename in same pass.
codemods/debarrel/tests/barrel-processing-order/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/barrel-processing-order/input/src/a-stories/storybook.ts Adds fixture story module.
codemods/debarrel/tests/barrel-processing-order/input/src/a-stories/index.ts Adds fixture barrel.
codemods/debarrel/tests/barrel-processing-order/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/barrel-processing-order/expected/src/z-consumer.ts Expected rewrite that resolves against renamed barrel.
codemods/debarrel/tests/barrel-processing-order/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/barrel-processing-order/expected/src/a-stories/storybook.ts Expected module preserved.
codemods/debarrel/tests/barrel-processing-order/expected/src/a-stories/index.barrel.bak.ts Expected renamed barrel after debarreling.
codemods/debarrel/tests/alias-wildcard-folder-import/metrics.json Adds fixture metrics for aliased imports + wildcard alias path rewriting.
codemods/debarrel/tests/alias-wildcard-folder-import/input/tsconfig.json Adds fixture tsconfig with wildcard alias.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/core/image/index.ts Adds fixture image barrel.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/core/image/image.ts Adds fixture image module.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/core/badge/tag.ts Adds fixture badge module.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/core/badge/index.ts Adds fixture badge barrel.
codemods/debarrel/tests/alias-wildcard-folder-import/input/src/App.ts Adds fixture consumer with aliased named imports.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/core/image/index.barrel.bak.ts Expected renamed barrel.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/core/image/image.ts Expected module preserved.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/core/badge/tag.ts Expected module preserved.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/core/badge/index.barrel.bak.ts Expected renamed barrel.
codemods/debarrel/tests/alias-wildcard-folder-import/expected/src/App.ts Expected rewritten imports to concrete modules (preserving local aliases).
codemods/debarrel/tests/alias-relative-folder-import/metrics.json Adds fixture metrics for relative folder imports with local aliases.
codemods/debarrel/tests/alias-relative-folder-import/input/tsconfig.json Adds fixture tsconfig for relative folder case.
codemods/debarrel/tests/alias-relative-folder-import/input/src/textarea/textarea.ts Adds fixture module exported via folder barrel.
codemods/debarrel/tests/alias-relative-folder-import/input/src/textarea/index.ts Adds fixture folder barrel.
codemods/debarrel/tests/alias-relative-folder-import/input/src/input/metrics.json Adds fixture input metrics.
codemods/debarrel/tests/alias-relative-folder-import/input/src/input/inputGroup.ts Adds fixture consumer using relative folder imports with an alias.
codemods/debarrel/tests/alias-relative-folder-import/expected/tsconfig.json Expected tsconfig preserved after codemod.
codemods/debarrel/tests/alias-relative-folder-import/expected/src/textarea/textarea.ts Expected module preserved.
codemods/debarrel/tests/alias-relative-folder-import/expected/src/textarea/index.barrel.bak.ts Expected renamed folder barrel.
codemods/debarrel/tests/alias-relative-folder-import/expected/src/input/metrics.json Expected metrics output for fixture.
codemods/debarrel/tests/alias-relative-folder-import/expected/src/input/inputGroup.ts Expected rewritten relative imports to concrete module paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread codemods/debarrel/scripts/utils/specifiers.ts
Comment thread codemods/debarrel/scripts/utils/paths.ts
Comment thread codemods/debarrel/scripts/utils/exportStar.ts Outdated
Comment thread codemods/debarrel/scripts/utils/paths.ts Outdated
Comment thread codemods/debarrel/scripts/utils/ast.ts
alexbit-codemod and others added 5 commits July 3, 2026 17:28
Real-world tsconfigs (including Sentry) use comments and trailing commas,
which caused JSON.parse to fail silently and skip path alias rewriting.

Add a JSONC-tolerant tsconfig reader and a fixture that proves alias
debarreling works when paths are declared in a commented tsconfig.

Co-Authored-By: Auto <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
When the semantic analyzer resolved through a barrel to the source file,
rewrites always used named imports and keyed metrics on the target file
instead of the barrel. Route through buildRewriteFromTarget and distinguish
`export { default }` from `export { Foo as default }` when picking import
type.

Co-Authored-By: Auto <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
barrelHasNamespaceImporters walked the full project tree for every
barrel candidate. Cache the file list by workspace root for the duration
of a codemod run to avoid repeated recursive directory scans.

Co-Authored-By: Auto <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the hand-rolled relative path helper with path.relative, which
is available in the JSSG runtime. joinImportPaths still avoids path.join
due to its leading-../ bug.

Co-Authored-By: Auto <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Auto <noreply@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@codemod-com-bot
codemod-com-bot merged commit 14c72ee into main Jul 4, 2026
1 check passed
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.

4 participants