EricSmekens / jsep

JavaScript Expression Parser
http://ericsmekens.github.io/jsep/
MIT License
836 stars 136 forks source link

Plugin mono repo #158

Closed 6utt3rfly closed 3 years ago

6utt3rfly commented 3 years ago
├── README.md
├── package.json
├── plugins
│   ├── plugin-assignment
│   │   ├── dist
│   │   │   ├── cjs
│   │   │   │   ├── index.cjs.js
│   │   │   └── index.js
│   │   ├── src
│   │   │   └── index.js
│   │   ├── test
│   │   │   └── index.test.js
│   │   ├── types
│   │   │   └── ts.d.ts
│   │   ├── package.json
│   │   ├── README.md
│   │   └── rollup.config.js
│   └── ...plugins
├── src
│   ├── jsep.js
│   └── index.js
├── test
│   ├── jsep.test.js
├── rollup.config.js

I added a build:all script, that is just cd plugins/{name} && npm run build... I manually copied everything to a typescript project and was able to:

import * as jsep from 'jsep';
import * as jsepArrow from '@jsep/plugin-arrow';
jsep.plugins.register(jsepArrow);

Note: I've never created a mono-repo before, but I copied rollup as an example framework and I think it works...

LeaVerou commented 3 years ago

I'm not very familiar with how mono-repos work. Maybe @EricSmekens should review this one.

I do like that plugins seem to be entirely self contained. I don't like the repetition. It looks like if we make a change to the build process, we'd need to make it N times, where N is the number of plugins? Is there a way to make this a little more DRY?

How does versioning work in a monorepo? Do plugins have their own versions or does the entire repo have a single version?

6utt3rfly commented 3 years ago

I removed a couple files per repo, but there are still 7 files:

Each plugin would have to be separately published to npm (that's why each has it's own package.json), and so they have independent version numbers. I don't know if there's anything special about publishing to @{string}/... (in this case @jsep/plugin-{name} or if it's first-come-first-serve like usual?

EricSmekens commented 3 years ago

I like the well documented, tested and extensible changes that were made. I don't have any experience with mono-repo/multiple package repo's like this either, but I think we'll manage this with deploying and learn from the initial publishes.

There are some downsides to it, but being able to patch/extend 1 plugin is a advantage. I cannot weigh them properly at this moment, but I feel like this is a fine way ahead and we can make changes along the way.

(Feel free to merge this into your existing PR, and mention me again when we want to move this to npm!)

(Also, apologies for the time I take to reply, busy times).