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

Prioritise workerd condition when bundling #2629

Merged
merged 4 commits into from
Jan 27, 2023
Merged

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Jan 27, 2023

What this PR solves / how to test:

This PR adds support for the workerd condition when bundling Worker code. This can be used to implement isomorphic libraries that work with different JavaScript runtimes. workerd is the standard key for the Cloudflare Workers runtime: https://runtime-keys.proposal.wintercg.org/#workerd.

To test this PR, run npx wrangler dev in the fixtures/worker-app directory, and visit http://127.0.0.1:8787/random in your browser. Note that random data appears. We haven't enabled Node.js compatibility so we must be using the workerd version of the isomorphic-random-example package.

Associated docs issues/PR:

Author has included the following, where applicable:

  • Tests
  • Changeset

Reviewer has performed the following, where applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

@mrbbot mrbbot requested a review from a team as a code owner January 27, 2023 10:47
@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2023

🦋 Changeset detected

Latest commit: fc3d4a7

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

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

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

@mrbbot mrbbot requested a review from jasnell January 27, 2023 10:49
@github-actions
Copy link
Contributor

github-actions bot commented Jan 27, 2023

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/4025095389/npm-package-wrangler-2629

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

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

Or you can use npx with this latest build directly:

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

Copy link
Contributor

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

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

Super cool!

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #2629 (fc3d4a7) into main (04d8a31) will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2629      +/-   ##
==========================================
+ Coverage   73.32%   73.35%   +0.03%     
==========================================
  Files         159      159              
  Lines        9852     9852              
  Branches     2627     2627              
==========================================
+ Hits         7224     7227       +3     
+ Misses       2628     2625       -3     
Impacted Files Coverage Δ
packages/wrangler/src/bundle.ts 90.33% <ø> (ø)
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

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM - personally I would prefer a bit more explanation in the changeset file, since this is what will appear in the changelog as documentation. For example you could add this sentence from the PR description:

This can be used to implement isomorphic libraries that work with different JavaScript runtimes. workerd is the standard key for the Cloudflare Workers runtime: https://runtime-keys.proposal.wintercg.org/#workerd.

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

This looks great! What about adding an e2e test, as well?

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Awesome.

@mrbbot mrbbot merged commit 151733e into main Jan 27, 2023
@mrbbot mrbbot deleted the bcoll/workerd-condition branch January 27, 2023 14:04
@github-actions github-actions bot mentioned this pull request Jan 27, 2023
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.

6 participants