Skip to content

Commit ce46ca7

Browse files
authored
feat: add esm support (#55)
1 parent d547700 commit ce46ca7

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
["@babel/preset-env", { "targets": { "node": "8" } }]],
3+
["@babel/preset-env", { "targets": { "node": "12" } }]],
44
"plugins": [
55
["@babel/plugin-proposal-class-properties"],
66
["@babel/plugin-transform-react-jsx", { "pragma": "h" }],

.babelrc.esm.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": false,
7+
"targets": { "node": "12" }
8+
}
9+
]
10+
],
11+
"plugins": [
12+
["@babel/plugin-proposal-class-properties"],
13+
["@babel/plugin-transform-react-jsx", { "pragma": "h" }]
14+
]
15+
}

dont-clean-up-after-each.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
process.env.PTL_SKIP_AUTO_CLEANUP = true;
1+
process.env.PTL_SKIP_AUTO_CLEANUP = true

package.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22
"name": "@testing-library/preact",
33
"version": "0.0.0-semantically-released",
44
"description": "Simple and complete Preact DOM testing utilities that encourage good testing practices.",
5-
"main": "dist/index.js",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
67
"types": "types/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./types/index.d.ts",
11+
"import": "./dist/esm/index.js",
12+
"browser": "./dist/cjs/index.js"
13+
},
14+
"./pure": {
15+
"types": "./pure.d.ts",
16+
"import": "./dist/esm/pure.js",
17+
"browser": "./dist/cjs/pure.js"
18+
}
19+
},
720
"license": "MIT",
821
"author": "Rahim Alwer <[email protected]>",
922
"homepage": "https://github.com/testing-library/preact-testing-library#readme",
@@ -33,13 +46,16 @@
3346
"dist",
3447
"dont-cleanup-after-each.js",
3548
"pure.js",
36-
"types/index.d.ts"
49+
"types/index.d.ts",
50+
"pure.d.ts"
3751
],
3852
"scripts": {
3953
"toc": "doctoc README.md",
4054
"lint": "eslint src/**/*.js --fix",
4155
"clean": "rimraf dist",
42-
"build": " babel src --out-dir dist --ignore '**/__tests__/**,**/__mocks__/**'",
56+
"build": "npm run build:cjs && npm run build:esm",
57+
"build:cjs": "babel src --out-dir dist/cjs --config-file ./.babelrc --ignore '**/__tests__/**,**/__mocks__/**'",
58+
"build:esm": "babel src --no-babelrc --out-dir dist/esm --config-file ./.babelrc.esm.json --ignore '**/__tests__/**,**/__mocks__/**'",
4359
"test": "jest src/__tests__ ",
4460
"test:watch": "npm test --watch",
4561
"test:update": "npm test --updateSnapshot --coverage",

pure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Makes it so people can import from '@testing-library/preact/pure'
2-
module.exports = require('./dist/pure');
2+
module.exports = require('./dist/pure')

0 commit comments

Comments
 (0)