-
Notifications
You must be signed in to change notification settings - Fork 61
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
strapi-plugin-navigation/dist/admin/index.js/mjs contains entire lodash source #509
Comments
We will investigate it, maybe the case is with bundling as a devDependency. |
Optimized package released as |
Most probably so that's an issue to address for Strapi Core team :) Last changes made package twice lighter so should be more manageable. |
I see you minified the source. I don't think that that is useful, because the plugin will be bundled and minified again when it is integrated in a Strapi application. |
As the NPM package is not carry the source files (TS) the minified source is going to be injected into the Strapi build, the size shouldn't be impacted. |
I have looked into this a bit and it seems it is not lodash that is included, but the entire strapi design system code. The index.js / index.mjs files of strapi design system contain lodash and for some reason these files are embedded in your plugin instead of imported. |
### 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](https://github.com/user-attachments/assets/26e8220f-bdeb-4188-935c-483037715b11) 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_
I noticed that the files in the dist/admin folder are pretty big: 2MB for js and mjs. It seems that for some reason lodash is bundled in these files:
I tried to find the cause in
@strapi/sdk-plugin
and@strapi/pack-up
but I could not find it quickly. Perhaps you have an idea.The text was updated successfully, but these errors were encountered: