marko icon indicating copy to clipboard operation
marko copied to clipboard

Publishing Components (Documentation/CLI)

Open DylanPiercey opened this issue 8 years ago • 2 comments
trafficstars

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 i takes.

When implementing the post install script there are two options:

  1. We require that component authors include marko as a peerDependency and marko-cli as a dependency.
  2. We could add the cli .bin for the post install script to the Marko repo, meaning package authors only need to add marko as 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.

DylanPiercey avatar Nov 01 '17 19:11 DylanPiercey

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

mlrawlings avatar Nov 01 '17 21:11 mlrawlings

The proposed postinstall script strategy may need to be reevaluated, since new Yarn features/versions are trying very hard to discourage them.

tigt avatar Jan 29 '20 21:01 tigt