ts-loader not liste for file change when exporting interface with webpack watch

Created on 6 Aug 2019  路  5Comments  路  Source: TypeStrong/ts-loader

Expected Behavior

ts-loader should listen to file changes.

Actual Behavior

It seems that the file is still in cache somewhere, restarting webpack or renaming the file solves temporarily this problem but any file changes isn't committed in ts-loader.

Even if i change the interface properties or the interface name i cannot use my new values until i rename the file o restart webpack.

Steps to Reproduce the Problem

env:

  • ts-loader: 6.0.4
  • webpack: 4.39.1

Use any webpack config with watch: true.

  • Create any interface
  • Init a variable using this interface
  • Change interface properties types
  • Change variable valorization according to the new types
  • An error occour in webpack

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/monkeythedev/ts-loader-interface-watch-bug/tree/master

wontfix

Most helpful comment

I'm also experiencing this behavior - adding a new interface to a file where _only interfaces and types are present_ doesn't actually allow me to use that interface/type anywhere else in my app. If that file contains at least one non-TypeScript thing (a variable, etc) it seems to work fine, and changes are saved properly across the app.

We see this the most in our types/ directory, where files will typically only contain interfaces/types and the changes have to be propagated via stopping and restarting Webpack Dev Server.

Versions: (I know these are a bit older, but we've been seeing this problem for some time now as well)
ts-loader: 5.3.0
webpack: 4.17.1

All 5 comments

@monkeythedev if you'd like to submit a speculative PR to fix this I'll take a look

I'm also experiencing this behavior - adding a new interface to a file where _only interfaces and types are present_ doesn't actually allow me to use that interface/type anywhere else in my app. If that file contains at least one non-TypeScript thing (a variable, etc) it seems to work fine, and changes are saved properly across the app.

We see this the most in our types/ directory, where files will typically only contain interfaces/types and the changes have to be propagated via stopping and restarting Webpack Dev Server.

Versions: (I know these are a bit older, but we've been seeing this problem for some time now as well)
ts-loader: 5.3.0
webpack: 4.17.1

@monkeythedev if you'd like to submit a speculative PR to fix this I'll take a look

Idk... I debugged for a few hours and found that in after-compile at function provideErrorsToWebpack after calling ensureProgram the instance returned does have in the value returned by program.getSourceFiles() the old source of the interface files. It's like the watcher cannot listen for the changed source...

I tried awesome-typescript-loader and it work fine, but i can't figure out why....

I also tried with the option experimentalWatchApi: true since at-loader uses createWatchProgram to create the watcher, but i had no results.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Closing as stale. Please reopen if you'd like to work on this further.

Was this page helpful?
0 / 5 - 0 ratings