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

Feature: Support native ESM #36

Closed
rschristian opened this issue Apr 18, 2021 · 3 comments · Fixed by #55
Closed

Feature: Support native ESM #36

rschristian opened this issue Apr 18, 2021 · 3 comments · Fixed by #55
Labels

Comments

@rschristian
Copy link
Contributor

rschristian commented Apr 18, 2021

  • preact-testing-library version: 2.0.1
  • preact version: 10.5.13
  • node version: 14.16.0
  • npm (or yarn) version: yarn 1.22.10

Relevant code or config

import { render, screen } from '@testing-library/preact';

What you did:

Tried to import from @testing-library/preact'

What happened:

SyntaxError: The requested module '@testing-library/preact' does not provide an export named 'render'

      at jasmine2 (node_modules/jest-jasmine2/build/index.js:228:5)

Problem description:

Currently @testing-library/preact does not offer ESM output, which makes it unsuitable for testing in a native ESM environment. This will begin to be a problem especially now that Node 10 is EOL ("type": "module" was first valid in v12.0.0, the now oldest support version of Node).

@testing-library/react does however support ESM, so preact here is behind. Edit: Apparently not. Apparently Jest doesn't even follow the widely used practice of the module key: jestjs/jest#2702 (comment)

Suggested solution:

Offer ESM output. Will just take an alteration of the build script.

@github-actions
Copy link

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@connorjclark
Copy link

Thanks @JoviDeCroock !

FYI I couldn't get an import to work until I put {"type": "module"} package.json in dist/esm.

@JoviDeCroock
Copy link
Member

@connorjclark fixed in #58

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