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 dynamic chunk loading on wrangler pages dev for _worker.js/ directory #3175

Merged
merged 3 commits into from
May 15, 2023

Conversation

GregBrimble
Copy link
Member

@GregBrimble GregBrimble commented May 10, 2023

Fixes #3148.

What this PR solves / how to test:

Associated docs issue(s)/PR(s):

  • [insert associated docs issue(s)/PR(s)]

Author has included the following, where applicable:

Reviewer is to perform the following, as 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

@changeset-bot
Copy link

changeset-bot bot commented May 10, 2023

🦋 Changeset detected

Latest commit: 574561d

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

@github-actions
Copy link
Contributor

github-actions bot commented May 10, 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/workers-sdk/runs/4981081436/npm-package-wrangler-3175

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

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

Or you can use npx with this latest build directly:

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

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

@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

Merging #3175 (742dee4) into main (7e58071) will decrease coverage by 0.03%.
The diff coverage is 56.66%.

❗ Current head 742dee4 differs from pull request most recent head 574561d. Consider uploading reports for the commit 574561d to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3175      +/-   ##
==========================================
- Coverage   74.62%   74.59%   -0.03%     
==========================================
  Files         179      179              
  Lines       10926    11031     +105     
  Branches     2908     2934      +26     
==========================================
+ Hits         8153     8229      +76     
- Misses       2773     2802      +29     
Impacted Files Coverage Δ
packages/wrangler/src/dev.tsx 85.18% <ø> (+0.06%) ⬆️
...ckages/wrangler/src/pages/functions/buildWorker.ts 68.53% <ø> (ø)
packages/wrangler/src/pages/dev.ts 17.33% <7.69%> (-0.81%) ⬇️
packages/wrangler/src/dev/start-server.ts 67.26% <75.00%> (-0.21%) ⬇️
packages/wrangler/src/api/dev.ts 59.34% <100.00%> (ø)
packages/wrangler/src/bundle.ts 93.64% <100.00%> (+0.25%) ⬆️
packages/wrangler/src/traverse-module-graph.ts 100.00% <100.00%> (ø)

... and 22 files with indirect coverage changes

@@ -457,16 +459,18 @@ export async function bundleWorker(
entryPointOutputs[0][0]
);

const modules = [...additionalModules, ...moduleCollector.modules];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that additionalModules and moduleCollector.modules contain duplicates?
Do we care? Probably not here, since all we are doing is writing them out to the directory containing the entry-point, so we just waste some time writing files more than once.

But this modules array is returned and could that result in multiple copies of the same file being added to an HTTP Form?

Copy link
Member Author

Choose a reason for hiding this comment

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

HTTP form defaults automatically de-dupes by preferring the last entry. Workerd crashed. I added this commit to more gracefully handle the unlikely case of a collision: 742dee4

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.

There is a test! It was previously erroneously passing.
So despite there being annotations about code coverage this is actually checked by that test.

We do need a changeset though!

@dario-piotrowicz
Copy link
Member

dario-piotrowicz commented May 11, 2023

is this missing a changeset?

Pete already asked for it, sorry I missed that 🙈

packages/wrangler/src/bundle.ts Outdated Show resolved Hide resolved
packages/wrangler/src/bundle.ts Outdated Show resolved Hide resolved
@GregBrimble GregBrimble force-pushed the fix-dynamic-chunk-loading-pages-dev branch from 9251a83 to 0821ad1 Compare May 15, 2023 10:52
@GregBrimble GregBrimble marked this pull request as ready for review May 15, 2023 10:57
@GregBrimble GregBrimble requested review from a team as code owners May 15, 2023 10:57
@GregBrimble GregBrimble merged commit 561b962 into main May 15, 2023
@GregBrimble GregBrimble deleted the fix-dynamic-chunk-loading-pages-dev branch May 15, 2023 13:51
@github-actions github-actions bot mentioned this pull request May 15, 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.

🐛 BUG: Dynamic variable chunk imports aren't found when using _worker.js/ directory
4 participants