You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and fresh would simply pick them up and auto-register them. However, thinking about it, this makes it difficult to specify registration order, which is already very possible by simply passing it to the "plugins" array of the start function.
I'm usually not into "magic" and doing too much behind the curtains (I prefer explicit code), but we are already doing file-based routing, so it seems only natural to allow this for plugins as well.
Disclaimer
Needless to say, this is just an idea as to "complete" the (1) file-based functionality of fresh, not to discourage the (2) more minimalistic, config-based approach of #1487 and #1602, which I believe we need to support as well. That being said, if this idea slows down (2), or adds too much complexity, I would discourage pursuing it.
The text was updated successfully, but these errors were encountered:
Babel tried this approach, but quickly moved away from that in favor of explicitly declaring which plugins to load. Doing auto-loading magically behind the scenes seems nice at first, but gets super nasty when you have plugins that depend on each other and expect one of them to be loaded first. With auto-loading the order is what every Fresh decides on (likely the way it's layd out in the file system), which isn't obvious and can lead to difficult to debug bugs.
I'm worried about the amount of magic causing more harm than good and causing more maintenance overhead. For routes this isn't as much of an issue because for 98% of routes (yes there are very few exceptions), they can be scored and sorted by specificity. This is something we can't do with plugins. Therefore auto-loading is something we won't add to Fresh.
Closing this issue as it caused confusion for users who stumbled on this and assumed Fresh doesn't support third party plugins in discord. This issue is merely about auto-loading plugins.
Fresh currently supports file-based routing, and in a more general sense, has the following "spec 9865 ial" folders:
components/
islands/
routes/
Continuing with this pattern, aren't we missing a
plugins/
folder, which could allow dynamic mounting/registration of plugins?plugins/
some-custom-plugin.ts
- e.g. adds some middleware to/
plugins/another-custom-plugin.ts
- e.g. adds error pages/_404
and/_500
Proposal
Then plugins e.g.
plugins/some-custom-plugin.ts
could be defined as follows:Or directly with a default exported Plugin object:
and fresh would simply pick them up and auto-register them. However, thinking about it, this makes it difficult to specify registration order, which is already very possible by simply passing it to the
"plugins"
array of thestart
function.I'm usually not into "magic" and doing too much behind the curtains (I prefer explicit code), but we are already doing file-based routing, so it seems only natural to allow this for plugins as well.
Disclaimer
Needless to say, this is just an idea as to "complete" the (1) file-based functionality of fresh, not to discourage the (2) more minimalistic, config-based approach of #1487 and #1602, which I believe we need to support as well. That being said, if this idea slows down (2), or adds too much complexity, I would discourage pursuing it.
The text was updated successfully, but these errors were encountered: