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

Esbuild doesn't rerun #53

Closed
janat08 opened this issue Sep 24, 2021 · 2 comments
Closed

Esbuild doesn't rerun #53

janat08 opened this issue Sep 24, 2021 · 2 comments
Labels
bug Something isn't working fixed-in-next Fixed in next release

Comments

@janat08
Copy link

janat08 commented Sep 24, 2021

When launching miniflare esbuild won't rerun on change, so old file gets loaded. I've checked my config and I don't think there's some sort of browser caching is involved.

wrangler.toml

name = "test-worker"
type = 'javascript'
account_id = ''
route = ''
zone_id = ''
usage_model = ''
workers_dev = true
compatibility_date = "2021-09-17"

[build]
watch_dir="./js"
command = "npm run buildes"
[build.upload]
# The "modules" upload format is required for all projects that export a Durable Objects class
format = "service-worker"

package.json

{
  "name": "test-worker",
  "main": "./dist/index.js",
  "scripts": {
    "build": "rollup -c",
    "buildes": "esbuild --bundle --sourcemap --minify --outfile=dist/index.js ./js/indexx.js",
    "watch": "rollup -c --watch",
    "preview": "lein compile && wrangler preview",
    "dev": "miniflare --watch --debug",
    "compileAuth": "rollup ./js/auth.js --file /target/auth.js --format umd --name 'auth'"
  },

terminal

gitpod /workspace/clojureworker $ cd worker
gitpod /workspace/clojureworker/worker $ npm run dev

> test-worker@ dev /workspace/clojureworker/worker
> miniflare --watch --debug


> buildes
> esbuild --bundle --sourcemap --minify --outfile=dist/index.js ./js/indexx.js


  dist/index.js      127.5kb
  dist/index.js.map  554.2kb

⚡ Done in 27ms
[mf:inf] Build succeeded
[mf:dbg] Options:
[mf:dbg] - Build Command: npm run buildes
[mf:dbg] - Scripts: dist/index.js
[mf:dbg] Reloading dist/index.js...
[mf:inf] Worker reloaded! (127.46KiB)
[mf:dbg] Watching .env, dist/index.js, js, package.json, wrangler.toml...
[mf:inf] Listening on :8787
[mf:inf] - http://127.0.0.1:8787
[mf:inf] - http://10.52.7.90:8787
3133
GET / 200 OK (9.27ms)
[mf:dbg] js/indexx.js changed, reloading...
[mf:dbg] Reloading dist/index.js...
[mf:inf] Worker reloaded! (127.46KiB)
3133
GET / 200 OK (2.29ms)

second console.log should be 31333

@mrbbot
Copy link
Contributor

mrbbot commented Sep 24, 2021

Hey! 👋 This is definitely a bug in Miniflare. Because of the ./ at the front of ./js, it's not realising the change is within the js directory. 🤦‍♂️ I'll fix this, but in the meantime, you should be able to change watch_dir to "js".

@mrbbot mrbbot added the bug Something isn't working label Sep 27, 2021
@mrbbot mrbbot added the fixed-in-next Fixed in next release label Oct 19, 2021
@mrbbot
Copy link
Contributor

mrbbot commented Oct 27, 2021

Hey! 👋 The first pre-release of Miniflare 2 has just been released, including this fix. You can find the full changelog here and install it with npm i miniflare@next -D. Please let me know if you have any other issues, and feel free to ask questions in the #miniflare channel of the Cloudflare Workers Discord server.

@mrbbot mrbbot closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-in-next Fixed in next release
Projects
None yet
Development

No branches or pull requests

2 participants