Skip to content

Commit

Permalink
Fix issue with fast-deep-equal when used with Vite
Browse files Browse the repository at this point in the history
When running this library from Vite, because it is ESM-only it will throw when trying to call `equal` from the `fast-deep-equal` library.

I believe this has to do with how it is imported, so we change the `import * as equal from...` to `import equal from...` and allow `esModuleInterop` in the `.tsconfig`

The output of this now works in a vite environment, and solves issue:
gilbarbara/react-joyride#769
  • Loading branch information
valtism committed Jan 11, 2022
1 parent 317dd4a commit 659de4c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/tree-changes-hook/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef } from 'react';
import * as equal from 'fast-deep-equal';
import equal from 'fast-deep-equal';
import treeChanges, { Data, KeyType, TreeChanges } from 'tree-changes';

export default function useTreeChanges<T extends Data>(value: T) {
Expand Down
3 changes: 2 additions & 1 deletion packages/tree-changes-hook/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@gilbarbara/tsconfig",
"compilerOptions": {
"outDir": "./lib",
"target": "es5"
"target": "es5",
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
Expand Down
2 changes: 1 addition & 1 deletion packages/tree-changes/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as equal from 'fast-deep-equal';
import equal from 'fast-deep-equal';
import is from 'is-lite';

import { CompareValuesOptions, Data, Key, Options, ValidTypes, Value } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/tree-changes/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as equal from 'fast-deep-equal';
import equal from 'fast-deep-equal';
import is from 'is-lite';

import { compareNumbers, compareValues, getIterables, includesOrEqualsTo, nested } from './helpers';
Expand Down
3 changes: 2 additions & 1 deletion packages/tree-changes/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@gilbarbara/tsconfig",
"compilerOptions": {
"outDir": "./lib",
"target": "es5"
"target": "es5",
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
Expand Down

0 comments on commit 659de4c

Please sign in to comment.