【发布时间】:2020-04-28 22:36:27
【问题描述】:
我有一个由 rush.js 控制的 monorepo,PNPM 作为包管理器。
我曾经将所有共享模块预编译为cjs、esm、dts 目标。但是这种方法有一些缺陷,所以我决定将它们保留为未触及的源,并将它们在package.json 中的主要条目设置为"main": "./src/index.ts|x"。
同时,我使用react-app-rewired 告诉Webpack 使用babel 只编译来自node_modules 的符号链接库,一切正常。 Jest 也很开心。
我遇到的问题是,当我出于某种原因运行tsc 时,编译器会深入到符号链接的本地包并报告很多问题(即使如果你运行他们的编译器,它们也没有任何问题tsc)。
TSForkWebpackPlugin 报告了 create-react-app 的类似问题,但我使用 reportFiles 配置选项使用 react-app-rewired 忽略了它们,并认为这是插件站点上的某种错误,但似乎不是。
我向 exclude 添加了各种 glob 模式,例如 **/node_modules/@namespace/** 和 node_modules/@namespace/** 和 node_modules/@namespace 这些都不起作用。
"skipLibCheck": true 也有。
我的tsconfig.json 供参考
{
"compilerOptions": {
"incremental": true,
"baseUrl": "src",
"downlevelIteration": true,
"lib": ["esnext", "dom", "dom.iterable"],
"module": "esnext",
"target": "esnext",
"sourceMap": true,
"allowJs": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "preserve",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true,
"noEmit": true,
"preserveSymlinks": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"strict": true
},
"exclude": [
"node_modules"
],
"include": ["src"]
}
【问题讨论】:
标签: typescript create-react-app symlink monorepo pnpm