code-chunks / angular2-logger

A log4j inspired logger for angular 2.
MIT License
144 stars 41 forks source link

Add field "typings" to package.json #67

Closed k7sleeper closed 8 years ago

k7sleeper commented 8 years ago

With version 0.4.x package.json's field main points to the right file! Thank you very much!

So, we have the possibility to write

import { Logger } from "angular2-logger";

Yes, I know, that's not the documented way to import this library but that's the purpose of the main field. For importing angular2-logger from TypeScript a typings field is also needed to make the above mentioned package import possible.

If you agree, I can send a PR.

langley-agm commented 8 years ago

Hi @k7sleeper,

If you use import { Logger } from "angular2-logger"; I cannot assure you it won't break in the future. Right now core is the only module, but there will be more, so I don't want to make the above mentioned package import possible. Doing it this way you'll risk to need a refactor later on.

k7sleeper commented 8 years ago

Ah, I understand.

In future it could be possible that more than one root module will be offered by package angular2-logger. Your're right, if that's the case than typings does not make sence, but main also, does it?

So, in my opinion, if you have a main field in package.json you should also have a typings field, or you dont have both.

langley-agm commented 8 years ago

I don't think there could be more than one root module.

The main field exists long time before the typings field, it is not dependant on it.

k7sleeper commented 8 years ago

Well, if you support package loading at runtime (by providing a main attribute (I appreciate it!)), it's merely consequent to provide the package API information at compile time (set the typings attribute). Otherwise, package loading support is half-hearted, or rather locks out TypeScript developers from using the offered package loading support. Native JS scripts can load angular2-loggerpackage today, why not also support TypeScript code to be able to do the same?