Skip to content

Commit

Permalink
Publish both esm and cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Feb 24, 2022
1 parent 4d0ceeb commit cf540f4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@
"name": "@testing-library/jest-dom",
"version": "0.0.0-semantically-released",
"description": "Custom jest matchers to test the state of the DOM",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"./matchers": {
"require": "./dist/cjs/matchers.js",
"import": "./dist/esm/matchers.js"
}
},
"engines": {
"node": ">=8",
"npm": ">=6",
"yarn": ">=1"
},
"scripts": {
"build": "kcd-scripts build",
"build": "rollup -c",
"format": "kcd-scripts format",
"lint": "kcd-scripts lint",
"setup": "npm install && npm run validate -s",
Expand Down Expand Up @@ -46,7 +57,8 @@
"jest-watch-select-projects": "^2.0.0",
"jsdom": "^16.2.1",
"kcd-scripts": "^11.1.0",
"pretty-format": "^25.1.0"
"pretty-format": "^25.1.0",
"rollup": "^2.68.0"
},
"eslintConfig": {
"extends": "./node_modules/kcd-scripts/eslint.js",
Expand Down
23 changes: 23 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import path from 'path'
import pkg from './package.json'

export default [
{
input: {
index: 'src/index.js',
matchers: 'src/matchers.js',
},
output: [
{
dir: path.dirname(pkg.exports['./matchers'].import),
format: 'esm',
},
{
dir: path.dirname(pkg.exports['./matchers'].require),
format: 'cjs',
},
],
external: id =>
!id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/'),
},
]

0 comments on commit cf540f4

Please sign in to comment.