fast-equals 4.0.2 → 5.0.0-beta.0

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.
Files changed (71) hide show
  1. package/.babelrc +34 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGELOG.md +43 -0
  4. package/README.md +146 -40
  5. package/build/rollup/config.base.js +49 -0
  6. package/build/rollup/config.cjs.js +10 -0
  7. package/build/rollup/config.esm.js +10 -0
  8. package/build/rollup/config.min.js +13 -0
  9. package/build/rollup/config.umd.js +10 -0
  10. package/build/tsconfig/base.json +32 -0
  11. package/build/tsconfig/cjs.json +8 -0
  12. package/build/tsconfig/declarations.json +9 -0
  13. package/build/tsconfig/esm.json +8 -0
  14. package/build/tsconfig/min.json +8 -0
  15. package/build/tsconfig/umd.json +8 -0
  16. package/build/webpack.config.js +57 -0
  17. package/dist/cjs/index.cjs +510 -0
  18. package/dist/cjs/index.cjs.map +1 -0
  19. package/dist/cjs/types/comparator.d.ts +2 -0
  20. package/dist/cjs/types/equals.d.ts +46 -0
  21. package/dist/cjs/types/index.d.ts +56 -0
  22. package/dist/cjs/types/internalTypes.d.ts +36 -0
  23. package/dist/cjs/types/utils.d.ts +19 -0
  24. package/dist/esm/index.mjs +499 -0
  25. package/dist/esm/index.mjs.map +1 -0
  26. package/dist/esm/types/comparator.d.ts +2 -0
  27. package/dist/esm/types/equals.d.ts +46 -0
  28. package/dist/esm/types/index.d.ts +56 -0
  29. package/dist/esm/types/internalTypes.d.ts +36 -0
  30. package/dist/esm/types/utils.d.ts +19 -0
  31. package/dist/min/index.js +1 -0
  32. package/dist/min/types/comparator.d.ts +2 -0
  33. package/dist/min/types/equals.d.ts +46 -0
  34. package/dist/min/types/index.d.ts +56 -0
  35. package/dist/min/types/internalTypes.d.ts +36 -0
  36. package/dist/min/types/utils.d.ts +19 -0
  37. package/dist/umd/index.js +516 -0
  38. package/dist/umd/index.js.map +1 -0
  39. package/dist/umd/types/comparator.d.ts +2 -0
  40. package/dist/umd/types/equals.d.ts +46 -0
  41. package/dist/umd/types/index.d.ts +56 -0
  42. package/dist/umd/types/internalTypes.d.ts +36 -0
  43. package/dist/umd/types/utils.d.ts +19 -0
  44. package/package.json +62 -41
  45. package/recipes/explicit-property-check.md +4 -6
  46. package/recipes/legacy-circular-equal-support.md +28 -20
  47. package/recipes/legacy-regexp-support.md +15 -16
  48. package/recipes/non-standard-properties.md +35 -23
  49. package/recipes/using-meta-in-comparison.md +10 -13
  50. package/src/comparator.ts +50 -47
  51. package/src/equals.ts +263 -0
  52. package/src/index.ts +183 -79
  53. package/src/internalTypes.ts +74 -0
  54. package/src/utils.ts +42 -49
  55. package/dist/fast-equals.cjs.js +0 -434
  56. package/dist/fast-equals.cjs.js.map +0 -1
  57. package/dist/fast-equals.esm.js +0 -424
  58. package/dist/fast-equals.esm.js.map +0 -1
  59. package/dist/fast-equals.js +0 -440
  60. package/dist/fast-equals.js.map +0 -1
  61. package/dist/fast-equals.min.js +0 -1
  62. package/dist/fast-equals.mjs +0 -424
  63. package/dist/fast-equals.mjs.map +0 -1
  64. package/index.d.ts +0 -58
  65. package/recipes/strict-property-descriptor-check.md +0 -42
  66. package/src/arrays.ts +0 -36
  67. package/src/dates.ts +0 -12
  68. package/src/maps.ts +0 -66
  69. package/src/objects.ts +0 -62
  70. package/src/regexps.ts +0 -11
  71. 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
@@ -1,4 +1,8 @@
1
1
  {
2
+ "arrowParens": "always",
3
+ "bracketSpacing": true,
4
+ "semi": true,
2
5
  "singleQuote": true,
6
+ "tabWidth": 2,
3
7
  "trailingComma": "all"
4
8
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
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
+
42
+ ## 4.0.3
43
+
44
+ - Remove unnecessary second strict equality check for objects in edge-case scenarios
45
+
3
46
  ## 4.0.2
4
47
 
5
48
  - [#85](https://github.com/planttheidea/fast-equals/issues/85) - `createCustomCircularEqual` typing is incorrect
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
- There are three builds, an ESM build for modern build systems / runtimes, a CommonJS build for traditional NodeJS environments, and a UMD build for legacy implementations. The ideal one will likely be chosen for you automatically, however if you want to use a specific build you can always import it directly:
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/fast-equals.esm.js`
53
- - For older `nodejs` versions that do not allow ESM with file extensions other than `.mjs` => `fast-equals/dist/fast-equals.mjs`
54
- - CommonJS => `fast-equals/dist/fast-equals.cjs.js`
55
- - UMD => `fast-equals/dist/fast-equals.js`
56
- - Minified UMD => `fast-equals/dist/fast-equals.min.js`
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,108 @@ 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 non-enumerable properties in object comparisons
206
+ - Checking full descriptor of properties on the object to match
207
+ - Checking non-index properties on arrays
208
+ - Checking non-key properties on `Map` / `Set` objects
209
+
210
+ ```ts
211
+ function Circular(value) {
212
+ this.me = {
213
+ deeply: {
214
+ nested: {
215
+ reference: this,
216
+ },
217
+ },
218
+ value,
219
+ };
220
+ }
221
+
222
+ const first = new Circular('foo');
223
+
224
+ Object.defineProperty(first, 'bar', {
225
+ enumerable: false,
226
+ value: 'baz',
227
+ });
228
+
229
+ const second = new Circular('foo');
230
+
231
+ Object.defineProperty(second, 'bar', {
232
+ enumerable: false,
233
+ value: 'baz',
234
+ });
235
+
236
+ console.log(circularDeepEqual(first, second)); // true
237
+ console.log(circularDeepEqual(first, new Circular('foo'))); // false
238
+ ```
239
+
240
+ ### strictCircularShallowEqual
241
+
242
+ Performs the same comparison as `circularShallowEqual` but performs a strict comparison of the objects. In this includes:
243
+
244
+ - Checking non-enumerable properties in object comparisons
245
+ - Checking full descriptor of properties on the object to match
246
+ - Checking non-index properties on arrays
247
+ - Checking non-key properties on `Map` / `Set` objects
248
+
249
+ ```ts
250
+ const array = ['foo'];
251
+ const otherArray = ['foo'];
252
+
253
+ array.push(array);
254
+ otherArray.push(otherArray);
255
+
256
+ array.bar = 'baz';
257
+ otherArray.bar = 'baz';
258
+
259
+ console.log(circularShallowEqual(array, otherArray)); // true
260
+ console.log(circularShallowEqual(array, ['foo', array])); // false
261
+ ```
262
+
158
263
  ### createCustomEqual
159
264
 
160
265
  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 +267,21 @@ Creates a custom equality comparator that will be used on nested values in the o
162
267
  The signature is as follows:
163
268
 
164
269
  ```ts
165
- type InternalEqualityComparator = (
166
- a: any,
167
- b: any,
168
- indexOrKeyA: any,
169
- indexOrKeyB: any,
170
- parentA: any,
171
- parentB: any,
172
- meta: any,
173
- ) => boolean;
270
+ interface BaseCircular extends Pick<WeakMap<any, any>, 'delete' | 'get'> {
271
+ set(key: object, value: any): any;
272
+ }
174
273
 
175
- type TypeEqualityComparator = <Type, Meta>(
176
- a: Type,
177
- b: Type,
178
- isEqual: InternalEqualityComparator,
179
- meta: Meta,
274
+ interface DefaultState<Meta> {
275
+ readonly cache: undefined | BaseCircular;
276
+ readonly equals: InternalEqualityComparator<Meta>;
277
+ meta: Meta;
278
+ readonly strict: boolean;
279
+ }
280
+
281
+ type EqualityComparator<Meta> = <A, B>(
282
+ a: A,
283
+ b: B,
284
+ state: State<Meta>,
180
285
  ) => boolean;
181
286
 
182
287
  interface CreateComparatorCreatorOptions<Meta> {
@@ -184,21 +289,31 @@ interface CreateComparatorCreatorOptions<Meta> {
184
289
  areDatesEqual: TypeEqualityComparator<Date, Meta>;
185
290
  areMapsEqual: TypeEqualityComparator<Map<any, any>, Meta>;
186
291
  areObjectsEqual: TypeEqualityComparator<Record<string, any>, Meta>;
292
+ arePrimitiveWrappersEqual: TypeEqualityComparator<
293
+ boolean | string | number,
294
+ Meta
295
+ >;
187
296
  areRegExpsEqual: TypeEqualityComparator<RegExp, Meta>;
188
297
  areSetsEqual: TypeEqualityComparator<Set<any>, Meta>;
189
- createIsNestedEqual?: (
190
- comparator: <A, B>(a: A, b: B, meta: Meta) => boolean,
191
- ) => InternalEqualityComparator;
298
+ }
299
+
300
+ interface CustomEqualCreatorOptions<Meta> {
301
+ circular?: boolean;
302
+ comparator?: EqualityComparator<Meta>;
303
+ createCustomConfig?: CreateCustomComparatorConfig<Meta>;
304
+ createInternalComparator?: <Meta>(
305
+ compare: EqualityComparator<Meta>,
306
+ ) => InternalEqualityComparator<Meta>;
307
+ createState?: CreateState<Meta>;
308
+ strict?: boolean;
192
309
  }
193
310
 
194
311
  function createCustomEqual(
195
- getComparatorOptions: (
196
- defaultOptions: CreateComparatorOptions,
197
- ) => Partial<CreateComparatorOptions>,
198
- ): EqualityComparator;
312
+ options: CustomEqualCreatorOptions<Meta>,
313
+ ): <A, B>(a: A, b: B, metaOverride?: Meta) => boolean;
199
314
  ```
200
315
 
201
- The `meta` parameter above is whatever you want it to be. It will be passed through to all equality checks, and is meant specifically for use with custom equality methods. For example, with the `circularDeepEqual` and `circularShallowEqual` methods, it is used to pass through a cache of processed objects. You also only need to return the override handlers; absent being provided, the defaults are used.
316
+ 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
317
 
203
318
  _**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
319
 
@@ -210,16 +325,7 @@ Some recipes have been created to provide examples of use-cases for `createCusto
210
325
  - [Explicit property check](./recipes/explicit-property-check.md)
211
326
  - [Using `meta` in comparison](./recipes//using-meta-in-comparison.md)
212
327
  - [Comparing non-standard properties](./recipes/non-standard-properties.md)
213
- - [Strict property descriptor comparison](./recipes/strict-equality-checks.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
-
328
+ - [Strict property descriptor comparison](./recipes/strict-property-descriptor-check.md)
223
329
  - [Legacy environment support for circualr equal comparators](./recipes/legacy-circular-equal-support.md)
224
330
 
225
331
  ## 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,10 @@
1
+ import { BASE_CONFIG, PACKAGE_JSON } from './config.base.js';
2
+
3
+ export default {
4
+ ...BASE_CONFIG,
5
+ output: {
6
+ ...BASE_CONFIG.output,
7
+ file: PACKAGE_JSON.main,
8
+ format: 'cjs',
9
+ },
10
+ };
@@ -0,0 +1,10 @@
1
+ import { BASE_CONFIG, PACKAGE_JSON } from './config.base.js';
2
+
3
+ export default {
4
+ ...BASE_CONFIG,
5
+ output: {
6
+ ...BASE_CONFIG.output,
7
+ file: PACKAGE_JSON.module,
8
+ format: 'es',
9
+ },
10
+ };
@@ -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,10 @@
1
+ import { BASE_CONFIG, PACKAGE_JSON } from './config.base.js';
2
+
3
+ export default {
4
+ ...BASE_CONFIG,
5
+ output: {
6
+ ...BASE_CONFIG.output,
7
+ file: PACKAGE_JSON.browser,
8
+ format: 'umd',
9
+ },
10
+ };
@@ -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,8 @@
1
+ {
2
+ "extends": "./declarations.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "../../dist/cjs/types",
5
+ "module": "CommonJS",
6
+ "outDir": "../../dist/cjs"
7
+ }
8
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./base.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "emitDeclarationOnly": true,
6
+ "resolveJsonModule": false
7
+ },
8
+ "include": ["../../src/*"]
9
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./declarations.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "../../dist/esm/types",
5
+ "module": "ESNext",
6
+ "outDir": "../../dist/esm"
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./declarations.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "../../dist/min/types",
5
+ "module": "UMD",
6
+ "outDir": "../../dist/min"
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./declarations.json",
3
+ "compilerOptions": {
4
+ "declarationDir": "../../dist/umd/types",
5
+ "module": "UMD",
6
+ "outDir": "../../dist/umd"
7
+ }
8
+ }
@@ -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
+ };