Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Pass the list of files to the JSCompiler #856

Closed
davidfestal opened this issue Feb 20, 2014 · 7 comments
Closed

Pass the list of files to the JSCompiler #856

davidfestal opened this issue Feb 20, 2014 · 7 comments
Assignees
Milestone

Comments

@davidfestal
Copy link
Contributor

Currently the JSCompiler is called by the IDE without setting the list of files, so that the JSCompiler compiles all the project files, even if they are not changed during an incremental build.
When we add this support, we should care about JS native files that should also trigger an incremental build if any.

@davidfestal davidfestal self-assigned this Mar 17, 2014
@davidfestal davidfestal added this to the Ceylon 1.1 milestone Aug 26, 2014
@chochos
Copy link
Contributor

chochos commented Aug 27, 2014

The JS compiler doesn't support incremental compilation yet. Its output is just one big text file in CommonJS format.

To support incremental compilation it will have to store the output of each source file in a separate text file, and those will just be temp files that have to be assembled together into the final JS module. This is a major refactoring of the way it works currently. I'll open an issue in ceylon-js.

@quintesse
Copy link
Contributor

@chochos I wonder if it's worth the added complexity, don't you? Although it could probably be done locally, with temp files that get stored alongside the .js files in the repository for example, but that are not "official artifacts" (ie they get ignored by any tool except the JS compiler and won't be copied anywhere). Still, is it worth it?

@chochos
Copy link
Contributor

chochos commented Aug 27, 2014

The JS compiler seems to me to be a lot faster than the JVM compiler (after all it's "just" generating text). But in a project with hundreds of source files it might save some time if only one JS file is generated and then all of them are stitched together again.

The final output however is backwards compatible, so I guess we can leave this for 1.2 because we do have to consider several things:

  • Store the intermediate JS files as official artifacts or not; and if so, as a single zip file or separate files
  • Make incremental compilation work for CLI as well
  • Reuse the code from JVM compiler which determines if a file must be recompiled. I guess the IDE can do this, but for CLI it needs to be available as well (determine if a file has been modified or is new, or has been removed, etc)

@chochos
Copy link
Contributor

chochos commented Aug 27, 2014

And as @davidfestal has pointed out (elsewhere), it's actually partial compilation we're talking about, not incremental build.

@quintesse
Copy link
Contributor

Reuse the code from JVM compiler which determines if a file must be recompiled

We don't do this in the JVM compiler actually. We just (re)compile what the user puts on the command line. So if you say ceylon compile foo and later ceylon compile source/foo/somefile.ceylon only the declarations in that file get recompiled. (The code I factored out some weeks ago gives you that list btw, it's just not used by the JsCompiler)

NB: If you'd just do ceylon compile source/foo/somefile.ceylon without ever having done ceylon compile foo before, you can get compile errors or just partially or wrongly generated code.

@davidfestal
Copy link
Contributor Author

Yes, true, but since you keep the other classes inside the archive when compiling a single java file (which I call partial module compilation), this allows the IDE to provide true incremental build

@davidfestal
Copy link
Contributor Author

So to summarize :

  • For the moment I give the list of all the project files (ceylon and js) to the JSCompiler even during incremental builds.
  • I've just added a TODO in the CeylonBuilder.generateBinaries() method in the IDE to remember what to change when Partial compilation ceylon/ceylon-js#408 is fixed
  • So that as soon as the ceylon-js issue is fixed and the TODO change is made, true incremental build for JS files should also work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants