ts-macros icon indicating copy to clipboard operation
ts-macros copied to clipboard

[BUG] Macro expansion is not updated when running under webpack --watch

Open andrei-datcu opened this issue 1 year ago • 1 comments

Describe the bug Macro and the invoking need to be in separate file

// def.ts

export function $macro(a: number, b: number) {
return a + b;
}
// usage.ts
import {$macro} from "./def.ts"

console.log($macro!(5, 4));

Code to reproduce Load the files with ts-loader.

webpack --watch
#all good
# edit macro def
# still old result

Expected behavior Updated result

Additional context I'm not sure there's anything you can do here, this seems to be related to ts-loader.

andrei-datcu avatar Apr 04 '23 19:04 andrei-datcu

For it to update you also need to update the file the macro is called in (even if it's just adding a space at the end of the file) - sadly ts-macros can't do much here since it's just a transformer and can't transpile other files on command.

Well - technically it could do some invisible change to the file it's called in to force the watcher to transpile the file, but that seems a little hacky. Maybe I could make that a transformer option.

GoogleFeud avatar Apr 04 '23 20:04 GoogleFeud