oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

Ignored files included in vite bundle #133

Closed jfairley closed 4 months ago

jfairley commented 10 months ago

Describe the Bug

Files within src/pages not matching the "routes" or "modals" globs are included in the resulting bundle (/dist).

Generouted Version

@generouted/react-router 1.16.0

Your Example Website or App or Reproduction

I couldn't get generouted working in stackblitz.

Steps to Reproduce the Bug or Issue

  1. create a file that should be ignored (does not match the file glob pattern).
    • out-of-the-box, something like src/pages/_i-am-ignored.tsx would do
    • For me, storybook files are ignored (src/pages/*.stories.ts)
  2. Build for production
  3. Inspect dist to find that the contents of your ignored file made their way into the output.
    • This is especially easy to identify when using @generouted/react-router/lazy, since it creates separate files.

Note: The ignored file is correctly excluded from the route tree, yet it is bundled into dist.

Expected Behavior

Ignored files do not end up in dist.

Screenshots or Videos

No response

Platform

Additional context

No response

lauri865 commented 6 months ago

Check this thread for a good solution to many woes around this. We also had inflated bundle sizes and broken tree shaking unknowingly. Changing to build-time generation (with HMR still) fixed it all.

https://github.com/oedotme/generouted/issues/135

oedotme commented 4 months ago

@jfairley I've excluded the ignored files/directories from Vite's glob pattern and that did that trick to exclude the ignored routes from the production build bundle. It's now released at v1.19.3!