Skip to content

Commit e21813b

Browse files
committed
feat!: update deps and add export map
BREAKING CHANGE: Add export map
1 parent b70c63e commit e21813b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2995
-3557
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.babelrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = (api) => {
2+
return {
3+
presets: [
4+
'@react-bootstrap',
5+
[
6+
'@babel/typescript',
7+
{
8+
rewriteImportExtensions: api.env() !== 'development',
9+
},
10+
],
11+
],
12+
};
13+
};

.github/workflows/test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
name: Run Testing Suite
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checking out Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 22.x
23+
24+
- name: Install Dependencies
25+
run: yarn
26+
27+
- name: Run lint
28+
run: yarn lint
29+
30+
- name: Run Tests
31+
run: yarn test
32+
33+
- name: Build Project
34+
run: yarn build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ $RECYCLE.BIN/
6767
*.msi
6868
*.msm
6969
*.msp
70+
71+
esm
72+
cjs

.size-snapshot.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

karma.conf.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict'
1+
'use strict';
22

3-
module.exports = config => {
4-
const { env } = process
3+
module.exports = (config) => {
4+
const { env } = process;
55

66
config.set({
77
basePath: '',
@@ -55,5 +55,5 @@ module.exports = config => {
5555
webpackServer: {
5656
noInfo: true,
5757
},
58-
})
59-
}
58+
});
59+
};

package.json

Lines changed: 57 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,36 @@
1111
"url": "git+https://github.com/react-bootstrap/dom-helpers.git"
1212
},
1313
"license": "MIT",
14-
"main": "lib/cjs/index.js",
15-
"types": "lib/cjs/index.d.ts",
16-
"module": "lib/esm/index.js",
14+
"files": [
15+
"cjs",
16+
"esm"
17+
],
18+
"main": "esm/index.js",
19+
"types": "esm/index.d.ts",
20+
"module": "esm/index.js",
21+
"exports": {
22+
"./package.json": "./package.json",
23+
".": {
24+
"require": {
25+
"types": "./cjs/index.d.ts",
26+
"default": "./cjs/index.js"
27+
},
28+
"import": {
29+
"types": "./esm/index.d.ts",
30+
"default": "./esm/index.js"
31+
}
32+
},
33+
"./*": {
34+
"require": {
35+
"types": "./cjs/*.d.ts",
36+
"default": "./cjs/*.js"
37+
},
38+
"import": {
39+
"types": "./esm/*.d.ts",
40+
"default": "./esm/*.js"
41+
}
42+
}
43+
},
1744
"keywords": [
1845
"dom-helpers",
1946
"react-component",
@@ -32,68 +59,63 @@
3259
"scripts": {
3360
"test": "karma start --single-run",
3461
"tdd": "karma start",
35-
"check:size": "rollup -c",
36-
"build:pick": "cherry-pick --name=dom-helpers --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm",
37-
"build": "rimraf lib && node_modules/.bin/build src && yarn build:pick",
62+
"build": "yarn build:cjs && yarn build:esm",
63+
"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",
64+
"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",
65+
"build:cjs:types": "tsc --emitDeclarationOnly --module commonjs --outDir cjs",
66+
"build:esm:types": "tsc --emitDeclarationOnly --module esnext --outDir esm",
3867
"prepublishOnly": "yarn build",
3968
"lint": "tsc -p ./ --noEmit && eslint src test",
4069
"release": "rollout"
4170
},
42-
"publishConfig": {
43-
"directory": "lib"
44-
},
4571
"release": {
4672
"conventionalCommits": true
4773
},
4874
"dependencies": {
49-
"@babel/runtime": "^7.8.7",
50-
"csstype": "^3.0.2"
75+
"@babel/runtime": "^7.27.1",
76+
"csstype": "^3.1.3"
5177
},
5278
"devDependencies": {
53-
"@4c/build": "^2.3.1",
54-
"@4c/rollout": "^2.2.1",
55-
"@4c/tsconfig": "^0.3.1",
56-
"@babel/cli": "^7.13.16",
57-
"@babel/core": "^7.14.0",
58-
"@babel/preset-typescript": "^7.13.0",
59-
"@react-bootstrap/babel-preset": "^1.2.0",
79+
"@4c/rollout": "^4.0.2",
80+
"@4c/tsconfig": "^0.4.1",
81+
"@babel/cli": "^7.27.2",
82+
"@babel/core": "^7.27.1",
83+
"@babel/preset-typescript": "^7.27.1",
84+
"@react-bootstrap/babel-preset": "^2.3.0",
6085
"@react-bootstrap/eslint-config": "^1.3.2",
6186
"@react-bootstrap/eslint-config-typescript": "^2.0.1",
6287
"@typescript-eslint/eslint-plugin": "^4.22.1",
6388
"@typescript-eslint/parser": "^4.22.1",
6489
"babel-eslint": "^10.1.0",
65-
"babel-loader": "^8.2.2",
66-
"cherry-pick": "^0.5.0",
90+
"babel-loader": "^10.0.0",
6791
"eslint": "^7.25.0",
6892
"eslint-plugin-import": "^2.22.1",
6993
"eslint-plugin-jsx-a11y": "^6.4.1",
7094
"eslint-plugin-mocha": "^8.1.0",
7195
"eslint-plugin-react": "^7.23.2",
7296
"expect.js": "^0.3.1",
73-
"jquery": "^3.6.0",
74-
"karma": "^6.3.2",
75-
"karma-chrome-launcher": "^3.1.0",
76-
"karma-firefox-launcher": "^2.1.0",
97+
"jquery": "^3.7.1",
98+
"karma": "^6.4.4",
99+
"karma-chrome-launcher": "^3.2.0",
100+
"karma-firefox-launcher": "^2.1.3",
77101
"karma-html2js-preprocessor": "^1.1.0",
78102
"karma-mocha": "~2.0.1",
79103
"karma-mocha-reporter": "^2.2.5",
80104
"karma-sinon": "^1.0.5",
81-
"karma-sourcemap-loader": "^0.3.8",
82-
"karma-webpack": "^4.0.2",
83-
"mocha": "^8.4.0",
84-
"rimraf": "^3.0.2",
85-
"rollup": "^2.47.0",
86-
"rollup-plugin-size-snapshot": "^0.12.0",
87-
"rollup-plugin-typescript": "^1.0.1",
105+
"karma-sourcemap-loader": "^0.4.0",
106+
"karma-webpack": "^5.0.1",
107+
"mocha": "^11.5.0",
108+
"rimraf": "^6.0.1",
88109
"simulant": "^0.2.2",
89-
"sinon": "^9.2.4",
90-
"typescript": "^4.2.4",
91-
"webpack": "^4.46.0"
110+
"sinon": "^20.0.0",
111+
"typescript": "^5.8.3",
112+
"webpack": "^5.99.9"
92113
},
93114
"bugs": {
94115
"url": "https://github.com/react-bootstrap/dom-helpers/issues"
95116
},
96117
"readme": "ERROR: No README data found!",
97118
"homepage": "https://github.com/react-bootstrap/dom-helpers#readme",
98-
119+
120+
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
99121
}

rollup.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/activeElement.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ownerDocument from './ownerDocument'
1+
import ownerDocument from './ownerDocument.ts';
22

33
/**
44
* Returns the actively focused element safely.
@@ -9,13 +9,13 @@ export default function activeElement(doc = ownerDocument()) {
99
// Support: IE 9 only
1010
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
1111
try {
12-
const active = doc.activeElement
12+
const active = doc.activeElement;
1313
// IE11 returns a seemingly empty object in some cases when accessing
1414
// document.activeElement from an <iframe>
15-
if (!active || !active.nodeName) return null
16-
return active
15+
if (!active || !active.nodeName) return null;
16+
return active;
1717
} catch (e) {
1818
/* ie throws if no active element */
19-
return doc.body
19+
return doc.body;
2020
}
2121
}

src/addClass.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
import hasClass from './hasClass'
1+
import hasClass from './hasClass.ts';
22

33
/**
44
* Adds a CSS class to a given element.
5-
*
5+
*
66
* @param element the element
77
* @param className the CSS class name
88
*/
9-
export default function addClass(
10-
element: Element | SVGElement,
11-
className: string
12-
) {
13-
if (element.classList) element.classList.add(className)
9+
export default function addClass(element: Element | SVGElement, className: string) {
10+
if (element.classList) element.classList.add(className);
1411
else if (!hasClass(element, className))
1512
if (typeof element.className === 'string')
16-
(element as Element).className = `${element.className} ${className}`
13+
(element as Element).className = `${element.className} ${className}`;
1714
else
1815
element.setAttribute(
1916
'class',
2017
`${(element.className && element.className.baseVal) || ''} ${className}`
21-
)
18+
);
2219
}

src/addEventListener.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/* eslint-disable no-return-assign */
2-
import canUseDOM from './canUseDOM'
2+
import canUseDOM from './canUseDOM.ts';
33

4-
export let optionsSupported = false
5-
export let onceSupported = false
4+
export let optionsSupported = false;
5+
export let onceSupported = false;
66

77
try {
88
const options = {
99
get passive() {
10-
return (optionsSupported = true)
10+
return (optionsSupported = true);
1111
},
1212
get once() {
1313
// eslint-disable-next-line no-multi-assign
14-
return (onceSupported = optionsSupported = true)
14+
return (onceSupported = optionsSupported = true);
1515
},
16-
}
16+
};
1717
if (canUseDOM) {
18-
window.addEventListener('test', options as any, options)
19-
window.removeEventListener('test', options as any, true)
18+
window.addEventListener('test', options as any, options);
19+
window.removeEventListener('test', options as any, true);
2020
}
2121
} catch (e) {
2222
/* */
@@ -25,15 +25,15 @@ try {
2525
export type EventHandler<K extends keyof HTMLElementEventMap> = (
2626
this: HTMLElement,
2727
event: HTMLElementEventMap[K]
28-
) => any
28+
) => any;
2929

30-
export type TaggedEventHandler<
31-
K extends keyof HTMLElementEventMap
32-
> = EventHandler<K> & { __once?: EventHandler<K> }
30+
export type TaggedEventHandler<K extends keyof HTMLElementEventMap> = EventHandler<K> & {
31+
__once?: EventHandler<K>;
32+
};
3333

3434
/**
3535
* An `addEventListener` ponyfill, supports the `once` option
36-
*
36+
*
3737
* @param node the element
3838
* @param eventName the event name
3939
* @param handle the handler
@@ -46,26 +46,22 @@ function addEventListener<K extends keyof HTMLElementEventMap>(
4646
options?: boolean | AddEventListenerOptions
4747
) {
4848
if (options && typeof options !== 'boolean' && !onceSupported) {
49-
const { once, capture } = options
50-
let wrappedHandler = handler
49+
const { once, capture } = options;
50+
let wrappedHandler = handler;
5151
if (!onceSupported && once) {
5252
wrappedHandler =
5353
handler.__once ||
5454
function onceHandler(event) {
55-
this.removeEventListener(eventName, onceHandler, capture)
56-
handler.call(this, event)
57-
}
58-
handler.__once = wrappedHandler
55+
this.removeEventListener(eventName, onceHandler, capture);
56+
handler.call(this, event);
57+
};
58+
handler.__once = wrappedHandler;
5959
}
6060

61-
node.addEventListener(
62-
eventName,
63-
wrappedHandler,
64-
optionsSupported ? options : capture
65-
)
61+
node.addEventListener(eventName, wrappedHandler, optionsSupported ? options : capture);
6662
}
6763

68-
node.addEventListener(eventName, handler, options)
64+
node.addEventListener(eventName, handler, options);
6965
}
7066

71-
export default addEventListener
67+
export default addEventListener;

0 commit comments

Comments
 (0)