我在使用 SystemJS 和 ES 导入语法时导入 Angular2 组件时遇到问题。
项目结构:
ROOT
|_src
|_client
|_app
|_frameworks
|_il8n
|_analytics
|_main
|_components
|_pages
|_utility
假设我有一个文件:ROOT/src/client/app/frameworks/il8n/language-service.ts
和另一个文件:ROOT/src/client/app/main/pages/login/login.ts
。在 login.ts 中,我想导入 language.ts,所以一种方法是这样的:
//login.ts
import { LanguageService } from '../../../../frameworks/il8n/language-service';
另一种方法是使用桶,如下所示:
//login.ts
import { LanguageService } from '../../../../frameworks/index';
where frameworks/index.ts
是在做export * from './il8n/language-service';
我不想做../../../
每次我需要导入东西时等等;如果我能做就好了import { LanguageService } from 'frameworks';
到目前为止,我已经能够使用 SystemJS 来让我的构建过程正常工作“地图”选项 https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#map像这样:
map: {
frameworks: 'src/client/app/frameworks/index',
components: 'src/client/app/main/components/index',
pages: 'src/client/app/main/pages/index'
}
然而,每当我执行以下操作时,我的 IDE 都会抱怨(所有 IntelliSense 功能都完全损坏):
`import { LanguageService } from 'frameworks';`
这是我的 tsconfig.json 文件:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"pretty": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noFallthroughCasesInSwitch": true,
"baseUrl": "./src",
"paths": {
"frameworks": ["client/app/frameworks"],
"components": ["client/app/main/components"],
"pages": ["client/app/main/pages"],
"utility": ["client/app/main/utility"]
}
},
"compileOnSave": false
}
有没有办法同时满足我的 IDE 和 SystemJS 构建配置,以便我可以进行“简单”导入?