Auto code splitting - does component need to be defined in route file?
Hello! I need clarification on the automatic code splitting feature.
Current Pattern:
The Docs Say:
"Route properties like component, loader, etc., should not be exported from the route file. Exporting these properties results in them being bundled into the main application bundle, which means that they will not be code-split."Example from docs: Question: Does this mean the component MUST be defined in the route file (not imported) for auto code splitting to work? Should I refactor to this instead? If yes, is this the recommended approach even for large pages? Or is there a better pattern to maintain separation while keeping auto code splitting? Thanks! 🙏
2 Replies
solid-orange•2mo ago
the docs are not wrong, but the wording can be improved. IF you define a component inside a route file, THEN dont export it. importing it from any other file is fine
exotic-emeraldOP•2mo ago
Got it, thanks for clarifying!