简体   繁体   中英

Deploying changes to JavaScript files generated from Typescript in IntelliJ; js not updated

I am having a problem with IntelliJ and the automatic deployment of changes while the server is running (in this case Spring Boot).

I have enabled the "Build project automatically" in the IntelliJ options.

When I make a change to a .ts file, the .js and .js.map files in the code are correctly updated.

The .ts file, however, it not updated in the target directory. That is NO problem. I just press the "Compile" shortcut and the .ts file in the target output are updated. Great.

What is NOT updated though are the target .js and js.map files. No matter how many times I open these files and press "Compile" the files in the target are not updated. So the .ts and .js files are now out-of-sync, and I need to restart the server for the .js file change to be noticed.

The weirder part is that all this works just fine on my work computer, with what I can tell the exact same settings. But I cannot get it to work on my home computer. Neither can a co-worker of mine get it to work on his work computer, and I've looked and looked for any differences in settings.

It is as if IntelliJ watches the files for changes on some setups, and on some setups, they are completely ignored because they were generated.

Can anyone help me with any pointers?

Okay, I figured out a solution to this.

By changing the tsconfig.json into stating compilerOptions/outDir so that it outputs straight into the target/classes/static directory, the changes are propagated correctly. (for me the value became the beautiful ../../../../../target/classes/static/scripts )

A side effect though is that the source map paths become quite wonky and start showing up as a folder called something alike C:/.../src/main/resorces/static/... in the browser dev tools, inside to the JavaScript root directory, and the typescript files had difficulty showing up sometimes, just being blank.

A workaround that I found for this was to also set compilerOptions/inlineSources to true and to set compilerOptions/sourceRoot to something fictitious like http://TypeScriptFiles so it shows up in the browser dev tools as a new root node called TypeScriptFiles instead of the weird nested directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM