6

I'm moving my projects to a monorepo with Lerna and yarn workspace. I managed to setup the basic stuffs but I'm stuck with this issue and can't find similar problem on the web.

As you can see on the image below I'm unable to make path alias intellisense working for the "current" package src. You know the one we declare like this in a normal project in tsconfig

"paths": {
    "@/*": [
        "src/*"
    ]
},

When I open directly the packages/pro-app folder in vscode it works fine, but when I open the root monorepo, I have this issue

alias issue

Webpack build works fine also

this is the <root>tsconfig.json

{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "strict": true,
        "strictNullChecks": false,
        "jsx": "preserve",
        "importHelpers": true,
        "moduleResolution": "node",
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "baseUrl": ".",
        "types": [
            "webpack-env",
            "jest"
        ],
        "lib": [
            "esnext",
            "dom",
            "dom.iterable",
            "scripthost"
        ]
    }
}

and packages/pro-app/tsconfig.json

{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "strict": true,
        "strictNullChecks": false,
        "jsx": "preserve",
        "importHelpers": true,
        "moduleResolution": "node",
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "baseUrl": ".",
        "types": [
            "webpack-env",
            "jest"
        ],
        "paths": {
            "@/*": [
                "src/*"
            ]
        },
        "lib": [
            "esnext",
            "dom",
            "dom.iterable",
            "scripthost"
        ]
    },
    "include": [
        "src/**/*.ts",
        "src/**/*.tsx",
        "src/**/*.vue",
        "tests/**/*.ts",
        "tests/**/*.tsx"
    ],
    "exclude": [
        "node_modules"
    ]
}

I tried different paths configs but I can't make it work :/

Is it still possible to use "@/*" alias in a monorepo ?

Or maybe I shouldn't open the monorepo in vscode ? juste package by package

Thank you

jeremy castelli
  • 1,232
  • 10
  • 26
  • 1
    Hey! Did you found any solution to this? – Tirias Jun 27 '21 at 18:25
  • 1
    hey ! yes, there is a workaround, not a direct solution. We can't just open the global folder, but create a multi-root workspace. https://code.visualstudio.com/docs/editor/multi-root-workspaces . Basically we need to add each package folder independently. – jeremy castelli Jun 28 '21 at 07:31

0 Answers0