【发布时间】:2017-02-28 18:15:43
【问题描述】:
我发现我正在慢慢地挖自己的坟墓,因为我的文件夹结构越深,每次需要从根组件导入模块时,我必须越往后走:
import {ComponentsModule, SharedModule} from '../../../../../../shared';
由于该视图也有子视图,因此它会变得更长。
我查看了this question,这表明到目前为止,Angular 2 无法做到这一点。然而,这对我来说似乎很奇怪,以至于没有办法实现这样的目标:
import {ComponentsModule, SharedModule} from 'src/app/shared';
这是将来会出现的功能,还是已经可能以某种方式实现?
编辑:根据@Sasxa 的建议,我这样做了:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": [
"*"
]
},
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
但是现在,当我尝试启动 Angular CLI 时,我得到了一大堆错误,主要是这些:ERROR in Entry module not found: Error: Recursion in resolving 和 ERROR in multi main Module not found: Error: Recursion in resolving。
有什么遗漏吗?
【问题讨论】:
-
几个月前我一直在研究这个问题,可以通过制作导出东西的节点模块(有点像你从'@angular'导入)。我发现了这个:github.com/Microsoft/TypeScript/issues/5039,它接缝了一些选项已添加到
tsconfig。我也得研究一下(;
标签: angular typescript import