Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multipackage monorepos #1534

Closed
ffflabs opened this issue Feb 17, 2016 · 5 comments
Closed

Support multipackage monorepos #1534

ffflabs opened this issue Feb 17, 2016 · 5 comments

Comments

@ffflabs
Copy link

ffflabs commented Feb 17, 2016

A few big projects are embracing the monorepo approach (For example babel, Ember, React and soon Turf, or so it seems) without giving up their multipackage structure.

The thing is, instead of separating packages physically in the form of N repos (which tend to become a real mess) those project resort to a logical separation. They have a packages folder in which each subfolder is a package by itself with its own package.json, thus allowing for code reutilization at an atomic level.

Tools like babel are using lerna to publish the contents of each subfolder as an NPM package, so people can build babel-like projects that need only a few individual packages. However, I believe that step to be overkill for a tool like jspm. We don't need to have NPM as a man in the middle if there's a folder convention.

Currently, when using jspm-cli to install a component from a github repo, we work under the assumption that there's a package.json in the root, like so

jspm install github:facebook/react 

will look for https://github.com/facebook/react/blob/master/package.json

That behavior could remain untouched, but we could add support for a syntax like

jspm install github:facebook/react/packages/react-dom

Which will instead use https://github.com/facebook/react/blob/master/packages/react-dom/package.json to figure out the entry point and eventual dependencies.

@guybedford
Copy link
Member

It's a good point, yes the monorepo approach is becoming popular as a git optimization. But that doesn't mean it is a package management optimization. Personally I prefer to clone all my packages into a single "project" folder, and then link between the subfolders, which provides an equivalent development experience to a monorepo. With the monorepo approach, rather than installing github:facebook/react typically one installs from npm:react, where a package is a package. In development within the monorepo, linking approaches are used to work on the packages together as opposed to installing.

From a technical perspective, installing from subfolders within a package is not possible anyway as packages need to have a well-defined package format and can't use arbitrary numbers of / separators in jspm.

@ffflabs
Copy link
Author

ffflabs commented Mar 15, 2016

Just to provide a bit more context, yesterday I found out that this is a subject that has been brought to the table since 2012 at NPM's issues: npm/npm#2974

If I had seen that before I should have known there's no easy answer.

@fusionstrings
Copy link
Contributor

Tools like bazel, lerna and yarn workspaces have helped to achieve better experience for monorepo based repositories. This seems like critical in adopting JSPM.

Do you have change of thought on the subject @guybedford ?

@guybedford
Copy link
Member

@fusionstrings yes there is a sort of a local monorepo pattern for jspm, just give me a few days to test that it is working smoothly before sharing further.

@guybedford
Copy link
Member

I finally managed to put together my thoughts on this topic in #2491. There are still some linking features / bugs that need working out as are being tracked there. Would really value your feedback further on that too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants