react-instantsearch icon indicating copy to clipboard operation
react-instantsearch copied to clipboard

instantsearch-hooks-server: use literal imports

Open danielbeardsley opened this issue 2 years ago • 6 comments

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.

danielbeardsley avatar Sep 09 '22 21:09 danielbeardsley

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

codesandbox-ci[bot] avatar Sep 09 '22 21:09 codesandbox-ci[bot]

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.

netlify[bot] avatar Sep 09 '22 21:09 netlify[bot]

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 avatar Sep 12 '22 07:09 Haroenv

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

Haroenv avatar Sep 14 '22 08:09 Haroenv

Maybe my pullrequest will work:

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

DB-Alex avatar Sep 15 '22 16:09 DB-Alex

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

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

danielbeardsley avatar Sep 15 '22 17:09 danielbeardsley