Skip to content

belgattitude/next-transpile-ts-workspace

Repository files navigation

CAUTION this repo has been moved to vercel-monorepo-test

NextJS monorepo tests

Experimenting with a monorepo setup for nextjs / typescript.

See: https://next-transpile-ts-workspace.vercel.app/

Approach

How to

Structure

.
├── apps
│   ├── web-app                 (NextJS application)
|   |   ├── src/
|   |   ├── next.config.js
|   |   ├── package.json
|   |   └── tsconfig.json       (extends base config)
├── packages
│   ├── bar                     Bar package, publishable with microbundle)
|   |   ├── src/
|   |   ├── package.json
|   |   └── tsconfig.json       (extends base config)
│   ├── foo 
|   |   ├── src/
|   |   ├── package.json
|   |   └── tsconfig.json       (extends base config)
├── package.json                (the workspace config)
├── tsconfig.json               (base typescript config)
└── vercel.json 

Notes

Drawbacks

  • Keep all deps at the same version. You will run into problem if one package depends a v1 version and another in a v2. (There's a script to check that yarn deps:check)
  • You might have to create multiple tsconfig.json (i.e: tsconfig.dev.json, tsconfig.build.json...) if you want to use a distributed package rather than transpiling.
  • Currently only one app can be build on vercel (waiting for monorepo support)

Advantages over next-transpile-modules

Advantages of next-transpile-modules

  • It handles css/scss as well

Interesting next steps:

Caution

  • Monorepos are not monoliths, this approach is for sanity while developing (not rebuild). For production packages should be publishable and apps deployable independently (lerna, nx...).

About

Testing next-transpile, with typescript yarn workspace

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published