readthedocs / readthedocs.org

The source code that powers readthedocs.org
https://readthedocs.org/
MIT License
8.01k stars 3.58k forks source link

Npm install support #11216

Open LecrisUT opened 7 months ago

LecrisUT commented 7 months ago

What's the problem this feature will solve?

Similar to the python.install feature, it would be nice to support a npm.install as well. Maybe also cargo and go?

Describe the solution you'd like

A small wrapper for npm install (and npm build?) to automatically build the packages in package.json. Having first-party support would be helpful, because than the caching can be more efficiently shared.

Alternative solutions

Manual control of cache artifacts

agjohnson commented 7 months ago

We were sort of discussing this recently. Right now, our default commands executed for builds are meant to serve Python based projects. This comes from all of the tooling we directly supported historically being Python based tools -- Sphinx and Mkdocs.

More direct support for Node/etc tooling is getting into some new area for us, so we don't yet have concrete plans here. Feedback here is definitely helpful for us!

So, a few things that we've discussed at some points:

We've talked about at very least offering overrides to default build jobs. These are discussed more here:

The missing jobs right now are:

You can sort of accomplish this now with the pre_install/post_install jobs too. But official support might look like:

build:
  jobs:
    install:
      - npm install
    build:
      html:
        - npm run build
        - ...

As far as native support for npm install in our configuration file, these additions are hard for us to maintain. So, we might instead prefer to keep npm/etc support at simply overriding build.jobs.install for now. This feels reasonable as there probably isn't much to gain from our configuration file acting as a proxy.

You can also do this with build.commands but need to control the build process entirely.

Our eventual goal here is to support/offer reusable, community build packages, where users only need to specify the tooling package and it's arguments. This is a far ways out though.

As far as caching goes, we do not cache anything between builds anyways. Each build requires a full, fresh checkout of your repository. We've tried caching layers and surprisingly saw little improvement with build time.