Add ESM support
sheremet-va opened this issue ยท 5 comments
preact-testing-library
version: 2.0.1preact
version: anynode
version: anynpm
(oryarn
) version: any
Problem description:
This package doesn't have ESM support. This is needed for vitest
to properly load ESM
version of preact: related issue
Suggested solution:
Bundle ESM and add it to exports
field, so Node can resolve it automatically.
Ah, my Preact hook tests are broken because of this :)
I am going to try using preact/text-utils
directly instead...
The release is available on:
Your semantic-release bot
@sheremet-va is this working for you? Not working at my end, I am afraid :(
Fails in Vitest with:
pnpx vitest --run --config vitest.config.js
("type": "module"
in all my package.json
, including the root Turbo monorepo)
vitest.config.js
==>
export default {
test: {
globals: false,
},
};
import { cleanup, render, waitFor } from '@testing-library/preact/pure';
===>
Error: Cannot find module '/PATH/TO/node_modules/.pnpm/@testing-library+preact@3.1.1_preact@10.7.2/node_modules/@testing-library/preact/dist/esm/fire-event' imported from /PATH/TO/node_modules/.pnpm/@testing-library+preact@3.1.1_preact@10.7.2/node_modules/@testing-library/preact/dist/esm/pure.mjs
(basically, the system seems to be confused between node_modules/@testing-library/preact/dist/esm/pure.mjs
and node_modules/@testing-library/preact/dist/esm/pure.js
... not sure exactly)
As mentioned here vitest-dev/vitest#747 (comment)
...my workaround consists in copying @testing-library/preact
's pure.js
and associated TypeScript types into my codebase.
@danielweck this should be fixed now sorry about that
Brilliant, all good now :)
Thanks Jovi.