diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c30f829..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@react-bootstrap", "@babel/typescript"] -} diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 0000000..738f58d --- /dev/null +++ b/.babelrc.js @@ -0,0 +1,13 @@ +module.exports = (api) => { + return { + presets: [ + '@react-bootstrap', + [ + '@babel/typescript', + { + rewriteImportExtensions: api.env() !== 'development', + }, + ], + ], + }; +}; diff --git a/.gitignore b/.gitignore index 2d1ca22..da42e46 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,6 @@ $RECYCLE.BIN/ *.msi *.msm *.msp + +esm +cjs diff --git a/.size-snapshot.json b/.size-snapshot.json deleted file mode 100644 index 124d90a..0000000 --- a/.size-snapshot.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "lib/dist/dom-helpers.js": { - "bundled": 24575, - "minified": 12882, - "gzipped": 4632, - "treeshaked": { - "rollup": { - "code": 716, - "import_statements": 0 - }, - "webpack": { - "code": 2003 - } - } - } -} diff --git a/karma.conf.js b/karma.conf.js index 203dc52..a400380 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,7 +1,7 @@ -'use strict' +'use strict'; -module.exports = config => { - const { env } = process +module.exports = (config) => { + const { env } = process; config.set({ basePath: '', @@ -55,5 +55,5 @@ module.exports = config => { webpackServer: { noInfo: true, }, - }) -} + }); +}; diff --git a/package.json b/package.json index dde0ea4..1d89269 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,36 @@ "url": "git+https://github.com/react-bootstrap/dom-helpers.git" }, "license": "MIT", - "main": "lib/cjs/index.js", - "types": "lib/cjs/index.d.ts", - "module": "lib/esm/index.js", + "files": [ + "cjs", + "esm" + ], + "main": "esm/index.js", + "types": "esm/index.d.ts", + "module": "esm/index.js", + "exports": { + "./package.json": "./package.json", + ".": { + "require": { + "types": "./cjs/index.d.ts", + "default": "./cjs/index.js" + }, + "import": { + "types": "./esm/index.d.ts", + "default": "./esm/index.js" + } + }, + "./*": { + "require": { + "types": "./cjs/*.d.ts", + "default": "./cjs/*.js" + }, + "import": { + "types": "./esm/*.d.ts", + "default": "./esm/*.js" + } + } + }, "keywords": [ "dom-helpers", "react-component", @@ -32,68 +59,63 @@ "scripts": { "test": "karma start --single-run", "tdd": "karma start", - "check:size": "rollup -c", - "build:pick": "cherry-pick --name=dom-helpers --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm", - "build": "rimraf lib && node_modules/.bin/build src && yarn build:pick", + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "rimraf cjs && babel src --out-dir cjs --delete-dir-on-start --env-name cjs --extensions .ts && yarn build:cjs:types && echo '{\"type\": \"commonjs\"}' > cjs/package.json", + "build:esm": "rimraf esm && babel src --out-dir esm --delete-dir-on-start --env-name esm --extensions .ts && yarn build:esm:types && echo '{\"type\": \"module\"}' > esm/package.json", + "build:cjs:types": "tsc --emitDeclarationOnly --module commonjs --outDir cjs", + "build:esm:types": "tsc --emitDeclarationOnly --module esnext --outDir esm", "prepublishOnly": "yarn build", "lint": "tsc -p ./ --noEmit && eslint src test", "release": "rollout" }, - "publishConfig": { - "directory": "lib" - }, "release": { "conventionalCommits": true }, "dependencies": { - "@babel/runtime": "^7.8.7", - "csstype": "^3.0.2" + "@babel/runtime": "^7.27.1", + "csstype": "^3.1.3" }, "devDependencies": { - "@4c/build": "^2.3.1", - "@4c/rollout": "^2.2.1", - "@4c/tsconfig": "^0.3.1", - "@babel/cli": "^7.13.16", - "@babel/core": "^7.14.0", - "@babel/preset-typescript": "^7.13.0", - "@react-bootstrap/babel-preset": "^1.2.0", + "@4c/rollout": "^4.0.2", + "@4c/tsconfig": "^0.4.1", + "@babel/cli": "^7.27.2", + "@babel/core": "^7.27.1", + "@babel/preset-typescript": "^7.27.1", + "@react-bootstrap/babel-preset": "^2.3.0", "@react-bootstrap/eslint-config": "^1.3.2", "@react-bootstrap/eslint-config-typescript": "^2.0.1", "@typescript-eslint/eslint-plugin": "^4.22.1", "@typescript-eslint/parser": "^4.22.1", "babel-eslint": "^10.1.0", - "babel-loader": "^8.2.2", - "cherry-pick": "^0.5.0", + "babel-loader": "^10.0.0", "eslint": "^7.25.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-mocha": "^8.1.0", "eslint-plugin-react": "^7.23.2", "expect.js": "^0.3.1", - "jquery": "^3.6.0", - "karma": "^6.3.2", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "^2.1.0", + "jquery": "^3.7.1", + "karma": "^6.4.4", + "karma-chrome-launcher": "^3.2.0", + "karma-firefox-launcher": "^2.1.3", "karma-html2js-preprocessor": "^1.1.0", "karma-mocha": "~2.0.1", "karma-mocha-reporter": "^2.2.5", "karma-sinon": "^1.0.5", - "karma-sourcemap-loader": "^0.3.8", - "karma-webpack": "^4.0.2", - "mocha": "^8.4.0", - "rimraf": "^3.0.2", - "rollup": "^2.47.0", - "rollup-plugin-size-snapshot": "^0.12.0", - "rollup-plugin-typescript": "^1.0.1", + "karma-sourcemap-loader": "^0.4.0", + "karma-webpack": "^5.0.1", + "mocha": "^11.5.0", + "rimraf": "^6.0.1", "simulant": "^0.2.2", - "sinon": "^9.2.4", - "typescript": "^4.2.4", - "webpack": "^4.46.0" + "sinon": "^20.0.0", + "typescript": "^5.8.3", + "webpack": "^5.99.9" }, "bugs": { "url": "https://github.com/react-bootstrap/dom-helpers/issues" }, "readme": "ERROR: No README data found!", "homepage": "https://github.com/react-bootstrap/dom-helpers#readme", - "_id": "dom-helpers@5.2.0" + "_id": "dom-helpers@5.2.0", + "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 3a59cc1..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,14 +0,0 @@ -import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; -import typescript from 'rollup-plugin-typescript'; - -export default { - input: './src/index.ts', - output: { - file: './lib/dist/dom-helpers.js', - format: 'esm', - }, - plugins: [ - typescript(), - sizeSnapshot(), - ], -} diff --git a/src/activeElement.ts b/src/activeElement.ts index 6a90b1a..9864e78 100644 --- a/src/activeElement.ts +++ b/src/activeElement.ts @@ -1,4 +1,4 @@ -import ownerDocument from './ownerDocument' +import ownerDocument from './ownerDocument.ts'; /** * Returns the actively focused element safely. @@ -9,13 +9,13 @@ export default function activeElement(doc = ownerDocument()) { // Support: IE 9 only // IE9 throws an "Unspecified error" accessing document.activeElement from an