tajo / ladle

🥄 Develop, test and document your React story components faster.
https://www.ladle.dev
MIT License
2.63k stars 93 forks source link

`tsconfig` paths not works #417

Closed donrsh closed 1 year ago

donrsh commented 1 year ago

Describe the bug

Hi. I just tried to upgrade @ladle/react from v2.4.5 to v2.11.1, and met this problem:

image

My project is a nx monorepo, and ladle is an app. @/... is actually a lib consumed by other apps. With the tsconfig:

"compilerOptions": {
    "paths": {
      // align with apps tsconfig
      "@/*": ["../app-shared/*"],
    },
    "include": [
      "**/*",
      "./.ladle/**/*",
      "../app-shared/**/*",
    ]
  },

it worked quite well originally.

Looking up release logs, I wonder the problem has something to do with this patch?

Environment

tajo commented 1 year ago

Are you using yarn pnp? If so, 2.11.1 disables vite-tsconfig-paths in pnp environment. We had some issues with it in our internal monorepo but it might be specific to our (pretty complicated) setup. You can add it back by creating your own vite.config.js.

donrsh commented 1 year ago

Nope, I don't. But I do have customized vite.config.ts for configuring pubicDir. Might it be the cause?

// vite.config.js
/**
 * @type  {import("vite").UserConfig}
 */
export default {
  publicDir: "public",
};
tajo commented 1 year ago

publicDir should not be related

Can you reproduce it with https://ladle.dev/new?

donrsh commented 1 year ago

Hi, my case is less simpler, so I made some extractions to demo the issue: https://github.com/donrsh/issue-ladle-tsconfig-path-not-work.

Also I added some description to describe the issue in the README. Thanks!

tajo commented 1 year ago

it got broken by updating vite-tsconfig-paths@3.6.0 to vite-tsconfig-paths@4.0.0

going to pin it down in Ladle to 3.6.0

in meantime, you can fix your setup by adding this into package.json

"resolutions": {
  "vite-tsconfig-paths": "3.6.0"
},