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

feat:wrangler dev with dynamic sites + miniflare assets plugin #6564

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Aug 23, 2024

What this PR solves / how to test

This creates a new assets miniflare plugin. The Asset Worker and Router Worker are imported from workers-shared and used as miniflare services. If assets are detected, the miniflare entry worker will always point towards the Router Worker instead of the User Worker like it usually does.

We also add in a config object that can be passed to Router Worker. Currently this only contains {hasUserWorker: boolean}, but will be used later for other routing config.

User Worker + Assets diagram. If there is no UW, this remains the same except wrangler provides a no-op worker that cannot be reached.

diagram

Author has addressed the following

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

Copy link

changeset-bot bot commented Aug 23, 2024

🦋 Changeset detected

Latest commit: 3b4d90f

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

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

@emily-shen emily-shen force-pushed the emily/assets-plugin-refactor branch from 96da898 to 6ef84d5 Compare August 23, 2024 10:40
@emily-shen emily-shen changed the title [wip] wrangler dev with dynamic sites feat:wrangler dev with dynamic sites + miniflare assets plugin Aug 23, 2024
Copy link
Contributor

github-actions bot commented Aug 23, 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/10634012860/npm-package-wrangler-6564

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

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

Or you can use npx with this latest build directly:

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

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


wrangler@3.73.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240821.0
workerd 1.20240821.1 1.20240821.1
workerd --version 1.20240821.1 2024-08-21

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

@emily-shen emily-shen force-pushed the emily/assets-plugin-refactor branch 6 times, most recently from 6ab6490 to 1c8d39b Compare August 27, 2024 14:29
@emily-shen emily-shen marked this pull request as ready for review August 27, 2024 15:11
@emily-shen emily-shen requested a review from a team as a code owner August 27, 2024 15:11
@emily-shen emily-shen force-pushed the emily/assets-plugin-refactor branch 4 times, most recently from a2883c9 to 0077d5e Compare August 28, 2024 16:25
@emily-shen emily-shen requested a review from a team as a code owner August 28, 2024 20:52
@emily-shen emily-shen added the e2e Run e2e tests on a PR label Aug 28, 2024

`workers-with-assets` is a test fixture that showcases Workers with Assets. This particular fixture sets up an assets-only Workers project.
`workers-assets-with-user-worker"` is a test fixture that showcases Workers with Assets. This particular fixture sets up a User Worker, assets, and a binding from the user Worker to the assets.
Copy link
Contributor

Choose a reason for hiding this comment

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

:meouw-heart:

@emily-shen emily-shen force-pushed the emily/assets-plugin-refactor branch from 5e56c5c to 83fcef8 Compare August 30, 2024 10:11
@@ -1250,6 +1250,7 @@ export class Miniflare {
loopbackPort,
log: this.#log,
proxyBindings,
hasWorkerAssets: !!this.#workerOpts[0].assets.assets,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a fun assignment 😆

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm...that is true

@CarmenPopoviciu CarmenPopoviciu force-pushed the emily/assets-plugin-refactor branch from 1048a0f to 514e943 Compare August 30, 2024 13:59
@CarmenPopoviciu CarmenPopoviciu force-pushed the emily/assets-plugin-refactor branch from 61909d3 to 3b4d90f Compare August 30, 2024 14:01
@emily-shen emily-shen merged commit e8975a9 into main Aug 30, 2024
24 checks passed
@emily-shen emily-shen deleted the emily/assets-plugin-refactor branch August 30, 2024 14:37
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
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants