fast-equals 4.0.3 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +34 -0
- package/.prettierrc +4 -0
- package/CHANGELOG.md +39 -0
- package/README.md +146 -39
- package/build/rollup/config.base.js +49 -0
- package/build/rollup/config.cjs.js +10 -0
- package/build/rollup/config.esm.js +10 -0
- package/build/rollup/config.min.js +13 -0
- package/build/rollup/config.umd.js +10 -0
- package/build/tsconfig/base.json +32 -0
- package/build/tsconfig/cjs.json +8 -0
- package/build/tsconfig/declarations.json +9 -0
- package/build/tsconfig/esm.json +8 -0
- package/build/tsconfig/min.json +8 -0
- package/build/tsconfig/umd.json +8 -0
- package/build/webpack.config.js +57 -0
- package/dist/cjs/index.cjs +510 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/types/comparator.d.ts +2 -0
- package/dist/cjs/types/equals.d.ts +46 -0
- package/dist/cjs/types/index.d.ts +56 -0
- package/dist/cjs/types/internalTypes.d.ts +36 -0
- package/dist/cjs/types/utils.d.ts +19 -0
- package/dist/esm/index.mjs +499 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/types/comparator.d.ts +2 -0
- package/dist/esm/types/equals.d.ts +46 -0
- package/dist/esm/types/index.d.ts +56 -0
- package/dist/esm/types/internalTypes.d.ts +36 -0
- package/dist/esm/types/utils.d.ts +19 -0
- package/dist/min/index.js +1 -0
- package/dist/min/types/comparator.d.ts +2 -0
- package/dist/min/types/equals.d.ts +46 -0
- package/dist/min/types/index.d.ts +56 -0
- package/dist/min/types/internalTypes.d.ts +36 -0
- package/dist/min/types/utils.d.ts +19 -0
- package/dist/umd/index.js +516 -0
- package/dist/umd/index.js.map +1 -0
- package/dist/umd/types/comparator.d.ts +2 -0
- package/dist/umd/types/equals.d.ts +46 -0
- package/dist/umd/types/index.d.ts +56 -0
- package/dist/umd/types/internalTypes.d.ts +36 -0
- package/dist/umd/types/utils.d.ts +19 -0
- package/index.d.ts +62 -55
- package/package.json +59 -38
- package/recipes/explicit-property-check.md +4 -6
- package/recipes/legacy-circular-equal-support.md +28 -20
- package/recipes/legacy-regexp-support.md +15 -16
- package/recipes/non-standard-properties.md +35 -23
- package/recipes/using-meta-in-comparison.md +10 -13
- package/src/comparator.ts +43 -40
- package/src/equals.ts +263 -0
- package/src/index.ts +183 -79
- package/src/internalTypes.ts +74 -0
- package/src/utils.ts +42 -49
- package/dist/fast-equals.cjs.js +0 -432
- package/dist/fast-equals.cjs.js.map +0 -1
- package/dist/fast-equals.esm.js +0 -422
- package/dist/fast-equals.esm.js.map +0 -1
- package/dist/fast-equals.js +0 -438
- package/dist/fast-equals.js.map +0 -1
- package/dist/fast-equals.min.js +0 -1
- package/dist/fast-equals.mjs +0 -422
- package/dist/fast-equals.mjs.map +0 -1
- package/recipes/strict-property-descriptor-check.md +0 -42
- package/src/arrays.ts +0 -36
- package/src/dates.ts +0 -12
- package/src/maps.ts +0 -66
- package/src/objects.ts +0 -62
- package/src/regexps.ts +0 -11
- package/src/sets.ts +0 -61
package/.babelrc
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"lib": {
|
|
4
|
+
"presets": [
|
|
5
|
+
[
|
|
6
|
+
"@babel/preset-env",
|
|
7
|
+
{
|
|
8
|
+
"loose": true
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"test": {
|
|
14
|
+
"presets": [
|
|
15
|
+
[
|
|
16
|
+
"@babel/preset-env",
|
|
17
|
+
{
|
|
18
|
+
"loose": true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"presets": [
|
|
25
|
+
"@babel/preset-typescript",
|
|
26
|
+
[
|
|
27
|
+
"@babel/preset-env",
|
|
28
|
+
{
|
|
29
|
+
"loose": true,
|
|
30
|
+
"modules": false
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
]
|
|
34
|
+
}
|
package/.prettierrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# fast-equals CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
|
|
7
|
+
#### `createCustomEqual` contract has changed
|
|
8
|
+
|
|
9
|
+
To better facilitate strict comparisons, but also to allow for `meta` use separate from caching, the contract for `createCustomEqual` has changed. See the [README documentation](./README.md#createcustomequal) for more details.
|
|
10
|
+
|
|
11
|
+
#### `createCustomCircularEqual` has been removed
|
|
12
|
+
|
|
13
|
+
You can create a custom circular equality comparator through `createCustomEqual` now by providing `circular: true` to the options.
|
|
14
|
+
|
|
15
|
+
#### Deep links have changed
|
|
16
|
+
|
|
17
|
+
If you were deep-linking into a specific asset type (ESM / CJS / UMD), they have changed location.
|
|
18
|
+
|
|
19
|
+
**NOTE**: You may no longer need to deep-link, as [the build resolution has improved](#better-build-system-resolution).
|
|
20
|
+
|
|
21
|
+
### Enhancements
|
|
22
|
+
|
|
23
|
+
#### New "strict" comparators available
|
|
24
|
+
|
|
25
|
+
The following new comparators are available:
|
|
26
|
+
|
|
27
|
+
- `strictDeepEqual`
|
|
28
|
+
- `strictShallowEqual`
|
|
29
|
+
- `strictCircularDeepEqual`
|
|
30
|
+
- `strictCircularShallowEqual`
|
|
31
|
+
|
|
32
|
+
This will perform the same comparisons as their non-strict counterparts, but will verify additional properties (non-enumerable properties on objects, keyed objects on `Array` / `Map` / `Set`) and that the descriptors for the properties align.
|
|
33
|
+
|
|
34
|
+
#### Better build system resolution
|
|
35
|
+
|
|
36
|
+
The library now leverages the `exports` property in the `package.json` to provide builds specific to your method of consumption (ESM / CommonJS / UMD). There is still a minified UMD version available if you want to use it instead.
|
|
37
|
+
|
|
38
|
+
#### `arePrimitiveWrappersEqual` added to `createCustomEqual` configuration
|
|
39
|
+
|
|
40
|
+
If you want a custom comparator for primitive wrappers (`new Boolean()` / `new Number()` / `new String()`) it is now available.
|
|
41
|
+
|
|
3
42
|
## 4.0.3
|
|
4
43
|
|
|
5
44
|
- Remove unnecessary second strict equality check for objects in edge-case scenarios
|
package/README.md
CHANGED
|
@@ -30,10 +30,12 @@ Starting with version `1.5.0`, circular objects are supported for both deep and
|
|
|
30
30
|
- [sameValueZeroEqual](#samevaluezeroequal)
|
|
31
31
|
- [circularDeepEqual](#circulardeepequal)
|
|
32
32
|
- [circularShallowEqual](#circularshallowequal)
|
|
33
|
+
- [strictDeepEqual](#strictdeepequal)
|
|
34
|
+
- [strictShallowEqual](#strictshallowequal)
|
|
35
|
+
- [strictCircularDeepEqual](#strictcirculardeepequal)
|
|
36
|
+
- [strictCircularShallowEqual](#strictcircularshallowequal)
|
|
33
37
|
- [createCustomEqual](#createcustomequal)
|
|
34
38
|
- [Recipes](#recipes)
|
|
35
|
-
- [`createCustomCircularEqual`](#createcustomcircularequal)
|
|
36
|
-
- [Recipes](#recipes-1)
|
|
37
39
|
- [Benchmarks](#benchmarks)
|
|
38
40
|
- [Development](#development)
|
|
39
41
|
|
|
@@ -47,13 +49,14 @@ console.log(deepEqual({ foo: 'bar' }, { foo: 'bar' })); // true
|
|
|
47
49
|
|
|
48
50
|
### Specific builds
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
By default, npm should resolve the correct build of the package based on your consumption (ESM vs CommonJS). However, if you want to force use of a specific build, they can be located here:
|
|
51
53
|
|
|
52
|
-
- ESM => `fast-equals/dist/
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
- UMD => `fast-equals/dist/
|
|
56
|
-
|
|
54
|
+
- ESM => `fast-equals/dist/esm/index.mjs`
|
|
55
|
+
- CommonJS => `fast-equals/dist/cjs/index.cjs`
|
|
56
|
+
- UMD => `fast-equals/dist/umd/index.js`
|
|
57
|
+
- Minified UMD => `fast-equals/dist/min/index.js`
|
|
58
|
+
|
|
59
|
+
If you are having issues loading a specific build type, [please file an issue](https://github.com/planttheidea/fast-equals/issues).
|
|
57
60
|
|
|
58
61
|
## Available methods
|
|
59
62
|
|
|
@@ -155,6 +158,109 @@ console.log(circularShallowEqual(array, ['foo', array])); // true
|
|
|
155
158
|
console.log(circularShallowEqual(array, [array])); // false
|
|
156
159
|
```
|
|
157
160
|
|
|
161
|
+
### strictDeepEqual
|
|
162
|
+
|
|
163
|
+
Performs the same comparison as `deepEqual` but performs a strict comparison of the objects. In this includes:
|
|
164
|
+
|
|
165
|
+
- Checking non-enumerable properties in object comparisons
|
|
166
|
+
- Checking full descriptor of properties on the object to match
|
|
167
|
+
- Checking non-index properties on arrays
|
|
168
|
+
- Checking non-key properties on `Map` / `Set` objects
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const array = [{ foo: 'bar' }];
|
|
172
|
+
const otherArray = [{ foo: 'bar' }];
|
|
173
|
+
|
|
174
|
+
array.bar = 'baz';
|
|
175
|
+
otherArray.bar = 'baz';
|
|
176
|
+
|
|
177
|
+
console.log(strictDeepEqual(array, otherArray)); // true;
|
|
178
|
+
console.log(strictDeepEqual(array, [{ foo: 'bar' }])); // false;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### strictShallowEqual
|
|
182
|
+
|
|
183
|
+
Performs the same comparison as `shallowEqual` but performs a strict comparison of the objects. In this includes:
|
|
184
|
+
|
|
185
|
+
- Checking non-enumerable properties in object comparisons
|
|
186
|
+
- Checking full descriptor of properties on the object to match
|
|
187
|
+
- Checking non-index properties on arrays
|
|
188
|
+
- Checking non-key properties on `Map` / `Set` objects
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
const array = ['foo'];
|
|
192
|
+
const otherArray = ['foo'];
|
|
193
|
+
|
|
194
|
+
array.bar = 'baz';
|
|
195
|
+
otherArray.bar = 'baz';
|
|
196
|
+
|
|
197
|
+
console.log(strictDeepEqual(array, otherArray)); // true;
|
|
198
|
+
console.log(strictDeepEqual(array, ['foo'])); // false;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### strictCircularDeepEqual
|
|
202
|
+
|
|
203
|
+
Performs the same comparison as `circularDeepEqual` but performs a strict comparison of the objects. In this includes:
|
|
204
|
+
|
|
205
|
+
- Checking `Symbol` properties on the object
|
|
206
|
+
- Checking non-enumerable properties in object comparisons
|
|
207
|
+
- Checking full descriptor of properties on the object to match
|
|
208
|
+
- Checking non-index properties on arrays
|
|
209
|
+
- Checking non-key properties on `Map` / `Set` objects
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
function Circular(value) {
|
|
213
|
+
this.me = {
|
|
214
|
+
deeply: {
|
|
215
|
+
nested: {
|
|
216
|
+
reference: this,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
value,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const first = new Circular('foo');
|
|
224
|
+
|
|
225
|
+
Object.defineProperty(first, 'bar', {
|
|
226
|
+
enumerable: false,
|
|
227
|
+
value: 'baz',
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const second = new Circular('foo');
|
|
231
|
+
|
|
232
|
+
Object.defineProperty(second, 'bar', {
|
|
233
|
+
enumerable: false,
|
|
234
|
+
value: 'baz',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
console.log(circularDeepEqual(first, second)); // true
|
|
238
|
+
console.log(circularDeepEqual(first, new Circular('foo'))); // false
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### strictCircularShallowEqual
|
|
242
|
+
|
|
243
|
+
Performs the same comparison as `circularShallowEqual` but performs a strict comparison of the objects. In this includes:
|
|
244
|
+
|
|
245
|
+
- Checking non-enumerable properties in object comparisons
|
|
246
|
+
- Checking full descriptor of properties on the object to match
|
|
247
|
+
- Checking non-index properties on arrays
|
|
248
|
+
- Checking non-key properties on `Map` / `Set` objects
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
const array = ['foo'];
|
|
252
|
+
const otherArray = ['foo'];
|
|
253
|
+
|
|
254
|
+
array.push(array);
|
|
255
|
+
otherArray.push(otherArray);
|
|
256
|
+
|
|
257
|
+
array.bar = 'baz';
|
|
258
|
+
otherArray.bar = 'baz';
|
|
259
|
+
|
|
260
|
+
console.log(circularShallowEqual(array, otherArray)); // true
|
|
261
|
+
console.log(circularShallowEqual(array, ['foo', array])); // false
|
|
262
|
+
```
|
|
263
|
+
|
|
158
264
|
### createCustomEqual
|
|
159
265
|
|
|
160
266
|
Creates a custom equality comparator that will be used on nested values in the object. Unlike `deepEqual` and `shallowEqual`, this is a factory method that receives the default options used internally, and allows you to override the defaults as needed. This is generally for extreme edge-cases, or supporting legacy environments.
|
|
@@ -162,21 +268,21 @@ Creates a custom equality comparator that will be used on nested values in the o
|
|
|
162
268
|
The signature is as follows:
|
|
163
269
|
|
|
164
270
|
```ts
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
indexOrKeyA: any,
|
|
169
|
-
indexOrKeyB: any,
|
|
170
|
-
parentA: any,
|
|
171
|
-
parentB: any,
|
|
172
|
-
meta: any,
|
|
173
|
-
) => boolean;
|
|
271
|
+
interface BaseCircular extends Pick<WeakMap<any, any>, 'delete' | 'get'> {
|
|
272
|
+
set(key: object, value: any): any;
|
|
273
|
+
}
|
|
174
274
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
275
|
+
interface DefaultState<Meta> {
|
|
276
|
+
readonly cache: undefined | BaseCircular;
|
|
277
|
+
readonly equals: InternalEqualityComparator<Meta>;
|
|
278
|
+
meta: Meta;
|
|
279
|
+
readonly strict: boolean;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type EqualityComparator<Meta> = <A, B>(
|
|
283
|
+
a: A,
|
|
284
|
+
b: B,
|
|
285
|
+
state: State<Meta>,
|
|
180
286
|
) => boolean;
|
|
181
287
|
|
|
182
288
|
interface CreateComparatorCreatorOptions<Meta> {
|
|
@@ -184,21 +290,31 @@ interface CreateComparatorCreatorOptions<Meta> {
|
|
|
184
290
|
areDatesEqual: TypeEqualityComparator<Date, Meta>;
|
|
185
291
|
areMapsEqual: TypeEqualityComparator<Map<any, any>, Meta>;
|
|
186
292
|
areObjectsEqual: TypeEqualityComparator<Record<string, any>, Meta>;
|
|
293
|
+
arePrimitiveWrappersEqual: TypeEqualityComparator<
|
|
294
|
+
boolean | string | number,
|
|
295
|
+
Meta
|
|
296
|
+
>;
|
|
187
297
|
areRegExpsEqual: TypeEqualityComparator<RegExp, Meta>;
|
|
188
298
|
areSetsEqual: TypeEqualityComparator<Set<any>, Meta>;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface CustomEqualCreatorOptions<Meta> {
|
|
302
|
+
circular?: boolean;
|
|
303
|
+
comparator?: EqualityComparator<Meta>;
|
|
304
|
+
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
|
|
305
|
+
createInternalComparator?: <Meta>(
|
|
306
|
+
compare: EqualityComparator<Meta>,
|
|
307
|
+
) => InternalEqualityComparator<Meta>;
|
|
308
|
+
createState?: CreateState<Meta>;
|
|
309
|
+
strict?: boolean;
|
|
192
310
|
}
|
|
193
311
|
|
|
194
312
|
function createCustomEqual(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
) => Partial<CreateComparatorOptions>,
|
|
198
|
-
): EqualityComparator;
|
|
313
|
+
options: CustomEqualCreatorOptions<Meta>,
|
|
314
|
+
): <A, B>(a: A, b: B, metaOverride?: Meta) => boolean;
|
|
199
315
|
```
|
|
200
316
|
|
|
201
|
-
|
|
317
|
+
Create a custom equality comparator. This allows complete control over building a bespoke equality method, in case your use-case requires a higher degree of performance, legacy environment support, or any other non-standard usage. The [recipes](#recipes) provide examples of use in different use-cases, but if you have a specific goal in mind and would like assistance feel free to [file an issue](https://github.com/planttheidea/fast-equals/issues).
|
|
202
318
|
|
|
203
319
|
_**NOTE**: `Map` implementations compare equality for both keys and value. When using a custom comparator and comparing equality of the keys, the iteration index is provided as both `indexOrKeyA` and `indexOrKeyB` to help use-cases where ordering of keys matters to equality._
|
|
204
320
|
|
|
@@ -211,15 +327,6 @@ Some recipes have been created to provide examples of use-cases for `createCusto
|
|
|
211
327
|
- [Using `meta` in comparison](./recipes//using-meta-in-comparison.md)
|
|
212
328
|
- [Comparing non-standard properties](./recipes/non-standard-properties.md)
|
|
213
329
|
- [Strict property descriptor comparison](./recipes/strict-property-descriptor-check.md)
|
|
214
|
-
|
|
215
|
-
### `createCustomCircularEqual`
|
|
216
|
-
|
|
217
|
-
Operates nearly identically to [`createCustomEqual`](#createcustomequal), with the difference being that the `meta` property expected by the comparator is expected to have a `WeakMap` contract. This is because it is used for caching accessed objects to avoid maximum stack exceeded errors. The most common use for this method is a simple way to support circular checks for references that do not have `WeakMap` natively.
|
|
218
|
-
|
|
219
|
-
#### Recipes
|
|
220
|
-
|
|
221
|
-
Some recipes have been created to provide examples of use-cases for `createCustomEqual`. Even if not directly applicable to the problem you are solving, they can offer guidance of how to structure your solution.
|
|
222
|
-
|
|
223
330
|
- [Legacy environment support for circualr equal comparators](./recipes/legacy-circular-equal-support.md)
|
|
224
331
|
|
|
225
332
|
## Benchmarks
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
3
|
+
import replace from '@rollup/plugin-replace';
|
|
4
|
+
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import tsc from 'typescript';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const ROOT = fileURLToPath(new URL('../..', import.meta.url));
|
|
11
|
+
|
|
12
|
+
export const PACKAGE_JSON = JSON.parse(
|
|
13
|
+
fs.readFileSync(path.resolve(ROOT, 'package.json')),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const external = [
|
|
17
|
+
...Object.keys(PACKAGE_JSON.dependencies || {}),
|
|
18
|
+
...Object.keys(PACKAGE_JSON.peerDependencies || {}),
|
|
19
|
+
];
|
|
20
|
+
const globals = external.reduce((globals, name) => {
|
|
21
|
+
globals[name] = name;
|
|
22
|
+
|
|
23
|
+
return globals;
|
|
24
|
+
}, {});
|
|
25
|
+
|
|
26
|
+
export const BASE_CONFIG = {
|
|
27
|
+
external,
|
|
28
|
+
input: path.resolve(ROOT, 'src', 'index.ts'),
|
|
29
|
+
output: {
|
|
30
|
+
exports: 'named',
|
|
31
|
+
globals,
|
|
32
|
+
name: 'fast-equals',
|
|
33
|
+
sourcemap: true,
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
replace({
|
|
37
|
+
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
38
|
+
preventAssignment: true,
|
|
39
|
+
}),
|
|
40
|
+
nodeResolve({
|
|
41
|
+
mainFields: ['module', 'browser', 'main'],
|
|
42
|
+
}),
|
|
43
|
+
commonjs({ include: /use-sync-external-store/ }),
|
|
44
|
+
typescript({
|
|
45
|
+
tsconfig: path.resolve(ROOT, 'build', 'tsconfig', 'base.json'),
|
|
46
|
+
typescript: tsc,
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BASE_CONFIG, PACKAGE_JSON } from './config.base.js';
|
|
2
|
+
import terser from '@rollup/plugin-terser';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...BASE_CONFIG,
|
|
6
|
+
output: {
|
|
7
|
+
...BASE_CONFIG.output,
|
|
8
|
+
file: PACKAGE_JSON.browser.replace('umd', 'min'),
|
|
9
|
+
format: 'umd',
|
|
10
|
+
sourcemap: false,
|
|
11
|
+
},
|
|
12
|
+
plugins: [...BASE_CONFIG.plugins, terser()],
|
|
13
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowUnreachableCode": false,
|
|
5
|
+
"baseUrl": "../../src",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"lib": ["DOM", "ESNext"],
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"moduleResolution": "Node",
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"noImplicitAny": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noImplicitThis": true,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"outDir": "../../../dist",
|
|
19
|
+
"resolveJsonModule": true,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"strict": true,
|
|
23
|
+
"strictBindCallApply": true,
|
|
24
|
+
"strictNullChecks": true,
|
|
25
|
+
"inlineSources": true,
|
|
26
|
+
"target": "es5",
|
|
27
|
+
"types": ["jest", "node", "react"]
|
|
28
|
+
},
|
|
29
|
+
"exclude": ["../../node_modules"],
|
|
30
|
+
"include": ["../../src/**/*", "../../__tests__/**/*", "../../DEV_ONLY/**/*"],
|
|
31
|
+
"files": ["../../node_modules/jest-expect-message/types/index.d.ts"]
|
|
32
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
|
|
3
|
+
import ESLintWebpackPlugin from 'eslint-webpack-plugin';
|
|
4
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import webpack from 'webpack';
|
|
8
|
+
|
|
9
|
+
const ROOT = fileURLToPath(new URL('..', import.meta.url));
|
|
10
|
+
const PORT = 3000;
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
cache: true,
|
|
14
|
+
|
|
15
|
+
devServer: {
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
port: PORT,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
devtool: 'source-map',
|
|
21
|
+
|
|
22
|
+
entry: [path.resolve(ROOT, 'DEV_ONLY', 'index.tsx')],
|
|
23
|
+
|
|
24
|
+
mode: 'development',
|
|
25
|
+
|
|
26
|
+
module: {
|
|
27
|
+
rules: [
|
|
28
|
+
{
|
|
29
|
+
include: [path.resolve(ROOT, 'src'), path.resolve(ROOT, 'DEV_ONLY')],
|
|
30
|
+
loader: 'ts-loader',
|
|
31
|
+
options: {
|
|
32
|
+
reportFiles: ['src/*.{ts|tsx}'],
|
|
33
|
+
},
|
|
34
|
+
test: /\.(ts|tsx)$/,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
output: {
|
|
40
|
+
filename: 'fast-equals.js',
|
|
41
|
+
library: 'fastEquals',
|
|
42
|
+
libraryTarget: 'umd',
|
|
43
|
+
path: path.resolve(ROOT, 'dist'),
|
|
44
|
+
publicPath: `http://localhost:${PORT}/`,
|
|
45
|
+
umdNamedDefine: true,
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
plugins: [
|
|
49
|
+
new ESLintWebpackPlugin(),
|
|
50
|
+
new webpack.EnvironmentPlugin(['NODE_ENV']),
|
|
51
|
+
new HtmlWebpackPlugin(),
|
|
52
|
+
],
|
|
53
|
+
|
|
54
|
+
resolve: {
|
|
55
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
56
|
+
},
|
|
57
|
+
};
|