Wonderjar's Blog

Yarn Workspace

2019-07-04

Structure
Root

  • A
  • B
  • C

Root package.json

1
2
3
4
5
6
"private": true,
"workspaces": [
"A",
"B",
"C"
],

A package.json

1
2
3
4
"name": "A",
"dependencies": {
"cross-env": "5.0.5"
}

B package.json

1
2
3
4
"name": "@XXX/B",
"dependencies": {
"cross-env": "5.0.5",
}

C package.json

1
2
3
4
5
"dependencies": {
"cross-env": "5.0.5",
"A":"*",
"@XXX/B": "*"
}

C

1
2
import Foo from 'A/src/index.js'
import Bar from '@XXX/B/src/index.js'