jrson83 / create-vite-plugin-ssr

create-vite-plugin-ssr wip
https://vite-plugin-ssr.com
MIT License
1 stars 1 forks source link

Monorepo architecture #8

Open brillout opened 2 years ago

brillout commented 2 years ago

How about:

That's it.

Where:

// packages/create-vite-plugin-ssr/package.json
{
  "name": "create-vite-plugin-ssr"
  // ...
}
// packages/build/package.json
{
  "name": "@awesome-scaffolder/build"
  // ...
}

We need a cool name for our scaffolding tech :-)

// packages/cli/package.json
{
  "name": "@awesome-scaffolder/cli"
  // ...
}

We need two npm pacakges because @awesome-scaffolder/cli is included in the npm package create-vite-plugin-ssr whereas @awesome-scaffolder/build is a dev dependency.

# Source files, checked in GitHub, not published to npm
pacakges/create-vite-plugin-ssr/boilerplates/preact
pacakges/create-vite-plugin-ssr/boilerplates/react
pacakges/create-vite-plugin-ssr/boilerplates/vue

# Generated files, pubslished to npm and not GitHub
pacakges/create-vite-plugin-ssr/templates/preact
pacakges/create-vite-plugin-ssr/templates/preact-js
pacakges/create-vite-plugin-ssr/templates/react
pacakges/create-vite-plugin-ssr/templates/react-js
pacakges/create-vite-plugin-ssr/templates/vue
pacakges/create-vite-plugin-ssr/templates/vue-js

# Config for `@awesome-scaffolder`
packages/create-vite-plugin-ssr/scaffold.config.ts
# Build script that generates the `templates/` dirS
packages/create-vite-plugin-ssr/build.ts
// packages/create-vite-plugin-ssr/build.ts

import scaffoldConfig from './scaffolder.config'
import awesomeScaffolder from 'awesome-scaffolder'

build()

async funciton build() {
  await awesomeScaffolder(scaffoldConfig)
}

Eventually, in the future, create-vite-plugin-ssr and @awesome-scaffolder would live in two different repositories.

jrson83 commented 2 years ago

I am very happy with the current folder structure and have put a lot of time and thought into it.

Because I don't have a lot of experience with publishing monorepos on NPM, I knew that something might need to be changed in the folder structure, but for now let me integrate the missing features so you can see how I envisioned the whole thing.

At the moment, restructuring again would be a massive throwback, not only for development time, but also my state of mind, because as I said I'm very happy with the structure.

I have of course considered that only certain folders are published only on Github or NPM (see .gitignore, .npmignore).

brillout commented 2 years ago

Ok we can keep it like this for now.

I think we'll have to change it though if we want to build a generic scaffolder.

The idea here is that create-vite-plugin-ssr is using awesome-scaffolder, where awesome-scaffolder can be used not only for vps but also for other tools.

jrson83 commented 2 years ago

I think we'll have to change it though if we want to build a generic scaffolder.

Yeah, as I tried to make a monorepo setup, like you described, I realized the purpose of your idea. Like the Vite monorepo, the actual github repo should be create-vite-plugin-ssr-monorepo which holds the actual create-vite-plugin-ssr module in packages, which then can have the cli as dependency,build as devDependency, include the current boilerplates module and also the templates module, and then either exclude or include the folders for github or npm, like you said. Since I like the idea with one scaffoldConfig, I will try to recreate a new setup again.