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 wrangler dev --local and its lazy imports of @miniflare/tre #2339

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

GregBrimble
Copy link
Member

The await import() of the environment polyfills seemed to break out of the if (tre) {} check. This made theminiflare-cli dist look like:

import { ... } from "@miniflare/tre"

When the @miniflare/tre package was missing, this broke wrangler dev --local for users.

By wrapping the polyfill logic in a function like this, we can avoid this top-level import.

@GregBrimble GregBrimble requested review from a team as code owners December 6, 2022 10:27
@changeset-bot
Copy link

changeset-bot bot commented Dec 6, 2022

🦋 Changeset detected

Latest commit: 7d27528

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

This PR includes changesets to release 2 packages
Name Type
@cloudflare/pages-shared Patch
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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/runs/3628661494/npm-package-wrangler-2339

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/prs/2339/npm-package-wrangler-2339

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/runs/3628661494/npm-package-wrangler-2339 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/runs/3628661494/npm-package-cloudflare-pages-shared-2339

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #2339 (7d27528) into main (271aece) will increase coverage by 0.03%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2339      +/-   ##
==========================================
+ Coverage   70.78%   70.82%   +0.03%     
==========================================
  Files         152      152              
  Lines        9712     9711       -1     
  Branches     2536     2536              
==========================================
+ Hits         6875     6878       +3     
+ Misses       2837     2833       -4     
Impacted Files Coverage Δ
packages/wrangler/src/miniflare-cli/assets.ts 7.75% <0.00%> (+0.06%) ⬆️
packages/wrangler/src/git-client.ts 81.25% <0.00%> (+4.16%) ⬆️
...ackages/wrangler/src/__tests__/helpers/mock-bin.ts 100.00% <0.00%> (+5.26%) ⬆️

Copy link
Contributor

@rozenmd rozenmd left a comment

Choose a reason for hiding this comment

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

wrangler dev --local works now

Copy link
Contributor

@mrbbot mrbbot left a comment

Choose a reason for hiding this comment

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

Looks good! We'll want to add a test that actually installs from an npm registry to prevent these types of the bug in the future, but that shouldn't block releasing this.

await readyPromise;
await new Promise((resolve, reject) => {
wranglerProcess.once("exit", (code) => {
if (!code) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: code will be null if the process is terminated with a signal, in which case we'd want to reject.

Suggested change
if (!code) {
if (code === 0) {

afterAll(async () => {
await readyPromise;
await new Promise((resolve, reject) => {
wranglerProcess.once("exit", (code) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required, but you might want to consider using the once helper from node:events here.

@GregBrimble
Copy link
Member Author

pages dev --experimental-local looks broken, but rather that than wrangler dev --local. I say let's merge and release this and fix pages dev --experimental-local at some point later this week?

@GregBrimble GregBrimble merged commit f682118 into main Dec 6, 2022
@GregBrimble GregBrimble deleted the fix-wrangler-dev branch December 6, 2022 12:16
@github-actions github-actions bot mentioned this pull request Dec 6, 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