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

fix live-reload with wrangler and esbuild #205

Open
lane711 opened this issue Sep 28, 2023 · 2 comments
Open

fix live-reload with wrangler and esbuild #205

lane711 opened this issue Sep 28, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@lane711
Copy link
Owner

lane711 commented Sep 28, 2023

live reload was working prior to this commit:
26bb2ac
dev build 26bb2ac Lane ldc0618@gmail.com Aug 22, 2023 at 8:48 AM

I had to convert the esbuild to use a config file.

Since then live reload with wranger has not worked. for reference here is the commands involved:
npm run dev
"dev": "run-p dev:*",
"dev:wrangler": "wrangler pages dev dist --live-reload",
"dev:esbuild": "node ./src/cms/util/build.mjs",

The goal is to restore live reload so that anytime a tsx, js, css, etc file is changed, it will build, copy to the dist folder and restart the server.

@lane711 lane711 added the help wanted Extra attention is needed label Sep 28, 2023
@rhamses
Copy link
Contributor

rhamses commented Jan 26, 2024

I somewhat fixed this if I run the commands not together, but I can't figure out why it doesn't work when I put everything in the package.json

The steps are the following (the code is here btw)

  • created a new esbuild watch file called watch.mjs where I use the context function. This will build the dist/_worker.js every time the server.ts and it's child has a change
  • on the package.json I updated the dev:esbuild task to run the previous step and on the dev:wrangler I just inserted the --live-reload option that refreshs the tab every time the dist/_worker.js is updated.

If you ran this commands in separated tabs it's works as intended, but when you try to run inside the package.json I get the error ERR_IPC_CHANNEL_CLOSED and I can't figure why.

I'd appreciate some help to solve this.

Here's the error code in fully formed:

/Users/rhamses/Sites/sonicjs/node_modules/wrangler/wrangler-dist/cli.js:30947
            throw a;
            ^

Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
    at new NodeError (node:internal/errors:405:5)
    at target.send (node:internal/child_process:754:16)
    at Object.announceAndOnReady [as onReady] (/Users/rhamses/Sites/sonicjs/node_modules/wrangler/wrangler-dist/cli.js:150985:15)
    at MiniflareServer.<anonymous> (/Users/rhamses/Sites/sonicjs/node_modules/wrangler/wrangler-dist/cli.js:128314:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on process instance at:
    at process.processEmit [as emit] (/Users/rhamses/Sites/sonicjs/node_modules/wrangler/wrangler-dist/cli.js:25324:38)
    at node:internal/child_process:758:35
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'ERR_IPC_CHANNEL_CLOSED'
}

@totto2727
Copy link
Contributor

Can we use Hono's new Cloudflare Pages template?

We are thinking that if we can run it with only Vite and Hono, without relying on Wrangler, it would give us a lot of flexibility.

However, when I tried it at hand, it did not work well...(seems to be a problem with loki and other processes?)

https://github.com/honojs/hono/releases/tag/v3.9.0

import { defineConfig } from 'vite'
import devServer from '@hono/vite-dev-server'
import pages from '@hono/vite-cloudflare-pages'

export default defineConfig({
  plugins: [
    pages(),
    devServer({
      entry: 'src/index.tsx'
    })
  ]
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants