Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pklaschka/pnpm-parcel-monorepo-test
A repository for trying a JS/TS npm library monorepo setup using pnpm as package manager and parcel as a build tool.
https://github.com/pklaschka/pnpm-parcel-monorepo-test
js library monorepo npm parcel pnpm ts typescript workspaces
Last synced: 2 months ago
JSON representation
A repository for trying a JS/TS npm library monorepo setup using pnpm as package manager and parcel as a build tool.
- Host: GitHub
- URL: https://github.com/pklaschka/pnpm-parcel-monorepo-test
- Owner: pklaschka
- Created: 2022-03-07T11:29:56.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T01:17:06.000Z (3 months ago)
- Last Synced: 2024-10-13T08:12:50.817Z (3 months ago)
- Topics: js, library, monorepo, npm, parcel, pnpm, ts, typescript, workspaces
- Language: JavaScript
- Homepage: https://pklaschka.notion.site/pnpm-and-parcel-for-monorepos-56107d7839594eec8ef5b6d0e9abcb1c
- Size: 1.09 MB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `pnpm` & `parcel` monorepo test
A repository for trying a JS/TS npm library monorepo setup using `pnpm` as package manager and `parcel` as a build tool.
Development prerequisites:
- [Node v16+](https://nodejs.org/en/download/)
- [pnpm](https://pnpm.io/installation)## Tech Stack
This is an overview of the most important components of this monorepo's tech stack
- **[pnpm](https://pnpm.io/)** -- package and monorepo workspace manager
- **[Parcel](https://parceljs.org/)** -- build tool
- **[Jest](https://jestjs.io/) / [`ts-jest`](https://kulshekhar.github.io/ts-jest/)** -- Unit testing framework
- **[TypeScript / `tsc`](https://www.typescriptlang.org/)** -- TypeScript type checking
- **[TypeScript ESLint](https://typescript-eslint.io/docs/linting/)** -- linting
- **[Prettier](https://prettier.io/)** -- code formatter
- **[fliegdoc](https://fliegwerk.github.io/fliegdoc/)** -- documentation generator
- **[GitHub Actions](https://docs.github.com/en/actions)** -- CI pipeline
- **[Renovate](https://renovatebot.com/)** -- Dependency Update Management## Usage
### Setting up the development environment
Install the dependencies:
```shell
pnpm install
```- automatically runs recursively for the workspace, cf. https://pnpm.io/cli/install
- Alias: `pnpm i`
- `npm ci`-equivalent: `pnpm i --frozen-lockfile` (automatically true in CI environment)**You can also run `pnpm install` when anything about your dependencies becomes out of date to fix it back up.**
### Dependency Management
#### Installing dependencies to packages
Run commands in the package's directory:
##### External dependencies
```shell
pnpm add [-D] @fliegwerk/logsemts
```##### Other packages from monorepo
```shell
pnpm add [-D] --workspace [package-name]
```- `--workspace` ensures that it is installed from the workspace directory.
- by default installs as `workspace:^[version]`. I recommend adjusting this to `workspace:^` afterwards to make it an easier workflow for updates (this "version specifier" gets replaced automatically with the correct version on publish)#### Installing development dependencies to root
In root directory:
```shell
pnpm add -D -w @parcel/core
```- `-w` "enables" running this in the workspace root (otherwise forbidden to ensure that you don't accidentally install it in the workspace root)
### During Development
#### Development flow (watching for changes and re-building)
In root directory:
```shell
pnpm watch
```#### Testing packages manually (REPL)
Install all pacakges in the workspace root (like the development dependencies, but without the `-D` argument).
Then, simply run `node` in the root directory, and you can `require()` all packages.#### Testing packages automatically (Jest-based unit tests)
In root directory:
```shell
pnpm test
```or
```shell
pnpm exec jest
```### Linting and Formatting
#### Linting with ESLint
In root directory:
```shell
pnpm lint
```#### Fix styling issues
In root directory:
```shell
pnpm prettier:fix
```#### Check for formatting issues
In root directory:
```shell
pnpm prettier:check
```### Building and publishing
#### Building packages
In root directory:
```shell
pnpm build
```#### Building documentation
In root directory:
```shell
pnpm docs
```This builds a static documentation page to `/docs` using [`fliegdoc`](https://github.com/fliegwerk/fliegdoc).
#### Publishing packages
**After adjusting package versions (TODO: find a way to automate this):**
In root directory:
```shell
pnpm publish -r
```- package versions in subpackages' `package.json` files get replaced automatically in the published version
- requires a clean git tree## TODO
- Find a way to use conventional commits for automatically adjusting package versions