|
| 1 | +--- |
| 2 | +sidebar: auto |
| 3 | +--- |
| 4 | + |
| 5 | +# Local Development |
| 6 | + |
| 7 | +## Informations |
| 8 | + |
| 9 | +If you here youh may be intereset of improve core vuepress. |
| 10 | + |
| 11 | +Vuepress is using a combo with [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) and [Lerna](https://github.com/lerna/lerna). |
| 12 | + |
| 13 | +## Init packages |
| 14 | + |
| 15 | +```bash |
| 16 | + yarn bootstrap // it will run and install into the root all packages subfolders |
| 17 | +``` |
| 18 | + |
| 19 | +yarn bootstrap will use hoisting. What it mean for you ? |
| 20 | + |
| 21 | +It will regroup all dependencies in the workspace root and link all packages. |
| 22 | + |
| 23 | +to check the link you can run |
| 24 | + |
| 25 | +```bash |
| 26 | + ls -la node_modules/@vuepress |
| 27 | +``` |
| 28 | + |
| 29 | +You will all symlinks |
| 30 | + |
| 31 | +:::warning |
| 32 | +You have to take care to declare all dependencies inside subFolders package.json. When publish the lib if dependencie from a package is not declare it will just not work. |
| 33 | +::: |
| 34 | + |
| 35 | +:::warning |
| 36 | +There is a special package you should have a look is @vuepress/shared-utils that are in typescript. |
| 37 | +::: |
| 38 | + |
| 39 | +After install everything it will run `yarn tsc`. This command will tell to @vuepress/shared-utils workspace to compile his js. |
| 40 | + |
| 41 | +:::warning |
| 42 | +From here if you are making change inside this package you will have to |
| 43 | +run `yarn tsc` all the time or run in separate shell `yarn run tsc -w`. This will re run tsc at any change from shared-utils |
| 44 | +::: |
| 45 | + |
| 46 | +## Link |
| 47 | + |
| 48 | +Good from here you have everything ready. You need to link vuepress to your project. |
| 49 | + |
| 50 | +```bash |
| 51 | +yarn register-vuepress |
| 52 | +``` |
| 53 | + |
| 54 | +You will have something like this: `success Registered "vuepress".` |
| 55 | + |
| 56 | +It will link the package vuepress from packages/vuepress. So you will have access to vuepress cli and vuepress packages. |
| 57 | + |
| 58 | +they are decalre in the `packages/vuepress/package.json` |
| 59 | + |
| 60 | +```js |
| 61 | +{ |
| 62 | +"main": "index.js", |
| 63 | +/// |
| 64 | +"bin": { |
| 65 | + "vuepress": "cli.js" |
| 66 | + } |
| 67 | + /// |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +Now go to your project and run `yarn link vuepress`. |
| 72 | + |
| 73 | +You should have it `success Using linked package for "vuepress".` |
| 74 | + |
| 75 | +## Unlink |
| 76 | + |
| 77 | +You may want to unlink everything. For it in the workspace root folder. Run |
| 78 | + |
| 79 | +```bash |
| 80 | +yarn unregister-vuepress |
| 81 | +``` |
| 82 | + |
| 83 | +Now you can run `yarn unlink vuepress` into your project folder. |
| 84 | + |
| 85 | +If everything work properly you should have an error telling you there is no package found called vuepress, if you run `yarn link vuepress` in you project folder. |
| 86 | + |
| 87 | +## BUGS / QA |
| 88 | + |
| 89 | +You will maybe find some difficulty with link. If you encounter something like `There's already a package called "vuepress" registered`. |
| 90 | +You have already vuepress registered. so: |
| 91 | + |
| 92 | +- if you already link vuepress from [Link](#link). It's totally fine. If you make changes because it is symlink you dont have to re run something. You will have to rerun yarn tsc if you update shared-utils package. Nothing more |
| 93 | +- if you have done nothing. You have already vuepress linked somewhere. What you have to do is to delete folder where you already run `yarn link` or run `yarn unlink` inside it. |
| 94 | + |
| 95 | +## More |
| 96 | + |
| 97 | +You will have interesting commands available: |
| 98 | + |
| 99 | +- `yarn packages:list` will list you every packages present and their versions [More...](https://github.com/lerna/lerna/tree/master/commands/list#readme) |
| 100 | +- `yarn packages:changed` will tell you which package will be affect by the next lerna publish / version [More...](https://github.com/lerna/lerna/tree/master/commands/changed#readme) |
| 101 | +- `yarn packages:diff` will show you all diff from last release [More...](https://github.com/lerna/lerna/tree/master/commands/diff#readme) |
0 commit comments