Skip to content

Commit 3059179

Browse files
authored
Module-first setup (#68)
* module-first steup * format * run apidoc * update CHANGELOG
1 parent 9f75cbb commit 3059179

21 files changed

+2739
-5766
lines changed

.codesandbox/ci.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"buildCommand": "compile",
3-
"sandboxes": ["vanilla", "vanilla-typescript-vanilla-ts", "new", "react-typescript-react-ts"],
3+
"sandboxes": [
4+
"vanilla",
5+
"vanilla-typescript-vanilla-ts",
6+
"new",
7+
"react-typescript-react-ts"
8+
],
49
"node": "18"
510
}

.eslintrc.cjs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-env node */
2+
module.exports = {
3+
root: true,
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:import/recommended',
10+
'plugin:import/typescript',
11+
'prettier',
12+
],
13+
ignorePatterns: ['dist/'],
14+
settings: {
15+
'import/resolver': {
16+
typescript: true,
17+
},
18+
},
19+
rules: {
20+
'import/no-unresolved': ['error', { ignore: ['proxy-compare'] }],
21+
'@typescript-eslint/no-unused-vars': [
22+
'error',
23+
{
24+
args: 'all',
25+
argsIgnorePattern: '^_',
26+
caughtErrors: 'all',
27+
caughtErrorsIgnorePattern: '^_',
28+
destructuredArrayIgnorePattern: '^_',
29+
varsIgnorePattern: '^_',
30+
ignoreRestSiblings: true,
31+
},
32+
],
33+
},
34+
};

.eslintrc.json

-47
This file was deleted.

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/pnpm-lock.yaml
2+
/dist
3+
/README.md

CHANGELOG.md

+58
Original file line numberDiff line numberDiff line change
@@ -2,103 +2,161 @@
22

33
## [Unreleased]
44

5+
### Changed
6+
7+
- Module-first setup #68
8+
9+
### Removed
10+
11+
- Drop UMD support
12+
513
## [2.6.0] - 2024-01-15
14+
615
### Added
16+
717
- feat: custom equality function #67
818

919
## [2.5.1] - 2023-05-04
20+
1021
### Changed
22+
1123
- fix: reuse target cache for inner createProxy runs #59
1224

1325
## [2.5.0] - 2023-02-14
26+
1427
### Added
28+
1529
- feat: optional target cache for performance #56
1630

1731
## [2.4.2] - 2023-02-13
32+
1833
### Changed
34+
1935
- fix: Don't unfreeze/copy targets w/object getters. #54
2036

2137
## [2.4.1] - 2023-02-07
38+
2239
### Changed
40+
2341
- fix: remove unfrozen cache #53
2442

2543
## [2.4.0] - 2023-01-04
44+
2645
### Added
46+
2747
- feat: better support of Object.hasOwn and "in" #47
2848
- feat: add an option to exclude object getters in affectedToPathList util #48
2949

3050
## [2.3.0] - 2022-08-13
51+
3152
### Added
53+
3254
- feat: support proxy-polyfill #41
55+
3356
### Changed
57+
3458
- fix: cache unfreeze results #44
3559

3660
## [2.2.0] - 2022-06-14
61+
3762
### Added
63+
3864
- Support nested proxy #38
3965

4066
## [2.1.0] - 2022-03-16
67+
4168
### Added
69+
4270
- Support getOwnPropertyDescriptor handler #34
4371

4472
## [2.0.3] - 2022-02-28
73+
4574
### Changed
75+
4676
- Fix affectedToPathList to avoid maximum call stack size exceeded error (#32)
4777

4878
## [2.0.2] - 2021-08-13
79+
4980
### Changed
81+
5082
- Fix package.json properly for ESM (#24)
5183

5284
## [2.0.1] - 2021-06-29
85+
5386
### Changed
87+
5488
- Fix package.json for React Native (#21)
5589

5690
## [2.0.0] - 2021-05-15
91+
5792
### Changed
93+
5894
- Drop mode in isDeepChanged [BREAKING CHANGE] (#18)
5995
- Rename exported functions [BREAKING CHANGE] (#19)
6096

6197
## [1.1.6] - 2021-01-21
98+
6299
### Changed
100+
63101
- Fix object frozen afterwards (#9)
64102
- Some refactors
65103

66104
## [1.1.5] - 2021-01-20
105+
67106
### Changed
107+
68108
- Fix read-only and non-configurable error (#8)
69109

70110
## [1.1.4] - 2021-01-14
111+
71112
### Changed
113+
72114
- The markToTrack util takes optional second argument
73115

74116
## [1.1.3] - 2020-11-24
117+
75118
### Added
119+
76120
- New markToTrack util
77121

78122
## [1.1.2] - 2020-11-21
123+
79124
### Changed
125+
80126
- Improve copying frozen objects
81127

82128
## [1.1.1] - 2020-11-20
129+
83130
### Changed
131+
84132
- Avoid mutating frozen objects
85133

86134
## [1.1.0] - 2020-11-18
135+
87136
### Changed
137+
88138
- Fix `MODE_IGNORE_REF_EQUALITY` behavior
89139

90140
## [1.0.3] - 2020-11-01
141+
91142
### Added
143+
92144
- affectedToPathList util
93145

94146
## [1.0.2] - 2020-07-02
147+
95148
### Changed
149+
96150
- Modern build
97151

98152
## [1.0.1] - 2020-03-09
153+
99154
### Changed
155+
100156
- Improve types
101157

102158
## [1.0.0] - 2020-03-08
159+
103160
### Added
161+
104162
- Initial release

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ for this purpose you can use the `affectedToPathList` helper.
6464
* `obj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object that will be wrapped on the proxy.
6565
* `affected` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>** WeakMap that will hold the tracking of which properties in the proxied object were accessed.
6666
* `proxyCache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>?** WeakMap that will help keep referential identity for proxies.
67+
* `targetCache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), any>?**&#x20;
6768

6869
#### Examples
6970

@@ -102,6 +103,7 @@ on the proxy, then isChanged will only compare the affected properties.
102103
* `affected` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>** WeakMap that holds the tracking of which properties in the proxied object were accessed.
103104
* `cache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>?** WeakMap that holds a cache of the comparisons for better performance with repetitive comparisons,
104105
and to avoid infinite loop with circular structures.
106+
* `isEqual` **function (a: any, b: any): [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** (optional, default `Object.is`)
105107

106108
#### Examples
107109

package.json

+36-30
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,44 @@
22
"name": "proxy-compare",
33
"description": "Compare two objects using accessed properties with Proxy",
44
"version": "2.6.0",
5+
"type": "module",
56
"author": "Daishi Kato",
67
"repository": {
78
"type": "git",
89
"url": "https://github.com/dai-shi/proxy-compare.git"
910
},
1011
"source": "./src/index.ts",
11-
"main": "./dist/index.umd.js",
12-
"module": "./dist/index.modern.js",
13-
"react-native": "./dist/index.modern.js",
14-
"types": "./dist/src/index.d.ts",
12+
"main": "./dist/index.js",
13+
"types": "./dist/index.d.ts",
1514
"exports": {
1615
"./package.json": "./package.json",
1716
".": {
18-
"types": "./dist/src/index.d.ts",
19-
"module": "./dist/index.modern.js",
20-
"import": "./dist/index.modern.mjs",
21-
"default": "./dist/index.umd.js"
17+
"require": {
18+
"types": "./dist/cjs/index.d.ts",
19+
"default": "./dist/cjs/index.js"
20+
},
21+
"default": {
22+
"types": "./dist/index.d.ts",
23+
"default": "./dist/index.js"
24+
}
2225
}
2326
},
2427
"sideEffects": false,
2528
"files": [
2629
"src",
2730
"dist"
2831
],
32+
"packageManager": "[email protected]",
2933
"scripts": {
30-
"compile": "microbundle build -f modern,umd",
31-
"postcompile": "cp dist/index.modern.mjs dist/index.modern.js && cp dist/index.modern.mjs.map dist/index.modern.js.map",
32-
"test": "run-s eslint tsc-test jest",
33-
"eslint": "eslint --ext .js,.ts --ignore-pattern dist .",
34-
"jest": "jest",
35-
"tsc-test": "tsc --project . --noEmit",
36-
"apidoc": "documentation readme src --section API --markdown-toc false --parse-extension ts"
37-
},
38-
"jest": {
39-
"preset": "ts-jest/presets/js-with-ts"
34+
"compile": "rm -rf dist && pnpm run '/^compile:.*/'",
35+
"compile:esm": "tsc -p tsconfig.esm.json",
36+
"compile:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
37+
"test": "pnpm run '/^test:.*/'",
38+
"test:format": "prettier -c .",
39+
"test:lint": "eslint .",
40+
"test:types": "tsc -p . --noEmit",
41+
"test:spec": "vitest run",
42+
"apidoc": "documentation readme src/index.ts --section API --markdown-toc false --parse-extension ts --require-extension ts"
4043
},
4144
"keywords": [
4245
"proxy",
@@ -46,19 +49,22 @@
4649
"deepequal"
4750
],
4851
"license": "MIT",
49-
"dependencies": {},
52+
"prettier": {
53+
"singleQuote": true
54+
},
5055
"devDependencies": {
51-
"@types/jest": "^29.5.11",
52-
"@typescript-eslint/eslint-plugin": "^6.18.1",
53-
"@typescript-eslint/parser": "^6.18.1",
54-
"documentation": "^14.0.2",
55-
"eslint": "^8.56.0",
56-
"eslint-config-airbnb-base": "^15.0.0",
56+
"@types/node": "^20.12.7",
57+
"@typescript-eslint/eslint-plugin": "^7.7.1",
58+
"@typescript-eslint/parser": "^7.7.1",
59+
"documentation": "^14.0.3",
60+
"eslint": "^8.57.0",
61+
"eslint-config-prettier": "^9.1.0",
62+
"eslint-import-resolver-typescript": "^3.6.1",
5763
"eslint-plugin-import": "^2.29.1",
58-
"jest": "^29.7.0",
59-
"microbundle": "^0.15.1",
60-
"npm-run-all": "^4.1.5",
61-
"ts-jest": "^29.1.1",
62-
"typescript": "^5.3.3"
64+
"prettier": "^3.2.5",
65+
"ts-expect": "^1.3.0",
66+
"typescript": "^5.4.5",
67+
"vite": "^5.2.10",
68+
"vitest": "^1.5.2"
6369
}
6470
}

0 commit comments

Comments
 (0)