-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat(utilities): Remove lodash dependency and replace it with custom functions #856
Conversation
Size stats
|
Deploy preview for mistica-web ready! ✅ Preview Built with commit 18406da. |
Accessibility report ℹ️ You can run this locally by executing |
@@ -121,6 +121,7 @@ | |||
"jest-environment-puppeteer": "^6.1.1", | |||
"jimp": "^0.16.1", | |||
"lint-staged": "^12.3.7", | |||
"lodash": "^4.17.21", |
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.
moved to devDependencies
src/utils/lodash.tsx
Outdated
} | ||
debounceTimeoutId = undefined; | ||
maxWaitTimeoutId = undefined; | ||
// eslint-disable-next-line testing-library/await-async-utils |
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.
false positive. I've created an issue in js-toolbox to track these problems
https://github.com/Telefonica/js-toolbox/issues/new
src/utils/__tests__/lodash-test.tsx
Outdated
jest.useFakeTimers(); | ||
}); | ||
|
||
describe('debounce', () => { |
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.
why describe?
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.
It is a way to organize the test suite. All debounce
tests are placed inside the debounce
describe section, same with isEqual
or any other method.
According to jest doc:
describe()
creates a block that groups together several related tests
And when you run the tests, they are shown with a pretty hierarchy
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.
I don't like it, and we don't use it anywhere. Organice the tests by file should be more than enough. And you already have a "debounce" or "isEqual" prefix in all your test names. It adds an extra nesting and can be tricky when combined with before/after methods
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.
I don't agree, but it also won't keep me awake.
Removed the describe blocks
@@ -13,6 +13,13 @@ export default defineConfig({ | |||
fileNames: ({name}) => `${name.replace(/\.css$/, '.css-mistica')}.js`, | |||
}), | |||
], | |||
resolve: { | |||
alias: { | |||
// forbid lodash usage |
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.
nice trick
# [14.21.0](v14.20.1...v14.21.0) (2023-08-24) ### Bug Fixes * **Cards:** remove min width from all the cards ([#858](#858)) ([029a6ea](029a6ea)) * **Tabs:** remove extra margin in safari ([#857](#857)) ([be8c2f2](be8c2f2)) ### Features * **FeedbackScreens:** updates in icons, paddings and styling ([#852](#852)) ([4b231e6](4b231e6)) * **Sheet:** new component ([#840](#840)) ([f03ca7c](f03ca7c)) * **utilities:** Remove lodash dependency and replace it with custom functions ([#856](#856)) ([dcaf691](dcaf691))
🎉 This PR is included in version 14.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This will help us to make mistica a fully ES Module library. In my tests, when changing the package type to
module
, the build was complaining aboutlodash
(which is a cjs library).I tried to replace it with
lodash-es
but for some reason that I was unable to understand, that produced problems with the SSR acceptance tests, so at the end we decided to fully remove lodash from mistica components (and we saved 2.2 kB)