Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 20df684

Browse files
authoredJan 6, 2025··
Update build, export real ESM (#100)
* build: switch to exports * upgrade stuff and fix tests * esm * tests * Update package.json * fixup * Delete build.mjs
1 parent a9613ec commit 20df684

File tree

72 files changed

+1745
-2191
lines changed

Some content is hidden

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

72 files changed

+1745
-2191
lines changed
 

‎.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lib/
2-
esm/
2+
cjs/
33

44
# Logs
55
logs

‎package.json

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
{
22
"name": "@restart/hooks",
33
"version": "0.5.1",
4-
"main": "lib/cjs/index.js",
5-
"types": "lib/cjs/index.d.ts",
6-
"module": "lib/esm/index.js",
4+
"type": "module",
75
"exports": {
8-
".": {
9-
"types": "./esm/index.d.ts",
10-
"import": "./esm/index.js",
11-
"require": "./cjs/index.js"
12-
},
136
"./*": {
14-
"types": "./esm/*.d.ts",
15-
"import": "./esm/*.js",
16-
"require": "./cjs/*.js"
7+
"require": {
8+
"types": "./cjs/index.d.ts",
9+
"default": "./cjs/index.js"
10+
},
11+
"import": {
12+
"types": "./lib/index.d.ts",
13+
"default": "./lib/index.js"
14+
}
1715
}
1816
},
17+
"files": [
18+
"cjs",
19+
"lib",
20+
"CHANGELOG.md"
21+
],
1922
"repository": {
2023
"type": "git",
21-
"url": "git+https://github.com/jquense/react-common-hooks.git"
24+
"url": "git+https://github.com/react-restart/hooks.git"
2225
},
2326
"author": {
2427
"name": "Jason Quense",
@@ -31,12 +34,16 @@
3134
"homepage": "https://github.com/react-restart/hooks#readme",
3235
"scripts": {
3336
"bootstrap": "yarn && yarn --cwd www",
34-
"test": "jest --coverage",
35-
"tdd": "jest --watch",
36-
"build:pick": "cherry-pick --name=@restart/hooks --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm",
37-
"build": "rimraf lib && 4c build src && yarn build:pick",
37+
"test": "vitest run --coverage",
38+
"tdd": "vitest",
39+
"build": "rimraf lib cjs && concurrently --names 'esm,cjs' 'yarn build:esm' 'yarn build:cjs' && concurrently --names 'esm types,cjs types' 'yarn build:esm:types' 'yarn build:cjs:types'",
40+
"build:esm": "babel src --env-name esm --out-dir lib --extensions '.ts' --ignore='**/*.d.ts'",
41+
"build:esm:types": "tsc -p . --emitDeclarationOnly --declaration --outDir lib",
42+
"build:cjs": "babel src --out-dir cjs --extensions '.ts' --ignore='**/*.d.ts' && echo '{\"type\": \"commonjs\"}' > cjs/package.json",
43+
"build:cjs:types": "tsc -p . --emitDeclarationOnly --declaration --outDir cjs --module commonjs --moduleResolution node",
3844
"deploy-docs": "yarn --cwd www build --prefix-paths && gh-pages -d www/public",
3945
"prepublishOnly": "yarn build",
46+
"typecheck": "tsc -p . --noEmit",
4047
"release": "rollout"
4148
},
4249
"jest": {
@@ -52,8 +59,7 @@
5259
"trailingComma": "all"
5360
},
5461
"publishConfig": {
55-
"access": "public",
56-
"directory": "lib"
62+
"access": "public"
5763
},
5864
"release": {
5965
"conventionalCommits": true
@@ -64,33 +70,32 @@
6470
"devDependencies": {
6571
"@4c/babel-preset": "^10.2.1",
6672
"@4c/cli": "^4.0.4",
67-
"@4c/jest-preset": "^1.8.1",
6873
"@4c/rollout": "^4.0.2",
6974
"@4c/tsconfig": "^0.4.1",
70-
"@babel/cli": "^7.22.9",
71-
"@babel/core": "^7.22.9",
72-
"@babel/preset-typescript": "^7.22.5",
73-
"@testing-library/react": "^12.1.5",
74-
"@testing-library/react-hooks": "^7.0.0",
75-
"@types/jest": "^29.5.3",
75+
"@babel/cli": "^7.26.4",
76+
"@babel/core": "^7.26.0",
77+
"@babel/preset-typescript": "^7.26.0",
78+
"@testing-library/dom": "^10.4.0",
79+
"@testing-library/react": "^16.1.0",
7680
"@types/lodash": "^4.14.195",
77-
"@types/react": "^18.2.15",
78-
"babel-jest": "^29.6.1",
81+
"@types/react": "^19.0.2",
82+
"@vitest/coverage-v8": "2.1.8",
7983
"babel-plugin-transform-rename-import": "^2.3.0",
8084
"cherry-pick": "^0.5.0",
8185
"codecov": "^3.8.3",
86+
"concurrently": "^9.1.2",
8287
"eslint": "^8.44.0",
8388
"gh-pages": "^3.1.0",
8489
"husky": "^4.3.6",
85-
"jest": "^29.6.1",
86-
"jest-environment-jsdom": "^29.6.1",
90+
"jsdom": "^25.0.1",
8791
"lint-staged": "^13.2.3",
8892
"mq-polyfill": "^1.1.8",
8993
"prettier": "^3.0.0",
90-
"react": "^16.13.0",
91-
"react-dom": "^16.13.0",
94+
"react": "^19.0.0",
95+
"react-dom": "^19.0.0",
9296
"rimraf": "^5.0.1",
93-
"typescript": "^5.1.6"
97+
"typescript": "^5.1.6",
98+
"vitest": "^2.1.8"
9499
},
95100
"dependencies": {
96101
"dequal": "^2.0.3"

0 commit comments

Comments
 (0)
Please sign in to comment.