SystemJS,Typescript,angular2和模块化
SystemJS, Typescript, angular2 and modularity
我正在尝试使用angular2/systemjs/typescript编写具有模块化的基本应用程序,并与Angular1一起使用,并且遇到了一些问题。
我需要在我的应用程序中的任何地方使用这个东西,而不依赖于文件的相对位置,其中smth-module
是我编写并包含(导出)SmthCmp
类的任何模块
import SmthCmp from 'smth-module';
测试应用结构
├── bootstrap.ts
├── graph-module
│ ├── component
│ │ └── line-graph
│ │ └── line-graph.ts
│ └── index.ts
└── page-module
├── component
│ └── page
│ └── page.ts
└── index.ts
引导程序.ts
...
import {PageCmp} from 'page-module/index';
bootstrap(PageCmp, [
...
]);
页面.ts
...
import {LineGraphCmp} from 'graph-module/index';
...
export class PageCmp {}
折线图.ts
...
export class LineGraphCmp {}
图形和页面模块索引如下所示
export {PageCmp} from './component/page/page';
也添加到 System.config()
map: {
'graph-module': '/graph-module',
'page-module': '/page-module'
}
所以我可以在任何地方使用export Smth from 'module/index'
语法,这几乎是我所需要的。但是有一个问题
app/bootstrap.ts(4,23): error TS2307: Cannot find module 'page-module/index'.
app/page-module/component/page/page.ts(8,28): error TS2307: Cannot find module 'graph-module/index'.
我怎样才能告诉打字稿编译器这个模块?或者我可以通过其他方式或模块系统来实现此模块的使用吗?
我也可以在没有直接"/index"引用的情况下以某种方式实现这种用法import {PageCmp} from 'page-module'
?
附言这是我在本次讨论中的最后一个问题的复制粘贴
这个问题完全是关于我的问题。等待使用moduleResolution: 'target'
的打字稿更新
https://github.com/Microsoft/TypeScript/issues/5039
相关文章:
- 聚合物是一个框架而不是一个库.如何模块化地使用web组件
- 使用Ampersand.js路由模块化应用程序
- 性能与模块化:将JS集成到PHP或单独的custom.JS中
- 将broccoliJS与当前使用requireJS的模块化主干应用程序结合使用,我想完全放弃requireJS
- 用于多个选项卡和模块化的knockoutjs设计模式
- 编写在浏览器和node.js中运行的模块化ECMAScript
- 模块化&重用使用ExtJS编写的代码
- 使用模块化CSS与Bootstrap 4和React
- 模块的TypeScript导入导出行为
- 构建模块化谷歌地图应用程序
- 模块化模块?需要父模块中的部分
- 为什么模块化幂函数在 Python 和 Javascript 中对于大数字的工作方式不同
- 模块化与性能与性能与角度应用程序中的ng-include
- 将变量传递给 Javascript 模块化模式方法
- JavaScript模块化和依赖注入之间的区别
- 无法模块化AngularJS应用程序
- 使用requirejs对延迟加载成员模块进行Typescript
- 模块化JS和原型继承
- 如何构建模块化的js承诺链
- SystemJS,Typescript,angular2和模块化