Skip to content

Commit 25363e2

Browse files
committed
chore: add yalc for local package linking and development workflow
1 parent 8f4a4dc commit 25363e2

5 files changed

Lines changed: 288 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ packages/imagekit-editor/*.tgz
2020
builds
2121
packages/imagekit-editor/README.md
2222
.cursor
23-
coverage
23+
coverage
24+
.yalc
25+
yalc.lock

DEVELOPMENT.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Development
2+
3+
## Prerequisites
4+
5+
- Node.js v20 (use `nvm use`)
6+
- Yarn 4 (via Corepack)
7+
- [yalc](https://github.com/wclr/yalc) (included as a devDependency)
8+
9+
## Getting Started
10+
11+
```bash
12+
nvm use
13+
yarn install
14+
yarn dev
15+
```
16+
17+
`yarn dev` runs vite in watch mode and **automatically publishes `@imagekit/editor` to the local yalc store** on every rebuild.
18+
19+
## Linking to External Projects
20+
21+
Use yalc to test `@imagekit/editor` in any project outside this monorepo:
22+
23+
### 1. Start dev mode (this repo)
24+
25+
```bash
26+
yarn dev
27+
```
28+
29+
This watches for source changes, rebuilds, and runs `yalc publish --push` automatically after each build.
30+
31+
### 2. Install yalc globally (required for consuming projects)
32+
33+
```bash
34+
npm i -g yalc
35+
```
36+
37+
### 3. Link in your consuming project
38+
39+
```bash
40+
# In your external project directory
41+
yalc link @imagekit/editor
42+
```
43+
44+
This creates a symlink to the yalc store. Every time the editor rebuilds, your project receives the update automatically via `--push`.
45+
46+
### 4. Remove the link when done
47+
48+
```bash
49+
# In your external project directory
50+
yalc remove @imagekit/editor
51+
```
52+
53+
## Build
54+
55+
```bash
56+
yarn build
57+
```
58+
59+
Produces the production bundle in `packages/imagekit-editor/dist/`.
60+
61+
## Package
62+
63+
```bash
64+
yarn package
65+
```
66+
67+
Creates a `.tgz` tarball in `builds/` for manual distribution or testing.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"lint-staged": "^16.1.2",
4141
"shx": "^0.4.0",
4242
"turbo": "^2.0.1",
43-
"vitest": "^2.1.9"
43+
"vitest": "^2.1.9",
44+
"yalc": "^1.0.0-pre.53"
4445
},
4546
"packageManager": "yarn@4.9.2",
4647
"lint-staged": {

packages/imagekit-editor-dev/vite.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1+
import { execSync } from "node:child_process"
12
import * as path from "node:path"
23
import react from "@vitejs/plugin-react"
3-
import { defineConfig } from "vite"
4+
import { defineConfig, type Plugin } from "vite"
45
import dts from "vite-plugin-dts"
56

7+
function yalcPublish(): Plugin {
8+
const editorPkgDir = path.resolve(__dirname, "../imagekit-editor")
9+
return {
10+
name: "vite-plugin-yalc-publish",
11+
closeBundle() {
12+
try {
13+
execSync("yalc publish --push --changed", {
14+
cwd: editorPkgDir,
15+
stdio: "inherit",
16+
})
17+
} catch (e) {
18+
console.error("[yalc] publish failed:", e)
19+
}
20+
},
21+
}
22+
}
23+
624
// https://vitejs.dev/config/
725
export default defineConfig({
826
plugins: [
@@ -15,6 +33,7 @@ export default defineConfig({
1533
exclude: ["node_modules", "lib"],
1634
outDir: "../imagekit-editor/dist/types",
1735
}),
36+
yalcPublish(),
1837
],
1938
test: {
2039
globals: true,

0 commit comments

Comments
 (0)