algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

instantsearch-hooks-server: use literal imports #3618

Closed danielbeardsley closed 1 year ago

danielbeardsley commented 1 year ago

Next.js build process (using pnpm) ends up not seeing these import statements cause the import statements didn't have string literals.

The result was that it didn't put these dependencies in the nested node_modules directory and thus this whole package breaks. Notably this only fails in the production build and not the dev build. See reported bug at next.js.

This change is functionally equivalent, we're just reformatting the code so the literal import statements can be found by whatever tool Next.js is using.

codesandbox-ci[bot] commented 1 year ago

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 b181c45f88783f78809db2720c93a38dbe318d22:

Sandbox Source
react-instantsearch-app Configuration
hooks-example Configuration
netlify[bot] commented 1 year ago

Deploy Preview for react-instantsearch ready!

Name Link
Latest commit b181c45f88783f78809db2720c93a38dbe318d22
Latest deploy log https://app.netlify.com/sites/react-instantsearch/deploys/631baf5b0e69a000075bbc3c
Deploy Preview https://deploy-preview-3618--react-instantsearch.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Haroenv commented 1 year ago

Argh, it's annoying that this code breaks again, as you can see in the linked issue https://github.com/webpack/webpack/issues/13865. We'll need to investigate this deeply to find the right solution, or possibly make the import user-injected (dependency injection) so it can't have any of these issues.

More specifically it's changed from import statements to expressions in https://github.com/algolia/react-instantsearch/pull/3515

Haroenv commented 1 year ago

@danielbeardsley, for a workaround you can use patch-package for now I think, is there a way we can reproduce this outside of Vercel?

DB-Alex commented 1 year ago

Maybe my pullrequest will work:

https://github.com/algolia/react-instantsearch/pull/3626

danielbeardsley commented 1 year ago

for a workaround you can use patch-package for now I think,

Yeah, we started using pnpm patch and it seems to be working.