-
Notifications
You must be signed in to change notification settings - Fork 507
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
Add initial monorepo template #778
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One simplification could be to just have 2 root-level tsconfig
s and one top-level .prettierrc
You may wanna mark this PR as resolves: #122
Good work! I've also got: https://github.com/AirLabsTeam/air-core FWIW
templates/monorepo/.gitignore
Outdated
dist | ||
compiled | ||
*.log | ||
coverage | ||
.DS_Store | ||
next.d.ts | ||
legacy.d.ts | ||
.idea | ||
*.orig | ||
|
||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
!/yarn.lock | ||
|
||
website/translated_docs | ||
website/build | ||
website/yarn.lock | ||
website/node_modules | ||
website/i18n | ||
!website/yarn.lock | ||
|
||
.vercel | ||
.yalc | ||
yalc.lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you need to do **/X
to some of these?
Thanks for working on this Jared! This is top 3 or top 2 most-requested features and the only one I have no WIP for or much experience with. I started reviewing this morning, will try to finish later tonight after work.
@kylemh per #122 (comment), without the
@jaredpalmer Agreed. I would say we might want to title the template as
I was thinking we'd modify
Yes, multi-entry is very different; that's for multiple entries within one package. E.g. a component library like MUI or a utility library like Lodash, or, per my comments there, the two use-cases I already use it for, polyfill + ponyfill ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, here's a first pass. Still need to dive a bit into the README but otherwise have gone through almost everything with a lens.
Sorry that the comments are a bit scattered in terms of order as I made them throughout multiple days, GitHub doesn't let you sort them 😕
Main issues are around inconsistency with existing templates and tsconfig
options that don't work with TSDX.
"registry": "https://registry.npmjs.org/", | ||
"publishConfig": { | ||
"access": "public" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these necessary? I believe these are the defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for scoped packages
|
||
Unlike other TSDX templates, the developer experience for this template is currently a bit more manual. | ||
|
||
Your first order of business will be to search and replace `@mono` for the npm organization of your own. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need to change author/username and LICENSE file. And description of packages, though that one's a given since the other templates don't do that either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lerna syncs the license from root prior to publishing for each package. lerna/lerna@5863564
"peerDependencies": { | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"peerDependencies": { | |
"react": "^16.8.0", | |
"react-dom": "^16.8.0" | |
}, | |
"peerDependencies": { | |
"react": ">=16", | |
}, |
Let's keep this consistent with the React templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof I didn't realize this was still there. Packages that use hooks actually need to specify React as peer dep as "react": "^16.8.0"
(when hooks were introduced). We should discuss in another issue tho as we will need to change the other templates too
@@ -0,0 +1,36 @@ | |||
{ | |||
"name": "@mono/react", | |||
"version": "0.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "0.0.0", | |
"version": "0.0.0", | |
"license": "MIT", |
MIT license missing. We probably want to include a LICENSE
file in each package as well. NPM will automatically include any LICENSE
file when publishing (similar to README.md
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lerna copies root license into each package before publishing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, does it do that for package.json.license
too? Fancy
@@ -0,0 +1,26 @@ | |||
{ | |||
"name": "@mono/utils", | |||
"version": "0.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "0.0.0", | |
"version": "0.0.0", | |
"license": "MIT", |
MIT license missing. We probably want to include a LICENSE
file in each package as well. NPM will automatically include any LICENSE
file when publishing (similar to README.md
)
@jaredpalmer, this template looks great! I am in the process of porting over a hand-crafted monorepo to this template. So far so good - only thing I am missing is Storybook. Can you please provide some pointers on how to integrate storybook? I have seen the react + storybook template, however wondering how I could leverage it in the monorepo. |
Hey @nareshbhatia maybe this repo will help? |
Thank you, @kylemh - awesome resource! Good to see that your setup generates a single Storybook for all the packages. |
to be fair, only one package uses it, but if more do - it's ready for that |
Probably not gonna have bandwidth to push this through for a week or 2, so if others want to jump on in and get this out feel free |
@jaredpalmer, @kylemh - thanks for all your help. I have now successfully migrated a substantial monorepo to tsdx. Would love to have you take a quick glance and provide feedback. The repo is here and the live Storybook is here. This repo essentially provides wrapper components over Material-UI and Formik. Also bunch of helper functions for date & time, http, web etc. Some of the key challenges I solved were:
|
I fiddled around with tsdx and monorepo and came up with this: https://github.com/known-as-bmf/store It uses The philosophy of
Also, there is no root package wrapping everything. Quick overview
|
Co-authored-by: Anton Gilgur <agilgur5@gmail.com>
Co-authored-by: Anton Gilgur <agilgur5@gmail.com>
Co-authored-by: Anton Gilgur <agilgur5@gmail.com>
This comment has been minimized.
This comment has been minimized.
any update on this? really looking forward to something like |
Will this work with yarn 2.0 berry? |
@timini you can see it in action here https://github.com/jaredpalmer/tsdx-monorepo. I am pretty sure it doesn't work with it, but I haven't tested it. |
Is there anyone know how to utilize tsdx with turborepo? |
This is a working monorepo template with tsdx.
I didn't bother with changing
tsdx create
yet. I will leave that work for others.This template bootstraps a minimally viable monorepo project with 2 packages
@mono/react
and@mono/utils
as well as an example playground. It's all powered by lerna, yarn workspaces, and tsdx. It has a similar workflow to regular tsdx: the example live reloads when changes are made to any package<package>/src/*
folder that triggers a rebuild.The onboarding for this template is more involved as we need to generate nested package.json's in addition to the root one. However, I'm comfortable with shipping this ASAP but telling users to search and replace
@mono
with@yourname
until we integrate it more deeply into the create command.Lastly, I think we will also want to add another few of templates to tsdx for packages within monorepos that assumes this core project structure.
Note: this is slightly different from multi-output #367. We still need that too. My idea is that this works today, and we can ship it. I'm already using this exact setup at work.