jihchi/vite-plugin-rescript

When `import "main. res"` is used, vite's hot update does not take effect

mowtwo opened this issue · 7 comments

Hello, I encountered some problems when using vite3 and vite-plugin-rescript
These are the dependencies I currently use
image

That is, when import "main. res" is used directly, vite's hot update does not take effect
After debugging the code, I found that the problem was caused by the use of the following options in the code
image

It would be helpful if you could provide a minimum reproducible repo.

@jihchi Wow, something amazing happened. I found this bug on Microsoft Windows. When I created sample code on MacOS at home, I found that there was no such problem

@jihchi 你好,我發現你也可以講漢語,而我的英語不太好,我直接用漢字表達更方便一些。
這個bug我是在公司的Windows操作系統上發現的,我一開始以為是我PC的問題,所以讓我朋友也嘗試了我的案例代碼,結果情況是一樣的,表現就是當你直接使用esm的import引入res文件,就會觸發。我當時將這個插件的源代碼下載到本地修改然後用npm pack後安裝到了項目中,發現確實是因為插件代碼中的server配置下的watch設置的ignored引起的。
當我注釋掉這部分代碼後,則可以正常運行。
剛剛我想給你提供案例代碼,但是家裡只有macOS的電腦,但是我在macOS上卻沒有這個問題,因此想問一下是否是因為系統的差異造成的
我在Windows上操作時,還有一種狀況是可以觸發hot update的,那就是在頁面裡同時有對編譯的.bs.js文件進行引用的場景,比如我通過<link rel="preload">對.bs.js進行引用時。

您好,我無法在「不能夠重現問題」的情況下進行查錯,從您描述的內容來看,我也摸不著頭緒。如果您能夠提供一個「能夠重現問題」的專案,這樣能夠幫助我進行除錯。

I have no idea what and how would the problem happen, please provide a minimum reproducible repo.

@jihchi 您好,我這邊創建了一個我在Windows上面可以復現bug的example,我今天在同事的電腦上嘗試,發現他電腦上的bug比我電腦上的問題更大,在他電腦上甚至無法觸發rescript編譯器的執行(使用的同一個example的代碼),目前已知的問題都是在Windows系統下才能重現
vite-plugin-rescript-bug-example

您的設定錯誤,如果您要使用 Loader 模式,請參閱文件進行設定。
如果並非 Loader 模式,請參考 https://github.com/jihchi/vitejs-template-react-rescript 進行設定。

I'd revise the README file to make setup more clear.