Skip to content

Conversation

@richardscarrott
Copy link
Contributor

@richardscarrott richardscarrott commented Oct 30, 2023

What this PR solves / how to test:

We want to import and use the AsyncLocalStorage polyfil in our Remix app, deployed to CF Pages.

However, to ensure Remix sourcemaps actually align with the executed code, we tell wrangler not to bundle our code and instead use Advanced Mode (_worker.js file).

npx wrangler pages deploy dist --project-name="${{ inputs.cloudflare_app }}" --branch="${{ inputs.cf_branch }}" --no-bundle

This fails with:

_worker.js is not being bundled by Wrangler but it is importing from another file. This will throw an error if deployed. You should bundle the Worker in a pre-build step, remove the import if it is unused, or ask Wrangler to bundle it by setting--bundle

Screenshot 2023-10-29 at 18 09 41

After some discussion in Discord, I believe this is a mistake because node:async_hooks is available to import at runtime and doesn't depend on a build step.

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because:

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@richardscarrott richardscarrott requested review from a team as code owners October 30, 2023 09:45
@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2023

🦋 Changeset detected

Latest commit: 5fac1d2

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 Oct 30, 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/7976171568/npm-package-wrangler-4303

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

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

Or you can use npx with this latest build directly:

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

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240129.3
workerd 1.20240129.0 1.20240129.0
workerd --version 1.20240129.0 2024-01-29

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

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (01e0846) 70.34% compared to head (5fac1d2) 70.40%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4303      +/-   ##
==========================================
+ Coverage   70.34%   70.40%   +0.05%     
==========================================
  Files         298      298              
  Lines       15463    15470       +7     
  Branches     3966     3969       +3     
==========================================
+ Hits        10877    10891      +14     
+ Misses       4586     4579       -7     
Files Coverage Δ
packages/wrangler/src/api/pages/deploy.tsx 86.36% <100.00%> (ø)
...ckages/wrangler/src/pages/functions/buildWorker.ts 74.50% <100.00%> (+3.67%) ⬆️
packages/wrangler/src/pages/dev.ts 16.16% <0.00%> (-0.06%) ⬇️

... and 6 files with indirect coverage changes

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.

DONT MERGE - just testing approval

@petebacondarwin petebacondarwin self-requested a review October 30, 2023 14:19
@petebacondarwin petebacondarwin dismissed their stale review October 30, 2023 14:20

It was a test

Copy link
Contributor

@Skye-31 Skye-31 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Could you add a test (see https://github.com/cloudflare/workers-sdk/blob/main/fixtures/pages-workerjs-app/tests/index.test.ts#L8), as well as a changeset (pnpx changeset in the root of the repo)

@penalosa
Copy link
Contributor

Apologies for the delay here—this is looking good! Before merging, could you add a unit test to https://github.com/cloudflare/workers-sdk/tree/main/packages/wrangler/src/__tests__/pages/deploy.test.ts ? I don't think this change will need a full fixture test

@petebacondarwin petebacondarwin added pages Relating to Pages awaiting reporter response Needs clarification or followup from OP bug Something that isn't working labels Jan 26, 2024
@lrapoport-cf
Copy link
Contributor

hi @richardscarrott :) could you please add a unit test (per @penalosa 's comment)? else we'll close the PR and you can re-open when you're able to revisit and make the relevant changes. thanks!

@mrbbot mrbbot added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Feb 7, 2024
@penalosa penalosa added awaiting reporter response Needs clarification or followup from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Feb 19, 2024
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.

One small comment but otherwise LGTM!
Thanks

// Otherwise, block any imports that the file is requesting
// If it's a node or cf built-in, mark it as external
if (
args.path.startsWith("node:") ||
Copy link
Contributor

Choose a reason for hiding this comment

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

OK so I think we just need a bit of care here.
We should only consider imports beginning with node: as external if the nodejs_compat flag is actually turned on.

We can pass that through to this plugin by making it a function with a parameter, I believe.

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.

I rebased, swapped out the fixture tests for unit tests, and added the check for the nodejs_compat flag.

@penalosa - PTAL

@petebacondarwin petebacondarwin removed the awaiting reporter response Needs clarification or followup from OP label Feb 19, 2024
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.

One misplaced comment, but LGTM

@petebacondarwin petebacondarwin merged commit 1c46028 into cloudflare:main Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something that isn't working pages Relating to Pages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants