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 pages functions using unenv aliased packages #8021

Merged
merged 10 commits into from
Feb 14, 2025

Conversation

0xD34DC0DE
Copy link
Contributor

@0xD34DC0DE 0xD34DC0DE commented Feb 4, 2025

Fixes #7572

  • Added a test fixture to test the edge case where pages functions using nodejs_compat (v2) together with the import of an npm package getting aliased by unenv would trigger the addition of __cf_cjs multiple times
  • Replace the __cf_cjs esm to cjs converter function by an inline expression to avoid the use of esbuild banners that might get included in the bundle multiple time.

A separate fixture has been created to avoid making all tests in fixtures\pages-nodejs-v2-compat fail for an unrelated reason since the runtime fails to start when the issue is present.
The test fixture was inspired by the nodejs-hybrid-app and pages-nodejs-v2-compat fixtures.


  • 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: should be adequately covered by fixtures
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Bugfix

@0xD34DC0DE 0xD34DC0DE requested a review from a team as a code owner February 4, 2025 04:05
Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 7350ca0

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 Feb 5, 2025

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/13324132685/npm-package-wrangler-8021

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-wrangler-8021 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-workers-bindings-extension-8021 -O ./cloudflare-workers-bindings-extension.0.0.0-v9ca029b6f.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v9ca029b6f.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-create-cloudflare-8021 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-kv-asset-handler-8021

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-miniflare-8021

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-pages-shared-8021

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-unenv-preset-8021

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-vite-plugin-8021

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-vitest-pool-workers-8021

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-workers-editor-shared-8021

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-workers-shared-8021

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13324132685/npm-package-cloudflare-workflows-shared-8021

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.20250204.1
workerd 1.20250204.0 1.20250204.0
workerd --version 1.20250204.0 2025-02-04

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

@petebacondarwin
Copy link
Contributor

The good news is that our test coverage seems to check these changes!
The bad news is that they appear to be unhappy with this change.

@0xD34DC0DE
Copy link
Contributor Author

The good news is that our test coverage seems to check these changes!
The bad news is that they appear to be unhappy with this change.

Thanks for the review, I'll try to see why the tests aren't successful when they're executed on the CI, my first guess would be the use of transitive includes (cross-fetch and cross-env)?

add missing comparison
handle nullish 'default' and ensure enumerable properties
remove unnecessary packages from fixture
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your work on this - and coping with my reviews ;)

One last comment and this should be good to go

0xD34DC0DE and others added 3 commits February 12, 2025 14:17
use toEqual instead of toMatchInlineSnapshot
Use direct 'require' instead of intermediate dependency
@vicb
Copy link
Contributor

vicb commented Feb 14, 2025

@0xD34DC0DE Sorry I was bad at following up here. Thanks for your work here and let's get this in today

@vicb vicb merged commit 28b1dc7 into cloudflare:main Feb 14, 2025
24 checks passed
@workers-devprod workers-devprod added the contribution [Holopin] Recognizes an open-source contribution, big or small label Feb 14, 2025
Copy link

holopin-bot bot commented Feb 14, 2025

Congratulations @0xD34DC0DE, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm74jng4052780clav2yk5rnz

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

@vicb
Copy link
Contributor

vicb commented Feb 14, 2025

Merci Émerick and sorry again for letting this unattended for so long :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution [Holopin] Recognizes an open-source contribution, big or small
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler pages dev failing with error on Identifier '__cf_cjs' has already been declared
4 participants