Can I set different compile option for different TypeScript files in WebStorm


#1

(I sent this post to JetBrains WebStorm forum, but no one reply…So I post here too, expect someone knows the answer)

Hi, Everyhero.

I am developing an Electron(http://electron.atom.io/) app using TypeScript 1.4 on WebStorm 10.0.4.

Some .ts files run on Electron main process(NodeJS), so I need to compile them with command option --module commonjs,
and some .ts files run on Electron render process(HTML), so I need to compile them without command option --module commonjs.

In Settings->Languages & Frameworks->TypeScript, I choose Scope to Current File, and set the command line option for file A,
The file B also becomes to use that command line opton…

Can Anyhero know how to resole my problem? Thank U very much first!


#2

Interesting. I wonder how many here develop Electron apps using Webstorm or other editors than Atom.
I never thought about it, but apparently I always naively assumed that Atom was used by default.


#3

Thanks!

Finally, someone on JetBrains forum replied to me, use File Watcher I resolved my problem.
Reference: https://devnet.jetbrains.com/message/5546382#5546382


#4

It’s also possible to use node-style requires in the render process. You should be fine just compiling them all as a commonjs module, as long as you require the files. I think this is nicer than including <script> tags, although you must still have at least one (with a src attribute or an inline require to the entry point).


#5

Yes, this is also a way to resolve this problem.
I will try your advice later, Thanks a lot!