requireJs / TypeScript, combine multiple classes into a single module?

一笑奈何 提交于 2020-01-05 17:54:17

问题


How can I combine multiple files into a single module ? Say I have a folder with multiple typescript classes e.g.

app
  module1
    foo1.ts
    foo2.ts
    ....
    module1.ts

In any classes which uses any of the module1 defined classes, I would like to be able to include the dependencies using a single import like

import {Foo1, Foo2} from "./module1/module1"

rather than importing individual classes like

 import {Foo1} from "./module1/foo1"
 import {Foo2} from "./module1/foo2"

How can I do this ?


回答1:


Not sure if this is the correct way, but it seems to work for what I need in module1.ts simply define export for the classes

export * from "./foo1";
export * from "./foo2";


来源:https://stackoverflow.com/questions/36531127/requirejs-typescript-combine-multiple-classes-into-a-single-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!