網站搜尋

reactjs - typings/image.d.ts 和 cssmodule.d.ts 在 Vite 构建 NX 16.5 中未找到


目前行為

我已經從 create-react-app 遷移到 Vite。在本地運行應用程式和構建都正常,但當我嘗試通過 bitbucket 管道部署更改時,出現了這個錯誤。

Nx 版本:16.5.3

tsconfig.json

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "allowJs": false,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "types": ["vite/client", "vitest"]
  },
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ],
  "extends": "../../tsconfig.base.json"
}


tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "types": ["node", "vite/client"]
  },
  "files": ["../../node_modules/@nx/react/typings/cssmodule.d.ts", "../../node_modules/@nx/react/typings/image.d.ts"],
  "exclude": [
    "src/**/*.spec.ts",
    "src/**/*.test.ts",
    "src/**/*.spec.tsx",
    "src/**/*.test.tsx",
    "src/**/*.spec.js",
    "src/**/*.test.js",
    "src/**/*.spec.jsx",
    "src/**/*.test.jsx"
  ],
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}

tsconfig.spec.ts

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"]
  },
  "include": [
    "vite.config.ts",
    "src/**/*.test.ts",
    "src/**/*.spec.ts",
    "src/**/*.test.tsx",
    "src/**/*.spec.tsx",
    "src/**/*.test.js",
    "src/**/*.spec.js",
    "src/**/*.test.jsx",
    "src/**/*.spec.jsx",
    "src/**/*.d.ts"
  ],
  "files": ["../../node_modules/@nx/react/typings/cssmodule.d.ts", "../../node_modules/@nx/react/typings/image.d.ts"]
}

tsconfig.base.json

{
  "compileOnSave": false,
  "compilerOptions": {
     "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "Node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "ESNext",
    "module": "ESNext",
    "lib": ["ES2017", "DOM", "ES2018.Promise", "ESNext"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "resolveJsonModule": true,
    "jsx": "react-jsx",
    "allowSyntheticDefaultImports": true,
    "strictNullChecks": true,
  },
  "exclude": ["node_modules", "tmp"]
}

預期行為

tsconfig 應該能夠檢測 nodemodules 上 typings 的路徑

重現步驟

  1. 使用 Vite 打包器創建一個 nx react 應用程式
  2. 使用 Bitbucket 管道部署

Nx 報告

Node   : 20.4.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx (global)        : 16.5.3
   nx                 : 16.5.3
   @nx/js             : 16.5.3
   @nx/jest           : 16.5.3
   @nx/linter         : 16.5.3
   @nx/workspace      : 16.5.3
   @nx/cypress        : 16.5.3
   @nx/devkit         : 16.5.3
   @nx/eslint-plugin  : 16.5.3
   @nx/react          : 16.5.3
   @nrwl/tao          : 16.5.3
   @nx/vite           : 16.5.3
   @nx/web            : 16.5.3
   @nx/webpack        : 16.5.3
   nx-cloud           : 16.1.0
   typescript         : 5.1.6

失敗日誌

error TS6053: File '/nx-wspace/node_modules/@nx/react/typings/cssmodule.d.ts' not found.
  The file is in the program because:
    Root file specified for compilation
error TS6053: File '/nx-wspace/node_modules/@nx/react/typings/image.d.ts' not found.
  The file is in the program because:
    Root file specified for compilation
Found 2 errors.
 >  NX   Found type errors. See above.
Error: Found type errors. See above.
    at validateTypes (/node_modules/@nx/vite/src/utils/executor-utils.js:28:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async viteBuildExecutor (/node_modules/@nx/vite/src/executors/build/build.impl.js:34:9)

作業系統

  • [X] macOS

附加資訊

無回應