fix(build): use optional-require dependency#1736
Merged
balazsorban44 merged 2 commits intonextfrom Apr 15, 2021
Merged
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/GLavhMbV1NMZXN74txpwaqAFp3PL |
|
🎉 This PR is included in version 4.0.0-next.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Member
Author
|
DISCLAIMER: Did not seem to work as expected... I will keep exploring ways that will make |
3 tasks
mnphpexpert
added a commit
to mnphpexpert/next-auth
that referenced
this pull request
Sep 2, 2024
* chore(deps): add optional-require * refactor: use optional-require
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
Use
optional-requireto require certain modules optionally.Why:
To my sadness, after trying out #1682 on a local project, I discovered that Next.js Webpack will try to include modules in the dev/prod builds that were added through dynamic imports, **even though they are wrapped in a conditional that is never
true.*. That just seem to be a limitation/behaviour I do not understand fully, to be honest. If someone visits this PR, please enlighten me 💡, or show me to some documentation/reasoning! In the meantime, let's see that using a wrapper for importing helps.I am trying
optional-requireinstead ofrequire_optionalfirst, as the latter looks to be unmaintained (with still a number of downloads/week though), and even themondodbmodule (that we used as an example when implementing optional modules) switched from it, as it introduced a bug in Windows.How:
Switch out the failed dynamic imports to
optionalRequirecalls, and see if solves the problem.Checklist: