fix(replay): Ensure lodash.debounce does not trigger next.js warning#6551
Merged
fix(replay): Ensure lodash.debounce does not trigger next.js warning#6551
Conversation
lodash.debounce uses `Function('')`, which nextjs interprets as unsafe, and does not work there.
See: lodash/lodash#5394
We don't really need that fallback anyhow, `global || self` should be fine for us.
Lms24
approved these changes
Dec 15, 2022
Member
Lms24
left a comment
There was a problem hiding this comment.
Thanks for taking care of this so quickly! Agreed, we should get rid of lodash.
Contributor
|
We're probably skipping a bit too many CI steps for a change like this... |
Member
Author
Well, on packages that do not depend on replay (thus aren't using this), this can't really have an impact, so 🤷♂️ (from a CI perspective) |
Member
|
Hmm a consequence of the Browser export is though that more packages now depend on Replay 😅 |
Member
Author
|
good point! I'll add replay to the browser dependency list 👍 |
mydea
added a commit
that referenced
this pull request
Dec 16, 2022
To ensure that CI does not re-use dependencies after #6551.
mydea
added a commit
that referenced
this pull request
Dec 16, 2022
To ensure that CI does not re-use dependencies after #6551.
Lms24
added a commit
that referenced
this pull request
Jan 4, 2023
…ation (#6593) Replace lodash's `debounce` function with a custom, minimal implementation that - Delays the function invocation by a `wait` time and gate it with a `maxWait` value - Provides the return value of the invocation for subsequent debounced function calls - Provides a `flush` and `cancel` function on the debounced function (analogously to lodash). - Invokes the function _after_ the wait/maxwait time triggered (i.e. on the trailing edge). Lodash allows to choose between the leading and trailing edge, which makes the implementation much more complicated than for us necessary - Works for functions _without_ parameters. By not supporting args, we can further cut down bundle size. (We might want to revisit this in the future but for now, this should do). With this change, we can also get rid of the package patch we introduced in #6551 and of the `commonjs()` plugin in our build process.
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.
lodash.debounce uses
Function(''), which nextjs interprets as unsafe, and does not work there. See: lodash/lodash#5394We don't really need that fallback anyhow,
global || selfshould be fine for us.Eventually, we should get rid of lodash...!