Stale compiled output after editing CoffeeScript files when using coffeescript/register
24.5K reputation · 26 Jan 2021, 05:41 UTC
When the CoffeeScript Node extension (coffeescript/register) is used, the compiler caches the generated JavaScript in Node's module cache so that subsequent require calls return the same compiled output.
The goal is to determine whether the extension provides a mechanism to automatically refresh this cached JavaScript when the source .coffee file changes, without resorting to a full require‑cache purge that could affect other modules.
Current observations show that edits to the source file are not reflected until the Node process restarts or the specific cache entry is manually removed, but it is unclear if this behavior is intentional, configurable, or a limitation of the underlying module‑caching system.
- Is there a supported option or API within
coffeescript/registerto disable or bypass its internal caching? - Does the extension expose a hook that allows a file‑watcher to invalidate only the compiled module for a given file?
- Are there recommended patterns for integrating the extension with hot‑reloading tools that avoid wholesale cache clearing?