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: ensure that alias config gets passed through to the bundler when using new --x-dev-env #6903

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Oct 6, 2024

What this PR solves / how to test

While this does fix the problem (it's a one-liner) and I added a test to prevent a regression,
we have a systemic problem here because the types are too loose within the ConfigController.

One approach to fixing this is: rather than defining the StartDevWorkerInput, where all the props are optional, and then inferring the StartDevWorkerOptions, we should flip it round. Make the StartDevWorkerOptions tight (i.e. nothing can be optional, but explicitly can be undefined if needed). And then infer the StartDevWorkerInput from there by "picking" the desired properties and marking the type as Partial<>.

This would have created a typings error when the alias property was added to the config, and therefore indicate to the developer that it needs to be addressed here.

There may be a better solution, perhaps using zod or similar. So I didn't do any refactoring in this PR to keep the fix simple to review and land.

Alternatively, we could avoid manually copying over properties and rely upon a more automatic merging helper function that would mean the developer has to do nothing here when adding to the config.

(I believe that there was some discussion about how this config copying was awkward at the time, and I think the plan was to clean it up once the "other" way of doing dev was removed, which is not far off now. So perhaps this can all be done in one go?)

Moreover the test coverage of this code is pretty thin, so whether (or how) we fix the typings we should make the ConfigController tests much more comprehensive.

Fixes #6898

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bug fix

@petebacondarwin petebacondarwin requested a review from a team as a code owner October 6, 2024 14:51
Copy link

changeset-bot bot commented Oct 6, 2024

🦋 Changeset detected

Latest commit: a423441

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers 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

github-actions bot commented Oct 6, 2024

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/workers-sdk/runs/11202827282/npm-package-wrangler-6903

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-wrangler-6903 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-create-cloudflare-6903 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-cloudflare-kv-asset-handler-6903
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-miniflare-6903
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-cloudflare-pages-shared-6903
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-cloudflare-vitest-pool-workers-6903
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-cloudflare-workers-editor-shared-6903
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11202827282/npm-package-cloudflare-workers-shared-6903

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.80.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240925.0
workerd 1.20240925.0 1.20240925.0
workerd --version 1.20240925.0 2024-09-25

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@petebacondarwin petebacondarwin added the e2e Run e2e tests on a PR label Oct 6, 2024
@petebacondarwin petebacondarwin merged commit 54924a4 into main Oct 7, 2024
28 of 31 checks passed
@petebacondarwin petebacondarwin deleted the pbd/alias-config-dev-env-6898 branch October 7, 2024 10:41
@workers-devprod workers-devprod mentioned this pull request Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: [alias] no longer working in wrangler dev in v3.80.0
3 participants