-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for bundling without a main module #29
Comments
Yes Angular2 don't have a .d.ts bundle, it use the compiler generated .d.ts files directly. What criteria should be taken to know that we have to create files .d.ts? If I had a large project and I would like to use several .d.ts files, I would use the compiler .d.ts generated files, and write some small bundles manually where I would export the required information: Small bundle example that I use on Ng2Emulation project export * from "./Decorators/Component";
export * from "./Decorators/Directive";
export * from "./Decorators/Inject";
export * from "./Decorators/Injectable";
export * from "./Events/EventEmitter";
export * from "./Core/Bootstrap";
export * from "./Decorators/Output";
export * from "./Decorators/Input";
export {OnChanges, OnInit, OnDestroy} from "./Core/LifeCycle/LifeCycleHooks"; |
For example, the dts-generator project, you dont have to specify a main.d.ts, you point to a folder and it creates a bundle, with every file it finds. The problem is if you want to filter. But I think that if you would like to filter and export files interfaces only, you would probably have a main.d.ts. But even if you do have a main, since importing a module is just importing a file, you could potentially import any file on any folder that exports something, even though you dont have a d.ts many one option could be to install from a main, just like now, or to install from a folder. How would one install angular2 with typings install , if there is no index.d.ts ? |
If you have a large project and you want to import some parts of your project you can use the typescript compiler generated .d.ts files separatelly. Imagine a project called // world/car.ts
export class Car {}
// world/animal.ts
export class Animal{}
// world/human.ts
export class Human {} if you want to use classes separately you can use the .d.ts files generated by typescript compiler, and you can use this way: import {Car} from "world/car"
import {Animal} from "world/animal"
import {Human} from "world/human" If you want to group your exports you should create a .ts file grouping it, for example: // world/alive.ts
export * from "world/animal"
export * form "world/human" Then use it this way: import {Animal, Human} from "world/alive" At last you can group all on a file // world/world.ts
export * from "world/animal"
export * from "world/car"
export * form "world/human" You can use Ok, @siulung4073 Perhaps I don't understand your question, if you are from Argentina and speak spanish you can send me a spanish e-mail to tolemac[at]jros.org to clarify this issue. |
I understand the uses of your examples and I know is possible to do it that Maybe I have to clarify something important. The problem with the d.ts Lets imagine you have a npm/bower/jspm package, and you want to use that in So if that package has a main.d.ts file you can use dts-bundle to generate So to recap, imagine you are the owner of the angular2 package and you On Wed, Jan 13, 2016 at 10:09 AM Javier Ros [email protected]
|
I understand that one could create a function to find every d.ts file, and On Wed, Jan 13, 2016 at 10:36 AM Matias Ribichich [email protected]
|
Ok @siulung4073, I understand you. Thanks for your time explain me the issue. |
I have implemented a "hack", see readme. |
great! seems cool! I'll try it out and let you know |
You have to git clone the master branch to test it.
Good luck! |
Close this issue to release 0.4.0 where you can include all files from a path, see "All .d.ts files" section of readme file. Let me know here if you have problems. |
@tolemac, did you manage to generate an angular2.d.ts with all definitions in it? I could create a bundled d.ts file but it is not compiling... |
I suppose the compiler can't find external references as promises, maps, ... Can you post here the compile error messages? |
Lots of |
Sorry, this image tell me nothing ... |
The problem is, that the imports are still relative:
In this sample code, the type If you transform the relative imports to absolute module names before bundling, then I think the bundled output would work: Single d.ts (before bundling)
Bundled d.ts (after bundling):
Just use the d.ts file path to convert the relative import to an absolute one. Is this possible to implement? |
You don't need to generate .d.ts to use Angular 2 in Visual Studio. You don't need dts-bundle. You are in the wrong way. |
Sometimes you just want to export a couple of modules but with their interfaces, separately, and from one file. probably something like gts-generator project does it.
One example is the angular2 project they dont have a main module. You always have to import from 'angular2/....' something.
thanks!
The text was updated successfully, but these errors were encountered: