Skip to content
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

Register lodash as dependency to externalize it #1844

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jorrit
Copy link

@jorrit jorrit commented Jan 29, 2025

What does it do?

I noticed that the dist files of the design system package contain the entire lodash source.

See: https://www.npmjs.com/package/@strapi/design-system/v/2.0.0-rc.14?activeTab=code
image

The design-system package uses lodash directly in extendTheme.ts but doesn't list this as a dependency in package.json. lodash happens to be present because it is a sub-sub-subdependency:

> npm ls lodash
[email protected] .\strapi-design-system
`-- @strapi/[email protected] -> .\packages\design-system
  `-- @strapi/[email protected]
    `-- [email protected]
      `-- [email protected]

By making it a direct dependency, vite will not bundle it in the dist files. Besides that, it is more correct to not rely on sub-dependencies.

Why is it needed?

When investigating the dist code of the strapi-plugin-navigation module I noticed that it contains the entire lodash code. I investigated this and it lead to the conclusion that it is actually the design-system package that provides this.
See VirtusLab-Open-Source/strapi-plugin-navigation#509

How to test it?

Build the design-system package before and after this change and observe the file size decrease.

It may be the case that there are more dependencies of the code that could be externalized

Without this change, the dist files include the entire lodash source
Copy link

vercel bot commented Jan 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 29, 2025 9:00am

@HichamELBSI
Copy link
Collaborator

@jorrit Thanks for your contribution, in order to merge the PR, you will need to generate changeset. You can run yarn release:add to generate it. Feel free to follow the contributing guide.

@jorrit
Copy link
Author

jorrit commented Jan 31, 2025

My apologies for not following the guidelines. I'll update the PR after the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants