Open present-g opened 1 year ago
This is because --watch
only watches dev.tsx and all of the things it is importing. App.tsx is not in the import path.
Adding a dummy import './src/App.tsx'
in your dev.tsx solves this problem.
@extrasalt, thank you
I tried this before but this solution only restarts the Server. We also need to update the code in the browser. This can be solved using WebSockets.
The main problem is how to update only the parts of the code that have changed without reloading the page. It looks like this cannot be solved without improving Bun.serve
in dev mode.
As an example, this is webpack-dev-server
I am not sure I understand what you mean by update the code in the browser.
With this when I change a line in App.jsx or any of the child-components, the dev.jsx re-runs.. rebuilding the frontend in the process and updating what's in the ./build directory.
You only need to refresh the page in the browser.
(If you want that to happen automatically, I was using react-dev-utils/openBrowser
but that kept stealing the focus away from the editor).
What version of Bun is running?
0.8.1
What platform is your computer?
Darwin 22.3.0 x86_64 i386
What steps can reproduce the bug?
bun create react
bun run dev
localhost:3000
browser pagesrc/App.tsx
What is the expected behavior?
In development mode, file changes are expected to refresh the page automatically.
What do you see instead?
The text does NOT change automatically even after refreshing the page. Only by restarting the server.
One more problem, as of now the following code is running in
dev.tsx
:Importantly! We cannot do
build
indev
mode, as real projects are large and the build will take a long time.Additional information
Is it possible to auto-reload the page? Is it possible not to build in
dev
mode as in webpack-dev-server?