-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
chore(build): solve initial .d.ts pain #128
Comments
known issue with configuration |
please update me if my advise helped |
Already had This was becomes more of a pain in 1.0.2.beta-1 because moment is a dependency that won't be found by This is my existing tsconfig.
Angular2 takes the approach of moving the .ts files to ts/ in its published module. Rxjs does not provide the source .ts files in its published modle. The Rxjs approach would be easier as it would only require an entry in the .npmignore -- but it seems like the Angular2 approach (ts/) is "more better". If your open to the Angular2 approach I can add a |
dirty hacks, both >.< |
and moment yes, I should somehow remove the initial pain with |
need to check date pipe, may be I will be able to reuse it somehow for data parsing |
oh, btw |
I am not sure I understand your dislike to moving the source to ts/ in the npm package? Why does it seem like a hack? I am only asking for the sake of understanding. It is natural that tsc would resolve references to the .ts rather than the .d.ts -- which it does. This makes it problematic to include both in the same path. It seems there are three flavors of npm packages generated from typescript:
The last option is a bad idea outright. The first approach would be fine in most situations. The middle approach is the most flexible. Developers could still step through the ts if they wished. The map files in the dev bundles can point to the node_modeles/ng2-bootstrap/ts/ path. Moving the source to ts/ should be a npm publish step only. The directory structure of the source code shouldn't change. |
Yesterday I tried to add ng2-bootstrap to our project. But as soon as I imported anything from ng2-bootstrap/ng2-bootstrap the typescript compiler throw some errors. It took me some hours to figure out that the problem is that typescript definition files and source files are in the same folder in node_modules. This is my tsconfig:
When I run tsc I get this error:
This error repeats for all components. When I remove the
For now I created a script that moves the ng2-bootstrap source ts files to a different location. But I hope you can move it to another location by default in the next release. |
ok, I agree that as for now there are should be some hack for tsc, |
in TS 1.8 there allowJs option microsoft/TypeScript#6725 so my plan is:
|
@valorkin if there is anything you would like a hand with let me know. I am willing to help sort this out. The work done in the project is superb and much appreciated. Some of us who have been working in TypeScript and Angular for years are heartened to see such quality libraries as this one for Angular2. A lack of choice in UI controls would easily be a friction point in adopting Angular2. We all appreciate the work that has gone into this project. I am not seeing the difficulty or hackishness of publishing segregated definitions and source to npm that you are. It is not a perfect analogy, but it may be helpful to think of the transpiled bundles as your object code and the d.ts definition files as the header files that provide the APIs, interfaces, to your bundles. So those the definitions and the bundles should be the "meat" of the npm package. Providing source in the package is fine -- but not essential. That is what github is for. Indeed going to the definition of a library is often useful. Stepping through a debugger and seeing source of a library is useful as well. That said, neither of these should be the default behavior as it violates the OOD principle of encapsulation. A library by definition should only expose a well designed interface (.d.ts) and not its implementation (.ts). Again -- there should be easy ways to see the source. For example change: |
yeap, may be you are right |
Thanks for kind words :) |
and to be honest, |
Stumbled into the same issue.
As a workaround I just removed all
|
how do you compile it? |
@martinmcwhorter do you have
in tsconfig? |
@valorkin yes. I have posted my tsconfig earlier in the thread. |
trying to understand why .js only version fails for webpack :) |
+1. Annoying node_modules folder appears in the outDir location for ng2-bootsrap only. |
yea, it is really annoying, came with ts 1.7.5 |
@valorkin Hi, this is very important, because I have to remove *.ts files via postinstall, which is not correct, but at least it works |
By the way. This is causing gulp-typescript to generate into the wrong destination folder. |
When compiling an application that does an import into ng2-bootstrap the compiler will default to the .ts rather than the .d.ts -- which causes the compiler to unnecessarily compile the ng2-bootstrap module.
This could be solved by moving the .ts files into src/ within the published npm module.
The text was updated successfully, but these errors were encountered: