-
Notifications
You must be signed in to change notification settings - Fork 204
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
Support compileOnSave
for --out
#206
Comments
_reference.ts
for javascript orderingfiles
for javascript ordering with --out
From @erikvullings : 1380a83#commitcomment-10394359 I've promised you an example of my project that uses the -out feature and
The attached project should generate a csComp.js file in the dist folder. Hope this helps. Cheers,
|
I don't recommend |
Hello First of all - Atom Typescript is fantastic, we've been looking into it as a cross platform alternative to visual studio. On the subject of I'm not sure removing support for it becuase it doesn't fit your personal use-case is the right thing to do. Namespaces suit our codebase, we don't want to use an external module loader and are quite happy with the level of control we get from ordering the combination from _references.ts. Do you think the decision to remove support for Cheers |
Thanks for the kind words 🌹 Note that I use
Agreed. That is why this issue is open for grabs ;)
The TypeScript team doesn't support
Please reconsider. I've spent a weekend at work at one point. Not saying you should spend a weekend but consider it a part of a future migration.
I am not removing it. Just warning that we don't have good support for it yet. The editor will work fine otherwise. |
I feel compelled to second @basarat here, for your own sake. 300+ and growing files with all manual dependency management is a house of cards just waiting to collapse. Take a couple days to fix it now for your own sake. :) |
@basarat Thanks for the reply.
This seems to be contrary to what I'm experiencing. See the screenshot below - it's an error that is generated, not a warning. The build no longer runs as it did in previous versions. @csnover With all respect, it's difficult for you to pass judgement on the best approach for our software development without knowing what kind of company we are, what the software does and the methodologies we employ in-house. Having dependency loading managed by our own code gives us greater control over a large development team. Cheers. |
@basarat @csnover I'm confused why you both would call
I prefer the |
I must say I prefer internal modules as well, though I prefer bundling on the back end in a build script rather than with
|
We're currently using I think all this proves is people have different preferences and different workflows. |
A decade of experience doing front-end development professionally, with about half that time consulting for many of the largest companies in the world, with big codebases and big development teams that get themselves into hell-level depths of trouble in part by doing things like hand-managing their thousand JavaScript file dependencies instead of using a module system with automatic dependency resolution. :) I’m not going to go crazy here to try to convince anyone of anything, just going to point out a couple things that maybe you haven’t considered and leave it at that:
It’s bad if you want to try to do a rolling upgrade/refactor (name conflict), or load an older and newer version of your app or a library in the same page (name conflict), or accidentally choose the same name as someone else (name conflict!). This happens more often than you might expect, especially if your company has several teams working independently and then someone decides to try integrating two independently written apps. Modules make it trivial to re-map identifiers at runtime so you can avoid conflicts no matter what happens in the future. Modules also guarantee that dead code (by static analysis of your dependency tree) can be safely removed; when you expose your code in the global scope you lose an entire path of optimisation because it’s no longer safe to assume that nothing else is going to dynamically access one of your exposed globals. Finally, in the case of TypeScript, once you introduce a library that doesn’t expose itself globally (expect to see more of this as ES modules become more widely adopted!) you’ll be unable to import it since the act of importing will turn your TS file into an external module.
Notwithstanding regeneration of the outfile all the time, source maps are positionally sensitive and run-length encoded so most of the map has to be rebuilt if you do this and use source maps (which you should!). At high-10s to 100s kloc combined it’s going to get slow.
Yeah, but so is brushing your teeth. You can get away with not doing both for a while but eventually bad things will happen. :) The good news is that you can create a roll-up module if you really need to and Anyway, it’s obviously up to you, I try to help steer people away from the same mistakes that other people have made in the past, but it is up to you if you know you know better, please definitely keep doing what you are doing! |
@csnover This is an awesome write-up. I'm definitely not trying to disagree with you, but here's my take on the other side of the coin. At the scale you're talking about - multiple teams, hundreds of dependencies, multiple versions of the same dependencies, etc., clearly external modules make sense. TypeScript external modules serve teams at that end of the spectrum very well (and there would essentially be no way to survive without following a pattern like that in regular JS). Based on your experience, it sounds like you rarely have to work on simple projects anymore. My experience has been mostly in smaller environments with much simpler architectural requirements (mostly corporate/line of business web apps). In those environments, choosing TypeScript external modules introduces several headaches that internal modules simply don't have. TypeScript internal modules "just work" in projects from trivial to medium complexity. It might just be that for developers working on these kinds of apps - modularization itself is a revolutionary concept, never mind bundling like what The way I look at it, using internal modules makes more sense from a YAGNI / KISS perspective until you actually start having the problems you're mentioning. As you've argued, using external modules in a system that is already suffering from complex module interrelationships helps reduce the complexity; however, I would assert that using external modules in a system that doesn't require their functionality increases its complexity. At some point on the graph, those lines intersect, but I don't believe it's at zero. It's funny - I think we answered the same question on Stack Overflow the other day with largely the same arguments (and someone was mad at me for recommending something "clearly against the best practice"). It's just my opinion. Again - thanks for posting this! I think you've made a pretty awesome argument. |
Sorry. My bad. Tracking : #244 |
@Deathspike Added examples. Bootstrapping does not help these examples.
If your code depends on any form of js ordering you will get random errors at runtime.
Consider class Foo {
} and a class Bar extends Foo {
} If you fail to compile it in correct order e.g. perhaps alphabetically
Consider module App {
export var foo = 123;
} And module App {
export var bar = foo + 456;
} If you fail to compile it in correct order e.g. perhaps alphabetically |
@Deathspike please see updated https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md (diff f1f4782) One thing that I cannot stress enough:
Its not just tools. Its also for code review and understanding for the next person. You will have a hard time reviewing other people's github projects (and I come across this all the time in C#). |
@nycdotnet Thanks for the kind words. FWIW, I would not have felt it necessary to say anything about, say, 5 or 10 TS files… but 300+ certainly qualifies on the “this is a large amount of code” scale :) |
Thanks for the additional examples @basarat Now the recommendation has started to make a lot of sense :-) |
Here is another one: Files cannot be compiled in isolation. E.g. consider module M {
var s = t;
} Will have different output depending upon whether there is a module M {
export var t = 5;
} or var t = 5; So |
Hi,
compileOnSave: false did the trick ;] |
@wojciak You can also:
I use the latter ever since the arguments against --out have been made crystal clear. |
Build works. Restored with Order seems to be preserved with Note
|
files
for javascript ordering with --out
compileOnSave
for --out
Sky is falling!!! :-) Also since I noticed that if I've ever had a TypeScript file open, if I change the order of You're the best, Bas. |
The gulp-order module does do that. You could include an extra section in tsconfig in which you order certain files. The remaining files can follow automatically in alphabetic order. Sent from my Windows Phone -----Original Message----- I noticed that if I've ever had a TypeScript file open, if I change the order of files in tsconfig.json, the order is reset to alphabetical on save. Didn't happen. I guess that is done by filesGlob expansion. I don't see an easy way to support filesGlob if you want to use out. Things will |
If you still think its a good idea to use |
I'm not well versed in the module story around TypeScript. So forgive my ignorance. But after reading this thread, I'm quite confused. I'm trying to understand the implications of all of this. What I can't figure out from the comments is the implications between If I'm developing code that is primarily used in a web application, it seems like most of these arguments are pushing for external modules. Furthermore, it seems like by not supporting I guess I'm just confused exactly what the "argument" in this thread is? For example, the issue with ordering with Ideally, I'd like to use Thanks. |
Yes. Effectively a necessity. Ps: outDir has nothing to do with any of the discussion here. You are free to use outDir. |
I am trying to follow this discussion and I am glad to see that I am not the only one befuddled by this question. I was trying to create a simple test case, for a simple program, that happens to need two just two source files. There are no complicated interlocking dependencies. More like a traditional #include. class1.ts defines a class called Class1 Whereas all I want to do is to execute the combined source files. Which from what I understand means tsc'ing each one, concatenating the resultant .js files in the right order, and then giving them to node to execute. Or, I have to learn about modules and exporting etc. and then also have to learn about build systems (gulp or grunt or others - still learning) I am not arguing in favor or against --out but I am just trying to clarify what my options are in this simple case. Maybe I should keep my whole program in one ts file until I learn modules, exporting and build tools. |
If you are executing with |
Since |
I don't use
--out
. So up for grabs.I don't recommend
--out
because : https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.mdThe text was updated successfully, but these errors were encountered: