marko
marko copied to clipboard
Publishing Components (Documentation/CLI)
New Feature
Document recommendations for publishing components to npm. Add ability to precompile node modules (with post install script).
Description
Currently the recommended approach to publishing a module has been to expose to actual Marko file.
Why
- This creates overhead (every build requires rebuilding all Marko components in node_modules).
- Currently you are unable to require a Marko component as a dependency without using a Marko plugin in your build tools.
Possible Implementation & Open Questions
Recommend component authors to publish with a post-install script to compile the component at install time which allows the component to always be compiled with the applications version of Marko.
Is this something you're interested in working on?
Yes.
Additional thoughts/goals
The post install script must:
- Use the application level Marko (to ensure consistent runtime).
- Not grossly increase the amount of time
npm itakes.
When implementing the post install script there are two options:
- We require that component authors include
markoas a peerDependency andmarko-clias a dependency. - We could add the cli
.binfor the post install script to theMarkorepo, meaning package authors only need to addmarkoas a peerDependency.
The first option is the simplest, however there could be issues with versioning the cli. The other issue is the dev ergonomics of having to install the marko-cli for all components and apps.
With the second option it allows us to avoid installing all of marko-cli when running post installs (this currently takes a while because of deps like puppeteer.).
The downside of the second option is that it would either require duplicating code between marko and marko-cli 🙅♂️. Alternatively we could separate out each of the marko-cli utilities into their own repo. If the separate repo option is chosen it would likely be worth considering using lerna to manage the cli as the number of packages increases.
To add my thoughts, I think I'm leaning towards having a .bin in the marko package for postinstall. This means the postinstall script would always be n'sync with the application's version of marko
The proposed postinstall script strategy may need to be reevaluated, since new Yarn features/versions are trying very hard to discourage them.