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

Use .js extension for build outputs #927

Closed
wants to merge 3 commits into from

Conversation

strmer15
Copy link

@strmer15 strmer15 commented Apr 13, 2022

What:
Fixes #839 by separating the ESM build and CommonJS builds into different directories, instead of using .cjs and .mjs extensions.

Why:
Some build tools don't work well with the .cjs / .mjs extensions, so using a .js extension is more compatible. Users with existing tooling setup for .js don't need to update their configurations to work with the new extensions.

How:
The entry points in package.json were changed to use index.js with the ESM build using an esm/ directory. The build.js script now tells esbuild to put the files in the appropriate space with the .js extension.

Checklist:

  • Documentation - N/A
  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 13, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit acbe109:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration

@codecov
Copy link

codecov bot commented Apr 13, 2022

Codecov Report

Merging #927 (acbe109) into main (ef826a4) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #927   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           85        85           
  Lines         1785      1785           
  Branches       641       641           
=========================================
  Hits          1785      1785           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef826a4...acbe109. Read the comment docs.

@ph-fritsche
Copy link
Member

First of all: Thanks for taking the time to contribute to this library.

The package.json does not have a type field. The dist/esm/index.js will be treated as CommonJS by Node and any environment following their module resolution.

@strmer15
Copy link
Author

First of all: Thanks for taking the time to contribute to this library.

The package.json does not have a type field. The dist/esm/index.js will be treated as CommonJS by Node and any environment following their module resolution.

Ah, ok - good point. I was thinking of this in terms of Webpack, which will use either the module or the exports declarations. I think a good way to deal with this would be to generate a package.json file that only contains { "type": "module" } and place it in the dist/esm directory. Does that sound good to you?

@ph-fritsche
Copy link
Member

Sounds as if it should work. But the current export should work too.
So I guess I'll keep this open for a while. Hopefully some people try the build from this PR in different environments and give some feedback.

@pgarciacamou
Copy link

pgarciacamou commented May 20, 2022

I pulled the build from @ph-fritsche (note: it is a compressed .zip file without extension, so you might have to manually add the .zip extension to be able to decompress it) and replaced the one in node_modules:

Screen Shot 2022-05-20 at 3 32 58 PM

So far, it is the only thing that has worked for me to solve the TypeError: _userEvent.default.setup is not a function issue mentioned in #839. All the jest setups mentioned in the comments or installing "@testing-library/dom" (as you can see I still tried above) which was suggested in another other issue by Kent did not work for me.

I'm using all the latest packages (as of today):

    "@testing-library/dom": "8.13.0",
    "@testing-library/jest-dom": "5.16.4",
    "@testing-library/react": "13.2.0",
    "@testing-library/user-event": "14.2.0",

@pgarciacamou
Copy link

Any news?

@ph-fritsche
Copy link
Member

closed in favor of #949

@ph-fritsche ph-fritsche closed this Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_userEvent.default.setup is not a function
3 participants