A starter to bootstrap your next monorepo with Lerna, TypeScript, a frontend powered by Next, a backend powered by Node + TypeScript and a shared package to reuse code across those packages.
A starter to bootstrap your next monorepo with Lerna, TypeScript, a frontend powered by Next, a backend
powered by Node + TypeScript and a shared package to reuse code across those packages.
It includes by default three packages
backend
- A TypeScript node backend, with aliases and bundling setup
frontend
- A fully featured Next TypeScript frontend (e2e testing, jest, styled-components…)
shared
- A simple package bundled with Rollup to export code that needs to be reused across packagesYou must launch the scripts at the root level.
```shell script
yarn install
yarn start
yarn dev
yarn test
yarn lint
yarn build
yarn frontend:lint
yarn frontend:start
yarn frontend:dev
yarn frontend:build
yarn frontend:test
yarn backend:lint
yarn backend:start
yarn backend:dev
yarn backend:build
yarn backendwatch
yarn shared:lint
yarn shared:build
yarn sharedwatch
### Shared
The shared folder is made to have a package that can be reused across your different packages.
It is configured to emit an ES module compatible source and CommonJS (for Node based environment or older runtimes).
You can consume it in your `frontend` and `backend` just by importing it like this
```typescript
import { foo } from '@monorepo-lerna-typescript-starter/shared'
But the package needs first to be built. If you’re using the provided scripts, they ensure that the
package is first bundled to avoid some errors.
For exemple, when using the dev
script, it launches the watch mode for your backend, the shared package and
the next application. For the frontend app, you even have the auto reloading feature when updating your
shared package!
See main
and modules
in the package.json. The TypeScript typings definitions are also exported.
You can also use, as for the other packages, the ~
alias (see packages/shared/src/index.ts
)
The template includes Prettier, ESLint (with Typescript-eslint), Babel and Husky.
All their related configurations are in the *rc
files, and it works across all the packages.