aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-27 15:52:52 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-27 15:52:52 -0700
commit16a7224ce5de519afa4765594d45350c95a87adc (patch)
treee2cac122fd328e88dad86eb726696752e244351e /src
parent7c44773f38bb68fc9dbddc755b636b3392ce83aa (diff)
downloadbun-16a7224ce5de519afa4765594d45350c95a87adc.tar.gz
bun-16a7224ce5de519afa4765594d45350c95a87adc.tar.zst
bun-16a7224ce5de519afa4765594d45350c95a87adc.zip
Fix hot reloading in canary (#3848)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/module_loader.zig19
-rw-r--r--src/watcher.zig1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 0e4cb5ba2..4763ed1bc 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -450,6 +450,25 @@ pub const RuntimeTranspilerStore = struct {
return;
};
+ if (vm.isWatcherEnabled()) {
+ if (input_file_fd != 0) {
+ if (vm.bun_watcher != null and !is_node_override and
+ std.fs.path.isAbsolute(path.text) and !strings.contains(path.text, "node_modules"))
+ {
+ should_close_input_file_fd = false;
+ vm.bun_watcher.?.addFile(
+ input_file_fd,
+ path.text,
+ hash,
+ loader,
+ 0,
+ package_json,
+ true,
+ ) catch {};
+ }
+ }
+ }
+
for (parse_result.ast.import_records.slice()) |*import_record_| {
var import_record: *bun.ImportRecord = import_record_;
diff --git a/src/watcher.zig b/src/watcher.zig
index 9bc61b3af..a31267c5f 100644
--- a/src/watcher.zig
+++ b/src/watcher.zig
@@ -693,6 +693,7 @@ pub fn NewWatcher(comptime ContextType: type) type {
package_json: ?*PackageJSON,
comptime copy_file_path: bool,
) !void {
+ // This must lock due to concurrent transpiler
this.mutex.lock();
defer this.mutex.unlock();