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.
Files changed (71) hide show
  1. package/.babelrc +34 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +146 -39
  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/index.d.ts +62 -55
  45. package/package.json +59 -38
  46. package/recipes/explicit-property-check.md +4 -6
  47. package/recipes/legacy-circular-equal-support.md +28 -20
  48. package/recipes/legacy-regexp-support.md +15 -16
  49. package/recipes/non-standard-properties.md +35 -23
  50. package/recipes/using-meta-in-comparison.md +10 -13
  51. package/src/comparator.ts +43 -40
  52. package/src/equals.ts +263 -0
  53. package/src/index.ts +183 -79
  54. package/src/internalTypes.ts +74 -0
  55. package/src/utils.ts +42 -49
  56. package/dist/fast-equals.cjs.js +0 -432
  57. package/dist/fast-equals.cjs.js.map +0 -1
  58. package/dist/fast-equals.esm.js +0 -422
  59. package/dist/fast-equals.esm.js.map +0 -1
  60. package/dist/fast-equals.js +0 -438
  61. package/dist/fast-equals.js.map +0 -1
  62. package/dist/fast-equals.min.js +0 -1
  63. package/dist/fast-equals.mjs +0 -422
  64. package/dist/fast-equals.mjs.map +0 -1
  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,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
- 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,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
- 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;
271
+ interface BaseCircular extends Pick<WeakMap<any, any>, 'delete' | 'get'> {
272
+ set(key: object, value: any): any;
273
+ }
174
274
 
175
- type TypeEqualityComparator = <Type, Meta>(
176
- a: Type,
177
- b: Type,
178
- isEqual: InternalEqualityComparator,
179
- meta: Meta,
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
- createIsNestedEqual?: (
190
- comparator: <A, B>(a: A, b: B, meta: Meta) => boolean,
191
- ) => InternalEqualityComparator;
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
- getComparatorOptions: (
196
- defaultOptions: CreateComparatorOptions,
197
- ) => Partial<CreateComparatorOptions>,
198
- ): EqualityComparator;
313
+ options: CustomEqualCreatorOptions<Meta>,
314
+ ): <A, B>(a: A, b: B, metaOverride?: Meta) => boolean;
199
315
  ```
200
316
 
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.
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,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
+ };