tajo / ladle

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

ladle build gives filenotfound error for typings-for-build tsconfig file #408

Closed arjunindia closed 1 year ago

arjunindia commented 1 year ago

Describe the bug

on running npx ladle build, an error is thrown:


> react-pewpew@1.0.5 build-ladle
> ladle build

FileNotFoundError: File not found: F:/htmlcss/react-pewpew/node_modules/@ladle/react/typings-for-build/app/tsconfig.json
    at RealFileSystemHost.getFileNotFoundErrorIfNecessary (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:1970:50)
    at RealFileSystemHost.readFileSync (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:1892:24)
    at TransactionalFileSystem.readFileSync (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:2468:32)
    at TsConfigResolver.getTsConfigFileJson (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:3048:38)
    at TsConfigResolver.decorator (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:2874:46)
    at TsConfigResolver.parseJsonConfigFileContent (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:3044:70)
    at TsConfigResolver.decorator (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:2874:46)
    at TsConfigResolver.getCompilerOptions (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:3013:21)
    at TsConfigResolver.decorator (F:\htmlcss\react-pewpew\node_modules\@ts-morph\common\dist\ts-morph-common.js:2874:46)
    at getTsConfigCompilerOptions (F:\htmlcss\react-pewpew\node_modules\ts-morph\dist\ts-morph.js:20124:111) {
  path: 'F:/htmlcss/react-pewpew/node_modules/@ladle/react/typings-for-build/app/tsconfig.json',
  code: 'ENOENT'
}
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open 'F:\htmlcss\react-pewpew\build\meta.json'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'F:\\htmlcss\\react-pewpew\\build\\meta.json'
}

Node.js v18.15.0

Environment

saisandeepvaddi commented 1 year ago

Happening on macOS as well with 2.11.1

tajo commented 1 year ago

Happening on macOS as well with 2.11.1

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

saisandeepvaddi commented 1 year ago

Yes. Still same issue with 2.12.0 :(

Here's the repo I'm using it for https://github.com/saisandeepvaddi/ant-table-extensions/blob/2.0/package.json#L70

macOS Ventura 13.3.1 M2 Pro

AlesMarz commented 1 year ago

I had the same issue and found that my Vite configuration caused the problem. I have custom Build Options configured and once I put those in comments it solved the issue.

What you could try is to create a second (empty) Vite configuration file:

import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({});

Then run your ladle build with the --viteConfig option set. ladle build --viteConfig ./vite-ladle.config.ts

shulcsm commented 1 year ago

Seems to be caused by vite-plugin-dts, but vite build works just fine.

tajo commented 1 year ago

not really tracking this as a bug since the root cause is vite-plugin-dts (or that's the repro we have so far)