-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this so quickly! Agreed, we should get rid of lodash.
We're probably skipping a bit too many CI steps for a change like this... |
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) |
Hmm a consequence of the Browser export is though that more packages now depend on Replay 😅 |
good point! I'll add replay to the browser dependency list 👍 |
To ensure that CI does not re-use dependencies after #6551.
To ensure that CI does not re-use dependencies after #6551.
…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.
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 || self
should be fine for us.Eventually, we should get rid of lodash...!