Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESM support #50

Closed
sheremet-va opened this issue Feb 14, 2022 · 5 comments · Fixed by #55
Closed

Add ESM support #50

sheremet-va opened this issue Feb 14, 2022 · 5 comments · Fixed by #55
Assignees
Labels

Comments

@sheremet-va
Copy link

  • preact-testing-library version: 2.0.1
  • preact version: any
  • node version: any
  • npm (or yarn) 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.

@danielweck
Copy link

Ah, my Preact hook tests are broken because of this :)
I am going to try using preact/text-utils directly instead...

@github-actions
Copy link

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@danielweck
Copy link

danielweck commented May 25, 2022

@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.

@JoviDeCroock
Copy link
Member

@danielweck this should be fixed now sorry about that

@danielweck
Copy link

Brilliant, all good now :)
Thanks Jovi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants