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

Upgrade miniflare to 2.0.0 🎉 #221

Merged
merged 4 commits into from
Jan 11, 2022
Merged

Upgrade miniflare to 2.0.0 🎉 #221

merged 4 commits into from
Jan 11, 2022

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Jan 8, 2022

Hey! 👋 This PR upgrades miniflare to version 2.0.0. There were only a couple changes since 2.0.0-rc.5, mostly around making fetch behave more like Cloudflare's. See the bottom of the changelog.

I've also made another few minor tweaks to pages dev:

  1. Remove redundant immediate pages dev rebuilds/reloads: watching all events without ignoreInitial set to true means chokidar calls the callback immediately. This caused functions to be built twice, and Miniflare to be reloaded immediately after startup.
  2. Wait for esbuild to finish before starting Miniflare: instead of using a scriptReady boolean, this now uses a deferred Promise, so the event loop isn't blocked. This is now awaited before constructing the new Miniflare, as this is what asynchronously kicks off loading the script. It looks like this wasn't doing anything before though, since scriptReady was initialised to true.
  3. Fix ReferenceError: __FALLBACK_SERVICE_FETCH__ is not defined on watch update with pages dev: subsequent Pages Functions worker builds due to file changes were not replacing __FALLBACK_SERVICE_FETCH__ leading to ReferenceErrors (I think this is a bug in esbuild-plugin-replace). This change switches to using esbuild's built-in define option, instead of esbuild-plugin-replace, removing an additional dependency.

cc @GregBrimble

Watching `all` events without `ignoreInitial` set to `true` means
`chokidar` will call the callback immediately. This caused functions
to be built twice, and Miniflare to be `reload`ed immediately after
startup.
Instead of using a `scriptReady` boolean, this now uses a deferred
`Promise`, so the event loop isn't blocked. This is `await`ed before
constructing the `new Miniflare`, as this will asynchronously kick
off loading the script.
Subsequent Pages Functions worker builds due to file changes were
not replacing `__FALLBACK_SERVICE_FETCH__` leading to
`ReferenceError`s. This change switches to using `esbuild`'s built-in
`define` option, instead of `esbuild-plugin-replace`, removing an
additional dependency.
@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2022

🦋 Changeset detected

Latest commit: 41d6df0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamping this to unblock. Feel free to merge if you'd like. (Else I'll do it Monday first thing)

@threepointone
Copy link
Contributor

Landing this!

@threepointone threepointone merged commit 8ff5537 into cloudflare:main Jan 11, 2022
@github-actions github-actions bot mentioned this pull request Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants