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

Address Vite warnings in build step #193

Merged
merged 8 commits into from
Aug 11, 2024

Conversation

Zac-Evans
Copy link
Contributor

@Zac-Evans Zac-Evans commented Aug 9, 2024

I noticed that Vite shows a few warning messages when running the build step. These few changes clear those messages and should also improve chunking via rollup.


- Error
(!) bulletproof-react/apps/react-vite/src/app/routes/app/users.tsx is dynamically imported by bulletproof-react/apps/react-vite/src/app/routes/index.tsx but also statically imported by bulletproof-react/apps/react-vite/src/app/routes/index.tsx, dynamic import will not move module into another chunk.

- Solution
The loaders for discussions and users need to be in a separate file. Since the page components are being dynamically imported in the router, the static imports for the loaders generate this warning which ends up creating larger chunks sizes.


- Error
src/components/ui/dialog/dialog.tsx (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.

- Solution
Remove "use client" from the dialog component.


- Error
Module "fs/promises" has been externalized for browser compatibility, imported by "bulletproof-react/apps/react-vite/src/testing/mocks/db.ts". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

- Solution
This isn't really an issue other than the error message, but you can prevent it by externalizing fs/promises via rollupOptions in the vite config


- Error
Some chunks are larger than 500 kB after minification. Consider: Using dynamic import() to code-split the application, Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks, Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

- Solution
Fixing the dynamic/static import loader issue gets the chunk size down a bit.

Before After
Before After

@alan2207 Thanks again for the great project, it has been really helpful for improving my project structures!

Copy link

netlify bot commented Aug 9, 2024

Deploy Preview for bulletproof-react-app ready!

Name Link
🔨 Latest commit e2ffecb
🔍 Latest deploy log https://app.netlify.com/sites/bulletproof-react-app/deploys/66b8840be3de590008203180
😎 Deploy Preview https://deploy-preview-193--bulletproof-react-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Zac-Evans Zac-Evans changed the base branch from master to dev August 9, 2024 22:42
@Zac-Evans Zac-Evans changed the base branch from dev to master August 9, 2024 22:43
@alan2207
Copy link
Owner

Hey @Zac-Evans , thanks for addressing these issues. I made some changes in order to keep the loaders colocated, for better maintainability.

@Zac-Evans
Copy link
Contributor Author

@alan2207 Cool that makes sense, thanks for taking a look. In my personal project, the element was loading before the data was fetched when I dynamically imported the loaders. Very possible that's just an issue in my project, might be worth checking though.

@alan2207 alan2207 merged commit 701820e into alan2207:master Aug 11, 2024
6 checks passed
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