nuxt / rfcs

RFCs for changes to Nuxt.js
96 stars 2 forks source link

Blueprints #37

Closed pimlie closed 2 years ago

pimlie commented 4 years ago

Introduction

Nuxt blueprints will be a way of distributing a micro-like-framework for Nuxt.js utilizing a Nuxt.js module. It follows (more or less) the same folder pattern as Nuxt.js and automatically registers any special components/scripts in the proper Nuxt way.

History

Basic concept of this rfc is based on work done by @galvez for NuxtPress. Not sure where his ideas were based on.

How does it work?

A blueprint will just be a supercharged Nuxt.js module (at least for starters, i.e. start small, grow big). E.g. currently the Nuxt.js module container provides only singular methods, meaning you can only register e.g. one plugin at the time (:bike:) . A blueprint module supports adding multiple plugins at the time (:bus:)

It will also provide a helper function to automatically discover template files within a folder to include. Those files can then be added all at once using another special resolver function.

If you dont like things to happen automagically, you could also just call the corresponding functions yourself

Isnt that module inception?

Yes, if you create a blueprint you create a module based on the blueprint module which uses the module container. A dream level 3 module if you like :upside_down_face: :open_mouth: :upside_down_face:

Why not just add these features to the moduleContainer?

Cause that could potentially break existing modules (although unlikely). Also nice to have separation of concerns, a blueprint will be so much more then just a module that it makes sense to split this.

Ok, but what about #30?

Same but different. Probaby this rfc evolved from that one, but the approach is a bit different. This rfc is module-centric and mainly utilizes only existing Nuxt features1

1 Existing as in available in nuxt-edge because some missing features have just been added to Nuxt.js

When will it be ready?

The basics have already been developed for Nuxt/Press

Why this rfc when its already available?

The NuxtPress implementation is/might not be generic (enough). This rfc is to find out what is missing.

I still dont get it?

To show by example, please explore the fixes-v0.2 branch of NuxtPress and read the blueprint & common replaced with core sections of this pr. Its a working example of what you can do with blueprints.

Feature wishlist

[x] = already implemented

pimlie commented 4 years ago

First alpha release is available: https://github.com/nuxt/blueprints