1 | When developing multiple packages locally, `jspm link` allows these local packages to be made available for installation through jspm.
|
2 |
|
3 | > There are some differences to standard linking workflows when linking with jspm, so its advisable to read these notes carefully.
|
4 |
|
5 | Linked packages are linked into a full registry, package and version name like `github:my/repo@dev`. Ideally this is the registry name that will be published so that linked packages can be replaced with their published counterparts easily.
|
6 |
|
7 | ### 1. Use `jspm link` to add a package to the global link cache
|
8 |
|
9 | ```
|
10 | cd my-local-package
|
11 | jspm link github:my/repo@dev
|
12 | ok Package linked.
|
13 | ```
|
14 |
|
15 | If you include the `name`, `registry` and `version` properties in the package.json, we don't need to provide the name when using `jspm link`:
|
16 |
|
17 | ```json
|
18 | {
|
19 | "name": "my/repo",
|
20 | "version": "dev",
|
21 | "registry": "github"
|
22 | }
|
23 | ```
|
24 | ```
|
25 | jspm link
|
26 | ok Package linked.
|
27 | ```
|
28 |
|
29 | Note that because registries apply arbitrary build operations to packages, and jspm also does some build operations, every code change to the local package requires `jspm link` be run again from that folder. A watch task could be set up to manage this, an issue for creating this project is being tracked at https://github.com/jspm/jspm-cli/issues/481.
|
30 |
|
31 | When linking over an existing package, jspm will ask to confirm the relink. Because this is a common workflow, it is advisable to use:
|
32 |
|
33 | ```
|
34 | jspm link github:my/repo@dev -y
|
35 | ```
|
36 |
|
37 | to auto-confirm this prompt.
|
38 |
|
39 | ### 2. Use `jspm install --link` to install a package from the global link cache
|
40 |
|
41 | ```
|
42 | cd my-jspm-app
|
43 | jspm install --link github:my/repo@dev
|
44 | ```
|
45 |
|
46 | The linked package will be symlinked into `jspm_packages`, and its dependencies will be installed down the tree.
|
47 |
|
48 | If linking packages that depend on eachother, start with the lowest in the dependency tree first.
|
49 |
|
50 | > If the package doesn't yet belong to a registry, it is also possible to link into the jspm registry itself with a name like `jspm link jspm:mypkg@dev`. Then this can be installed with `jspm install --link mypkg@dev`.
|
51 |
|
52 | ### 3. Use `jspm install --unlink` to replace a linked install with the published package
|
53 |
|
54 | ```
|
55 | jspm install --unlink github:my/repo@dev
|
56 | ```
|
57 |
|
58 | This will then replace the symlinked package with an installed version from the original repo on GitHub, undoing the linking operation. |
\ | No newline at end of file |