-
Notifications
You must be signed in to change notification settings - Fork 5
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
Exported components should not include dependencies #175
Comments
Hi @soedar, yes I agree that we should not be bundling and minifying the output. Could you elaborate on point 1 on how you plan on going about that? I am assuming that you will be also be using |
Ah, that is interesting. I would look into that. It seems like the current rollup configuration treats each component as a separate "build", and the package.json for each component is generated using the In my (limited) testing, I was able to generate component outputs that does not include node_modules dependencies simply by changing the the plugins that are used. However, the component output still included code of other components (i.e. when if a component include But good find, I'll see if I can tweak the config based on
So far during my testing, it seems like there shouldn't be any breaking changes, since we are only changing the way the modules are being generated. But will probably know more once we arrive at the solution and testing possible edge cases. |
Looking at the rollup docs for preserveModules,
Since we want to have explict entry points for each of the components, it seems like we should continue to use the current rollup configuration, where the different components are supplied as inputs to rollup. |
Rollup changes released in v2.2.2 https://github.com/GovTechSG/sgds-govtech-react/releases/tag/v2.2.2 Thank you @soedar for your contributions🌟, I shall close this thread now |
When troubleshooting an issue when using the library with a Next.js application, I noticed that the code exported by the library appears to include its dependencies. This may result in a shadowing behavior, where the dependencies being bundled by the library is used instead of the one installed by npm.
Reproducing behavior
Proposed changes
When packaging the library as a module for other projects, it seems like we should let npm handle the dependencies that would be used by the project and all other libraries. As such, we should not bundle the dependencies when generating the code for components. In addition, we should probably not minify/uglify the output, as it would make troubleshooting issues on the server side more difficult.
In addition, we can also generate a bundled JavaScript (iife), that could be used in the browser. In that case, we would need to include all the bundled dependency (less peer dependencies), and also minify/uglify the output. Essentially, this means we can provide a JS file that can be imported on the browsers (similar to this: https://react-bootstrap.github.io/docs/getting-started/introduction#browser-globals)
I propose the following changes:
node_modules
dependencies when generating code for each component and the main bundle.If this sounds ok, I can work on both changes, and would open PRs for review.
The text was updated successfully, but these errors were encountered: