Generate jsconfig.json allowing VSCode to "Open Definition" your Lerna packages.
$ npm i --save lerna-jsconfig
- Add a
jsconfig.json
to your Lerna root
{
"compilerOptions": {
"baseUrl": ".",
"paths": {}
}
}
- From inside your Lerna project:
$ npx --no-install lerna-jsconfig
lerna notice cli v3.4.3
lerna success found 13 packages
jsconfig.json was updated in Lerna root: /Users/username/repos/lerna-project-dir
{ compilerOptions:
{ baseUrl: '.',
paths:
{ '@project/comp-a': [Array],
'@project/comp-b': [Array],
'@project/comp-c': [Array] } } }
<lerna-root>/tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@project/comp-a": [
"./packages/comp-a/src/index.js"
],
"@project/comp-b": [
"./packages/comp-b/src/index.js"
],
"@project/comp-b": [
"./packages/comp-b/src/index.js"
]
}
}
}
$ npx --no-install lerna-jsconfig
- This will overwrite any existing
jsconfig.json
paths. - You MUST have a
jsconfig.json
in your Lerna root before running this. - You MUST have a
package.json
with amain
ormodule
entry point in thepackage.json
files for each or your packages.