diff --git a/.babelrc b/.babelrc index faf0601..1380931 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,6 @@ { "presets": [ - ["@babel/preset-env", { "targets": { "node": "8" } }]], + ["@babel/preset-env", { "targets": { "node": "12" } }]], "plugins": [ ["@babel/plugin-proposal-class-properties"], ["@babel/plugin-transform-react-jsx", { "pragma": "h" }], diff --git a/.babelrc.esm.json b/.babelrc.esm.json new file mode 100644 index 0000000..a3dc2fc --- /dev/null +++ b/.babelrc.esm.json @@ -0,0 +1,15 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "modules": false, + "targets": { "node": "12" } + } + ] + ], + "plugins": [ + ["@babel/plugin-proposal-class-properties"], + ["@babel/plugin-transform-react-jsx", { "pragma": "h" }] + ] +} diff --git a/dont-clean-up-after-each.js b/dont-clean-up-after-each.js index 22688e1..51d3277 100644 --- a/dont-clean-up-after-each.js +++ b/dont-clean-up-after-each.js @@ -1 +1 @@ -process.env.PTL_SKIP_AUTO_CLEANUP = true; +process.env.PTL_SKIP_AUTO_CLEANUP = true diff --git a/package.json b/package.json index a595faa..46fd471 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,21 @@ "name": "@testing-library/preact", "version": "0.0.0-semantically-released", "description": "Simple and complete Preact DOM testing utilities that encourage good testing practices.", - "main": "dist/index.js", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", "types": "types/index.d.ts", + "exports": { + ".": { + "types": "./types/index.d.ts", + "import": "./dist/esm/index.js", + "browser": "./dist/cjs/index.js" + }, + "./pure": { + "types": "./pure.d.ts", + "import": "./dist/esm/pure.js", + "browser": "./dist/cjs/pure.js" + } + }, "license": "MIT", "author": "Rahim Alwer ", "homepage": "https://github.com/testing-library/preact-testing-library#readme", @@ -33,13 +46,16 @@ "dist", "dont-cleanup-after-each.js", "pure.js", - "types/index.d.ts" + "types/index.d.ts", + "pure.d.ts" ], "scripts": { "toc": "doctoc README.md", "lint": "eslint src/**/*.js --fix", "clean": "rimraf dist", - "build": " babel src --out-dir dist --ignore '**/__tests__/**,**/__mocks__/**'", + "build": "npm run build:cjs && npm run build:esm", + "build:cjs": "babel src --out-dir dist/cjs --config-file ./.babelrc --ignore '**/__tests__/**,**/__mocks__/**'", + "build:esm": "babel src --no-babelrc --out-dir dist/esm --config-file ./.babelrc.esm.json --ignore '**/__tests__/**,**/__mocks__/**'", "test": "jest src/__tests__ ", "test:watch": "npm test --watch", "test:update": "npm test --updateSnapshot --coverage", diff --git a/pure.js b/pure.js index 714e7ac..607b34a 100644 --- a/pure.js +++ b/pure.js @@ -1,2 +1,2 @@ // Makes it so people can import from '@testing-library/preact/pure' -module.exports = require('./dist/pure'); +module.exports = require('./dist/pure')