{"id":13683479,"url":"https://github.com/martpie/monorepo-typescript-next-the-sane-way","last_synced_at":"2025-04-10T18:12:38.409Z","repository":{"id":47022355,"uuid":"144131686","full_name":"martpie/monorepo-typescript-next-the-sane-way","owner":"martpie","description":"A monorepo example using TypeScript and Next.js","archived":false,"fork":false,"pushed_at":"2023-01-05T14:39:24.000Z","size":738,"stargazers_count":144,"open_issues_count":0,"forks_count":20,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T15:52:23.786Z","etag":null,"topics":["javascript","jest","monorepo","next","nextjs","tslint","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/martpie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-09T09:35:14.000Z","updated_at":"2025-02-28T00:25:57.000Z","dependencies_parsed_at":"2023-02-04T06:15:28.935Z","dependency_job_id":null,"html_url":"https://github.com/martpie/monorepo-typescript-next-the-sane-way","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martpie%2Fmonorepo-typescript-next-the-sane-way","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martpie%2Fmonorepo-typescript-next-the-sane-way/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martpie%2Fmonorepo-typescript-next-the-sane-way/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martpie%2Fmonorepo-typescript-next-the-sane-way/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martpie","download_url":"https://codeload.github.com/martpie/monorepo-typescript-next-the-sane-way/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248269295,"owners_count":21075777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","jest","monorepo","next","nextjs","tslint","typescript"],"created_at":"2024-08-02T13:02:12.659Z","updated_at":"2025-04-10T18:12:38.392Z","avatar_url":"https://github.com/martpie.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# Monorepo + TypeScript + Next.js: The Sane Way\n\nThis repo is an experiment to set-up a monorepo for a Next.js project using modules located in other directories. Everything is not perfect and \"real-world\" ready, but it should be a good first step.\n\n- **Strict TypeScript**: potential bugs are not an option\n- ~~**Transpiled server-side code**: needed if you are going to re-use modules for both client and server-side~~ Not anymore, Next.js is plenty powerful now and does not need it anymore in 99% of the cases\n- **Jest**\n- **TypeScript**\n- **ESLint** (now included in Next.js 10)\n- **Transpile local packages** with Next.js on-demand + HMR\n\nMy approach completely changed after a couple of projects, I realised the previous approach of having common configuration files was a bad practice:\n\n- Not a true monorepo where every subfolder is a separate app\n- Difficult to deploy and test on CI\n\nNow, configuration files are repeated in each sub-folders, which means you need to be more careful regarding config and dependencies versions, but things are much easier to manage for developers and text editors.\n\n## Todos\n\n- [ ] GitHub actions sample\n- [ ] ESLint + Jest everywhere\n\n## More in details\n\n### TypeScript\n\nThe config is at the root of each project: `\u003croot\u003e/\u003csub-project\u003e/tsconfig.json`.\n\n### Unit-tests\n\nJest is used for unit tests and all test files should be put in `__tests__` folders to match the Jest philosophy and not pollute your directories too much.\n\nThe config is at the root of each project: `\u003croot\u003e/\u003csub-project\u003e/jest.config.js` and all the tests can be run with `npm run test:unit` in each folder.\n\n### Linting\n\n`npm run test:lint`\n\n### Root folder\n\nPut everything you want there, a Next app, shared code, a react-native app, a CRA, even Wordpress if you want.\n\n### Next.js and local modules\n\n~~Next.js will transpile modules thanks to the [`next-transpile-modules`](https://github.com/martpie/next-transpile-modules) package. Transpiled modules can be changed by editing the `transpileModules` option in `website/next.config.js`.~~\n\nSince Next.js 13.1, we can now use `next.config.js`'s `transpilePackages` option to achieve the same.\n\nThis setup works thanks to npm symlinking local dependencies in `website/`'s `node_modules` folder. Yarn workspaces would work as well (though requiring some adaptation from this bolerplate).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartpie%2Fmonorepo-typescript-next-the-sane-way","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartpie%2Fmonorepo-typescript-next-the-sane-way","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartpie%2Fmonorepo-typescript-next-the-sane-way/lists"}