insert rewritten imports in place of the old ones

This commit is contained in:
Oleksii Bulenok
2026-08-31 15:04:21 +02:00
parent 884950c34e
commit 1afff03313
2 changed files with 29 additions and 12 deletions
@@ -84,6 +84,18 @@ describe('transform', () => {
expect(out).not.toContain('import *')
})
test('inserts leaf imports at the barrel import position, not the top', () => {
const out = applyPlugin(
`import './setup'\nimport {app} from './lexicons'\nvoid app.bsky.feed.like\n`,
PROBE_FILE,
)
const setupAt = out.indexOf(`'./setup'`)
const leafAt = out.indexOf('import * as _lex_app_bsky_feed_like')
expect(setupAt).toBeGreaterThanOrEqual(0)
expect(leafAt).toBeGreaterThan(setupAt)
expect(out).not.toContain(`from './lexicons'`)
})
test('ignores imports that are not lexicon barrels', () => {
const src = `import {app} from './other'\nvoid app.bsky.feed.like\n`
const out = applyPlugin(src, PROBE_FILE)