Skip to content

Commit fe10758

Browse files
authored
Update instructions to use yalc (#8124)
1 parent 86f783d commit fe10758

2 files changed

Lines changed: 33 additions & 21 deletions

File tree

DEVELOPMENT.md

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,54 @@ This will alter the bundler to only emit non-minified esm modules. The aliasing
2727
2828
> Note: The build will be finished when the terminal displays: `[20xx-xx-xx 00:00:00] waiting for changes...`.
2929
30-
You will now `cd` into the `primereact/dist` directory and run:
30+
This will create a local copy of the package that is used instead of the registry version.
31+
Unlike `npm link`, `yalc` does not use symlinks, which avoids common module resolution issues.
3132

32-
```shell
33-
~/primereact/dist/ $ npm link
34-
```
33+
### Open a new terminal and navigate to the `primereact/dist/` directory
3534

36-
This will create a symlink in your global npm scope so that other local packages will rely on this version of primereact when built. You can verify that the package is linked by running this from the `primereact` directory.
37-
38-
```shell
39-
~/primereact/ $ npm ls -g --depth=0 --link=true
35+
Run yalc publish
4036

41-
/opt/homebrew/lib
42-
└── primereact@XX.X.XX -> ./../../../Users/${user}/primereact/dist # <-- this must be in the dist/ dir !!!
37+
```shell
38+
~/primereact/ $ cd dist
39+
~/primereact/dist/ $ npx yalc publish
4340
```
4441

45-
> [!WARNING]
46-
> Reminder! The XX.X.XX version must be a [valid semantic version](https://docs.npmjs.com/about-semantic-versioning) that you are using in your local project
47-
4842
### Now change your directory to your local project you are developing on!
4943

5044
```shell
5145
~/primereact/dist/ $ cd ~/my-cool-project
5246
~/my-cool-project/ $
5347
```
5448

55-
The goal now is to link your primereact dependency to the symlink that we configured earlier:
49+
The goal now is to link your primereact dependency to the yalc package that we configured earlier:
5650

5751
```shell
58-
~/my-cool-project/ $ npm link primereact
52+
~/my-cool-project/ $ npx yalc add primereact
5953
```
6054

6155
As long at the dependencies version that you symlinked satisfies the version that is specified in `my-cool-project/package.json` then the link should have worked.
6256

6357
You can validate that by running:
6458

6559
```shell
66-
~/my-cool-project/ $ npm ls --link=true
60+
~/my-cool-project/ $ npx yalc check
61+
62+
Yalc dependencies found: [ 'primereact' ]
63+
```
64+
65+
After doing your changes in the `primereact/` directory, you can publish the changes to your local project by running:
66+
67+
```shell
68+
~/primereact/dist/ $ npx yalc push
69+
```
6770

68-
my-cool-project@0.0.0 /Users/${user}/my-cool-project
69-
└── primereact@npm:dist@xx.x.xx -> ./../../primereact/dist # <-- this must be in the dist/ dir !!!
71+
## Live Development
72+
If you want to push your changes automatically to your local project, you can use the following:
73+
74+
```shell
75+
~/primereact $ npm run dev:link -- -- --watch.onEnd="cd dist && npx yalc push"
7076
```
77+
This command will watch for changes in the `primereact/` directory and automatically push updates to your local project whenever you save a file. (note the double -- before `watch.onEnd`)
7178

7279
### Congratulations!
7380

@@ -78,5 +85,10 @@ You can now live develop in the `primereact/` directory and your changes should
7885
Once done, you can clean up with:
7986

8087
```shell
81-
~/primereact/ $ npm unlink
88+
~/my-cool-project/ $ yalc remove primereact
89+
~/my-cool-project/ $ rm -rf yalc.lock .yalc
90+
~/my-cool-project/ $ npm install primereact@latest
8291
```
92+
93+
> Note: `yalc` stores the published package in `~/.yalc/primereact` and uses file references in your project.
94+
> This avoids typical pitfalls of `npm link`, such as duplicated React versions or broken module scopes.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"build:lib": "NODE_ENV=production INPUT_DIR=components/lib/ OUTPUT_DIR=dist/ npm run build:package",
1010
"build:lib:windows": "set \"NODE_ENV=production\" && set \"INPUT_DIR=components/lib/\" && set \"OUTPUT_DIR=dist/\" && npm run build:package",
1111
"build:package": "npm run build:check && rollup -c && gulp build-resources && npm run build:api",
12-
"dev:link": "NPM_LINK=true NODE_ENV=production INPUT_DIR=components/lib/ OUTPUT_DIR=dist/ npm run build:package:dev",
13-
"dev:link:windows": "set \"NPM_LINK=true\" && set \"NODE_ENV=production\" && set \"INPUT_DIR=components/lib/\" && set \"OUTPUT_DIR=dist/\" && npm run build:package:dev",
12+
"dev:link": "NODE_ENV=production INPUT_DIR=components/lib/ OUTPUT_DIR=dist/ npm run build:package:dev",
13+
"dev:link:windows": "set \"NODE_ENV=production\" && set \"INPUT_DIR=components/lib/\" && set \"OUTPUT_DIR=dist/\" && npm run build:package:dev",
1414
"build:package:dev": "npm run build:check && gulp build-resources && npm run build:api && rollup -c --watch",
1515
"build:api": "npm run apiwebtypes && npm run apidoc",
1616
"build:check": "npm run lint && npm run format:check && npm run type:check && npm run security:check",

0 commit comments

Comments
 (0)