Fork me on GitHub
#shadow-cljs
<
2024-02-17
>
genenakagaki09:02:05

I have a problem with external js files. When I change the external js file after I require it, the change does't get applied. Is there a way to refresh the required js file? I'm doing this on node.js as the target and using the node-repl

thheller09:02:43

how are you requiring that file?

genenakagaki09:02:45

(ns sample
  (:require
   ["./repository.js" :as repo]))

genenakagaki09:02:34

I have the repository.js in src/js/sample/require.js and I have src/js in the source-paths

thheller09:02:35

that file should get recompiled, but depending on how it is written the hot-reload may not work

genenakagaki09:02:54

How should I write it to recompile? I have a function in that file like this

export const findAll = async () => {
  ...
}

thheller09:02:11

that should be fine

thheller09:02:45

to be honest I have not spend any time on trying to make raw JS reload work for ESM files

thheller09:02:53

if you want you can write it as goog.module, no gurantee that'll work either but has higher chances

genenakagaki09:02:19

I see, I'll try that. Thanks for the help!!

thheller09:02:25

oh before you do that. which version do you use? there have been some issues not too long ago regarding JS reloading

thheller09:02:32

so if you are not on the latest consider upgrading first

👍 1