diff --git a/extend-expect.js b/extend-expect.js deleted file mode 100644 index e7d19c10..00000000 --- a/extend-expect.js +++ /dev/null @@ -1,2 +0,0 @@ -// eslint-disable-next-line -require('./dist/extend-expect') diff --git a/package.json b/package.json index 8c7ddfc9..e6e9217a 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,17 @@ "name": "@testing-library/jest-dom", "version": "0.0.0-semantically-released", "description": "Custom jest matchers to test the state of the DOM", - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", + "main": "dist/index.js", + "module": "dist/index.mjs", + "type": "commonjs", "exports": { ".": { - "require": "./dist/cjs/index.js", - "import": "./dist/esm/index.js" + "require": "./dist/index.js", + "import": "./dist/index.mjs" }, "./matchers": { - "require": "./dist/cjs/matchers.js", - "import": "./dist/esm/matchers.js" + "require": "./dist/matchers.js", + "import": "./dist/matchers.mjs" } }, "engines": { @@ -20,7 +21,7 @@ "yarn": ">=1" }, "scripts": { - "build": "rollup -c", + "build": "rimraf dist && rollup -c", "format": "kcd-scripts format", "lint": "kcd-scripts lint", "setup": "npm install && npm run validate -s", @@ -30,7 +31,6 @@ }, "files": [ "dist", - "extend-expect.js", "matchers.js" ], "keywords": [ @@ -58,6 +58,7 @@ "jsdom": "^16.2.1", "kcd-scripts": "^11.1.0", "pretty-format": "^25.1.0", + "rimraf": "^3.0.2", "rollup": "^2.68.0" }, "eslintConfig": { diff --git a/rollup.config.js b/rollup.config.js index 81b5e042..61162cd2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,22 +1,25 @@ -import path from 'path' -import pkg from './package.json' +const entries = ['src/index.js', 'src/matchers.js'] export default [ { - input: { - index: 'src/index.js', - matchers: 'src/matchers.js', + input: entries, + output: { + dir: 'dist', + entryFileNames: '[name].mjs', + chunkFileNames: '[name]-[hash].mjs', + format: 'esm', + }, + external: id => + !id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/'), + }, + { + input: entries, + output: { + dir: 'dist', + entryFileNames: '[name].js', + chunkFileNames: '[name]-[hash].js', + format: 'cjs', }, - 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('/'), }, diff --git a/src/extend-expect.js b/src/extend-expect.js deleted file mode 100644 index 3801a1d5..00000000 --- a/src/extend-expect.js +++ /dev/null @@ -1,3 +0,0 @@ -import * as extensions from './matchers' - -expect.extend(extensions) diff --git a/src/index.js b/src/index.js index 8cecbe35..3801a1d5 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,3 @@ -import './extend-expect' +import * as extensions from './matchers' + +expect.extend(extensions) diff --git a/src/to-have-form-values.js b/src/to-have-form-values.js index c3fddcc0..fe8c890a 100644 --- a/src/to-have-form-values.js +++ b/src/to-have-form-values.js @@ -1,5 +1,5 @@ -import isEqualWith from 'lodash/isEqualWith' -import uniq from 'lodash/uniq' +import isEqualWith from 'lodash/isEqualWith.js' +import uniq from 'lodash/uniq.js' import escape from 'css.escape' import { checkHtmlElement, diff --git a/src/to-have-value.js b/src/to-have-value.js index 0b24e165..da79e416 100644 --- a/src/to-have-value.js +++ b/src/to-have-value.js @@ -1,4 +1,4 @@ -import isEqualWith from 'lodash/isEqualWith' +import isEqualWith from 'lodash/isEqualWith.js' import { checkHtmlElement, compareArraysAsSet, diff --git a/src/utils.js b/src/utils.js index 2f07fb8e..943f92c2 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,6 +1,6 @@ import redent from 'redent' -import cssParse from 'css/lib/parse' -import isEqual from 'lodash/isEqual' +import cssParse from 'css/lib/parse/index.js' +import isEqual from 'lodash/isEqual.js' class GenericTypeError extends Error { constructor(expectedString, received, matcherFn, context) { diff --git a/tests/setup-env.js b/tests/setup-env.js index a9325d25..151f6e7b 100644 --- a/tests/setup-env.js +++ b/tests/setup-env.js @@ -1,4 +1,4 @@ import {plugins} from 'pretty-format' -import '../src/extend-expect' +import '../src/index' expect.addSnapshotSerializer(plugins.ConvertAnsi)