我有一个使用package.json文件的 TypeScript React 组件(参见屏幕截图),我运行tsc以将其转换为我dist文件夹中的es5,但该package.json文件没有被复制。请注意,在屏幕截图中,我手动将其复制到dist文件夹中。
所以我的问题是:有没有办法通过tsc/tsconfig...来做到这一点,而不必添加复制脚本(通过 运行yarn build)。因为我希望在运行时也能更新tsc --watch
此外,我不希望在组件文件夹中将我的 Component.tsx 重命名为 index.tsx。我不想在我的项目中有 200 个 index.tsx 文件并且使用package.json'smain允许我拥有import SomeComponent from './components/SomeComponent'而不是这样做import SomeComponent from './components/SomeComponent/SomeComponent'很棒。
这是我的tsconfig文件:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"outDir": "dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"declaration": true,
"jsx": "react"
},
"include": ["src"]
}
非常感谢您的时间和您的帮助或建议。
