Skip to content

Commit 719b35b

Browse files
authored
Publish both esm and cjs (#438)
1 parent 4d0ceeb commit 719b35b

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22
"name": "@testing-library/jest-dom",
33
"version": "0.0.0-semantically-released",
44
"description": "Custom jest matchers to test the state of the DOM",
5-
"main": "dist/index.js",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
7+
"exports": {
8+
".": {
9+
"require": "./dist/cjs/index.js",
10+
"import": "./dist/esm/index.js"
11+
},
12+
"./matchers": {
13+
"require": "./dist/cjs/matchers.js",
14+
"import": "./dist/esm/matchers.js"
15+
}
16+
},
617
"engines": {
718
"node": ">=8",
819
"npm": ">=6",
920
"yarn": ">=1"
1021
},
1122
"scripts": {
12-
"build": "kcd-scripts build",
23+
"build": "rollup -c",
1324
"format": "kcd-scripts format",
1425
"lint": "kcd-scripts lint",
1526
"setup": "npm install && npm run validate -s",
@@ -46,7 +57,8 @@
4657
"jest-watch-select-projects": "^2.0.0",
4758
"jsdom": "^16.2.1",
4859
"kcd-scripts": "^11.1.0",
49-
"pretty-format": "^25.1.0"
60+
"pretty-format": "^25.1.0",
61+
"rollup": "^2.68.0"
5062
},
5163
"eslintConfig": {
5264
"extends": "./node_modules/kcd-scripts/eslint.js",

rollup.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import path from 'path'
2+
import pkg from './package.json'
3+
4+
export default [
5+
{
6+
input: {
7+
index: 'src/index.js',
8+
matchers: 'src/matchers.js',
9+
},
10+
output: [
11+
{
12+
dir: path.dirname(pkg.exports['./matchers'].import),
13+
format: 'esm',
14+
},
15+
{
16+
dir: path.dirname(pkg.exports['./matchers'].require),
17+
format: 'cjs',
18+
},
19+
],
20+
external: id =>
21+
!id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/'),
22+
},
23+
]

0 commit comments

Comments
 (0)