Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andrei-datcu opened this issue Apr 4, 2023 · 1 comment

Comments

@andrei-datcu
Copy link

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.

@GoogleFeud
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants