cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 160 forks source link

TypeScript to JavaScript transpilation using tsc (not tsserver) fails when too many files #605

Closed frankcapodanno closed 3 years ago

frankcapodanno commented 4 years ago

Hi,

I have a problem when I try to parse a big project from ts to js with Jsweet. It seems that there is a limit in the command when many ts were generated. (Plugin with transpiler version 2.3.8) :

TypeScript2JavaScriptWithTscTranspiler:94 - command line is too long.

Maybe could be an idea when a lot of ts files was generated from ts to js would be divided in different calls to the command (tsc transpieler).

OS: Windows 10 Java : 8 (251) Transpieler Version : 2.3.8

Detail of the call that generate an error on a big project:

user.jsweet-node_modules\tsc.cmd, --target, ES5, --moduleResolution, classic, --experimentalDecorators, --emitDecoratorMetadata, --rootDir, C:\projekt\example\jsweetparse\ts, --outDir, C:\projekt\example\jsweetparse\js, .tsc-rootfile.ts, [HERE TOO MANY FILES]

renaudpawlak commented 4 years ago

Looks like a common issue with ProcessBuilder. The limit is around 2000 characters.

However, I am surprised because I know users who compile fairly big (even very big) projects and that don't run into such a limitation. I will ask how many files they compile.

In the meantime, can you consider splitting your project into modules? What you can do, is to adjust the input option and the exclusion patterns to partially transpile your project (exclusion patterns will filter out some Java files from the transpilation so they will not be passed to the TypeScript-to-JavaScript transpilation).

frankcapodanno commented 4 years ago

I think that's good., and thank you for the suggestion. I try something with my project but is not urgent and I try something with exclusions and inclusion patterns. But if you change input option that will be affected and also supported to the Maven Plugin ? Sorry for this newbie question. Thank you for your answer.

lgrignon commented 3 years ago

I think you can also avoid this problem by using the tsserver option (available with maven plugin as well) which AFAIK does not suffer this limitation.

The other question about includes/excludes has been answered here: https://github.com/lgrignon/jsweet-maven-plugin/issues/52#issuecomment-684509538

I keep this issue open and change title

lgrignon commented 3 years ago

@renaudpawlak I guess tsserver could be the default mode now? What do you think.

A workaround could be to minimize the file list by using relative paths from a root di if not done yet.

lgrignon commented 3 years ago

Paths are already as short as possible. Let's tsserver be the default mode for JSweet 3

lgrignon commented 3 years ago

@renaudpawlak request for confirmation :)