Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with fast-deep-equal when used with Vite #18

Closed
wants to merge 1 commit into from

Conversation

valtism
Copy link

@valtism valtism commented Jan 11, 2022

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

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
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 659de4c:

Sandbox Source
gilbarbara/tree-changes Configuration

@valtism
Copy link
Author

valtism commented Jan 11, 2022

I'm not entirely sure of the implications of importing the way I did, or of enabling esModuleInterop, but this does seem to work for both create-react-app as well as Vite in the debug repo: https://github.com/maltsev/react-joyride-debug

@gilbarbara
Copy link
Owner

@valtism In my experience turning on esModuleInterop in a library forces the hosting app/library to have the same configuration which is not a desirable option.

@valtism
Copy link
Author

valtism commented Jan 11, 2022

@gilbarbara Ah, I wasn't aware of that and that does sound pretty undesirable. I guess that means that this issue is blocked by epoberezkin/fast-deep-equal#105

@valtism
Copy link
Author

valtism commented Jan 11, 2022

Is there any way around this without fast-deep-equal exporting esm module builds?

@JimmyRowland
Copy link

Also need a walk around

@valtism
Copy link
Author

valtism commented Jan 25, 2022

@JimmyRowland Here's a workaround: gilbarbara/react-joyride#769 (comment)

@JimmyRowland
Copy link

@valtism Thanks. The walk around seems to work. I am using react-floater and after fixing fast-deep-equal/deepmerge import, react-floater still doesn't show custom body component. I will have to give up

@gilbarbara
Copy link
Owner

Fixed in 0.9.0

@gilbarbara gilbarbara closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants