openedx / wg-frontend

Open edX Frontend Working Group
4 stars 0 forks source link

NPM workspaces for JS repositories #165

Open adamstankiewicz opened 1 year ago

adamstankiewicz commented 1 year ago

Description

Many of our JavaScript libraries have several sub-packages included in their repositories.

This is most evidently seen in the Paragon repository where there is a component-generator, dependent-usage-analyzer, example, icons, src, and www all treated as packages within the repository, each containing their own package.json file to define their specific dependencies.

While other repositories (e.g., frontend-build, frontend-platform, frontend-component-header) don't have as many packages, our convention is typically to include an example MFE app in order to run the JS library against for QA during local development.

For example, frontend-build has an example package that defines its dependencies via its own package.json file. To run the example app after a git clone of the repo, you have to cd example && npm install && npm start rather than simply running npm install && npm start from the root of the repository, which is not intuitive.

To get around this issue and others in Paragon, we have adopted NPM workspaces. As such, this GitHub issue is intended to track the consideration of whether NPM workspaces are relevant for any of our other JS libraries as a quality of life improvement for contributors and newcomers.

davidjoy commented 1 year ago

FYI - https://github.com/openedx/frontend-platform/pull/235 which I plan to merge ASAP adds two sub-projects to frontend-platform (example and example-plugin-app)

Also, I discovered you can do npm --prefix example start and add that to your top-level package.json and it works like a charm.