Repository navigation
fix: re-export the named userEvent from the built entries - #12
Merged
Merged
Conversation
1.0.4 builds only the CJS bundle and makes index.mjs re-export it. bun build --target node compiles export { default as userEvent } to __toESM(require('@testing-library/user-event'), 1).default, and that Node-style interop ignores __esModule, so userEvent became user-event's whole module namespace ({ default, userEvent, PointerEventsCheckLevel }) and userEvent.type was undefined for every consumer.
Re-export the named userEvent binding instead, which does not depend on interop. The dist preload fixture now also types through the userEvent imported from each built entry; it fails on 1.0.4 with 'userEvent.type is not a function' and passes with this change.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
문제
1.0.4에서
userEventexport가 깨졌습니다. 의도치 않은 breaking change입니다.import { userEvent } from 'bun-test-env-dom'→userEvent.type is not a functionObject.keys(userEvent)가default,userEvent,PointerEventsCheckLevel로 나옵니다. user-event API가 아니라 모듈 namespace 전체가 export되고 있습니다.원인
#8에서 ESM 번들을 없애고
dist/index.mjs를export * from './index.cjs'로 바꿨습니다. 그런데bun build --target node --format cjs가export { default as userEvent } from '@testing-library/user-event'를 다음처럼 컴파일합니다.Node 방식 interop은
__esModule을 무시하고module.exports전체를default로 취급합니다. 그래서userEvent가 모듈 namespace가 됐습니다. 1.0.3은 ESM 번들에서import { default as F } from '@testing-library/user-event'를 썼기 때문에 정상이었습니다. 타입 선언은 그대로였기 때문에 tsc와 build는 통과했습니다.수정
src/index.ts: default 대신 이름으로 export된userEvent를 다시 export합니다. user-event 14는 CJS와 타입 모두에서userEvent라는 이름을 제공하므로, interop 방식과 상관없이 올바른 값이 나옵니다. 빌드 결과는userEvent: () => S.userEvent입니다.dist-preload.test.ts: 빌드된 각 진입 파일(dist/index.cjs,dist/index.mjs)을 preload한 새 프로세스에서, 그 진입 파일이 export한userEvent로 실제로 타이핑하는 테스트를 추가했습니다.TypeError: userEvent.type is not a function으로 실패검증
bun lint: 통과bun test: 28 pass, coverage 100%bun run build:dist/index.d.ts는export { userEvent } from '@testing-library/user-event'로 생성됩니다