[question] How to use platform specific code in libs?
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- build-system, tooling
调研方向
从 libs/nativescript-utils/src/index.ts 和平台特定文件开始,然后将库的 tsconfig.json 和 tsconfig.lib.json 与各 app 的 tsconfig.app.json 进行比较。重现 TypeScript 编译中缺少文件的错误,并追踪哪个配置控制库文件的包含。完成的标准是从库中导入时,.ios.ts 和 .android.ts 两个实现都能编译。
由索引模型根据 Issue 内容生成。
描述
It's me again :)
This time it's a question on how to do platform specific code in the libs. Here's my current issue:
I have these files under libs/nativescript-utils:
- src/lib/nativescript-utils.d.ts
export function nativescriptUtils(): string;
- src/lib/nativescript-utils.android.ts
- src/lib/nativescript-utils.ios.ts
- src/index.ts
export * from './lib/nativescript-utils';
Then I import the nativescriptUtils() in the app. When running the app I get this error:
ERROR in ../../libs/nativescript-utils/src/lib/nativescript-utils.ios.ts
Module build failed (from ../../node_modules/@ngtools/webpack/src/index.js):
Error: /Users/frank/git/private/nx-mobile-test/libs/nativescript-utils/src/lib/nativescript-utils.ios.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at /Users/frank/git/private/nx-mobile-test/node_modules/@ngtools/webpack/src/ivy/loader.js:64:26
@ ../../libs/nativescript-utils/src/index.ts 1:0-41 1:0-41
@ ./src/features/home/components/home.component.ts 2:0-71 12:41-58
@ ./src/features/home/home.module.ts 5:0-50
@ ./src/app.routing.ts 15:28-65
@ ./src/app.module.ts 3:0-49 10:89-105
@ ./src/main.ts 6:0-41 11:69-78
I did the same exercise under apps, d.ts + ios.ts + android.ts + index.ts -> same issue -> solved it by adding "**/*.ios.ts" to includes in tsconfig.app.json. But no matter what I do in the libs and tsconfig.json or tsconfig.lib.json, it's not being picked up.
Do you have any tips on how to fix this?
- 主要语言
- TypeScript
- 星标
- 68
- 派生
- 15
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/nx 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 65/100
NativeScript/nx#88 ·
-
难度 3/5 1-2 天 新手友好度 30/100
NativeScript/nx#84 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
NativeScript/nx#80 ·
-
难度 4/5 3-5 天 新手友好度 25/100
NativeScript/nx#78 ·
-
难度 4/5 3-5 天 新手友好度 35/100
NativeScript/nx#76 ·
相似的 Issue
-
comp/dashboard P3 type/bug
难度 2/5 1-3 小时 新手友好度 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
难度 2/5 1-3 小时 新手友好度 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 76/100
-
code-quality refactoring
难度 2/5 1-3 小时 新手友好度 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
难度 2/5 1-3 小时 新手友好度 74/100
langchain-ai/deepagents#6450 ·