Я пытаюсь использовать ссылки на проекты Typescript между 2 проектами: client
и shared
процесс client/tsc -b
завершается успешно. но при импорте shared
файлов во время выполнения происходит сбой.
структура проекта очень проста:
./client
./client/tsconfig.json
./client/src
./client/src/app-load.tsx
./shared
./shared/tsconfig.json
./shared/src
./shared/src/validation-utils.ts
содержимое . / client / tsconfig. json
{
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"jsx": "react",
"outDir": "build",
"rootDir": "src",
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"preserveConstEnums": true,
"sourceMap": true,
"skipLibCheck": true,
"types": ["react", "react-native", "jest"],
"paths": {
"@shared/*": [
"../shared/src/*"
]
}
},
"compileOnSave": false,
"exclude": ["android", "App.js", "ios", "build", "node_modules"],
"references": [{
"path": "../shared"
}]
}
содержимое . / Shared / tsconfig. json
{
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"rootDir": "src",
"outDir": "build",
"baseUrl": "src",
"composite": true,
"declaration": true,
"declarationMap": true,
},
"references": []
}
импорт используется в . / client / src / app-load.tsx
import { isEmailValid } from "@shared/validation-utils";
сообщение об ошибке во время выполнения
Невозможно разрешить "@ shared / validation-utils" из "build / app-load. js" Не удалось построить JavaScript bundle.
Я также пытался заменить rootDir
в client/tsconfig.json
с
"include": [
"src/**/*",
"../shared/**/*"
],
, как видно по другим вопросам, все еще безуспешно.
кто-нибудь понял, что я делаю не так?