8000 [plugins] refactor framework setup into fresh plugins · Issue #92 · netzo/fresh-netzo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.
This repository was archived by the owner on Sep 22, 2024. It is now read-only.
[plugins] refactor framework setup into fresh plugins #92
Closed
@miguelrk

Description

@miguelrk

TLDR: refactor the current project setup with a Netzo() entrypoint function in netzo.ts into the regular fresh project structure, with a regular netzo() fresh plugin to mount everything.

Context

In the spirit of aligning more to fresh, it is best to return to the default fresh project structure with a dev.ts, main.ts and a netzo.config.ts (extends the regular fresh.config.ts). We actually had it this way before, but we abstracted it away into a single netzo.ts for developer convenience (simpler project structure) and greater control (e.g. enforcing certain plugins). Going back to a netzo.config.ts would align netzo more with fresh, without sacrificing much DX. To do so, I see 3 alternatives:

1) Separate plugins
This has the least DX, but more modularity, encouraging the plugin ecosystem to grow. Downside is that there is innevitable dependency between certain netzo plugins (by design, to ease the setup, e.g. components depend on unocss being enabled) and this modularity decreases the ability to enforce certain plugins depending on others. That being said, explicit is always better than implicity, and this could be solved easily by simply documenting it.

import { auth } from "netzo/core/auth/mod.ts"
import { api } from "netzo/core/api/mod.ts"
import { unocss } from "netzo/core/unocss/mod.ts"
export default defineConfig({
  plugins: [
    auth({...}),
    api({...}),
    unocss({...}),
  ]
});

2) Separate plugins (with barrell file)
Same as above, with an additional barrel file import for DX convenience (despite perf issues with barrell files, this is opt-in so it's ok to offer it).

import * as netzo from "netzo/core/mod.ts"
export default defineConfig({
  plugins: [
    netzo.auth({...}),
    netzo.api({...}),
    netzo.unocss({...}),
  ]
});

3) Single plugin
This allows enforcing certain functionalities required by netzo (e.g. platform features like auto-loading remote environmnet variables) and also since some modules depend on others (e.g. components depend on unocss being enabled).

import * as netzo from "netzo/core/mod.ts"
export default defineConfig({
  plugins: [
    netzo({
      auth: {...},
      api: {...},
      unocss: {...},
    })
  ]
});

Related

Additionally, simplifying the project structure and fresh server should ideally be done upstream in fresh-land.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0