Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Sep 11, 2025

The native code appears in workerd as of https://github.com/cloudflare/workerd/releases/tag/v1.20250910.0.
It was turned on by default (when nodejs_compat is on) on 2025-10-01.

The remote mode tests would fail if we didn't have a version of workerd in prod that supports this.

Export workerd unenv diff
new Script throws fake script object different
Script.runInContext throws throws same
Script.runInNewContext throws throws same
Script.runInThisContext throws throws same
Script.createCachedData throws throws same
constants object object same
compileFunction throws throws same
createContext throws returns fake context object different
createScript throws returns new Script different
isContext returns false returns true if fake context obj n/a since no way to create in workerd
measureMemory throws returns fake promise different
runInContext throws throws same
runInThisContext throws throws same
runInNewContext throws throws same
  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal change
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: unenv is not backported

@petebacondarwin petebacondarwin requested a review from a team September 11, 2025 15:54
@petebacondarwin petebacondarwin requested a review from a team as a code owner September 11, 2025 15:54
@changeset-bot
Copy link

changeset-bot bot commented Sep 11, 2025

🦋 Changeset detected

Latest commit: cdd5733

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

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 11, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10621

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10621

miniflare

npm i https://pkg.pr.new/miniflare@10621

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10621

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10621

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10621

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10621

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10621

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@10621

wrangler

npm i https://pkg.pr.new/wrangler@10621

commit: cdd5733

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.

Changes look good to me.

Could you please add to the PR description what this depends on (the PR in workerd) and in what release is first appears.

Also please update the peer dep on workerd in the unenv-preset to that date

@github-project-automation github-project-automation bot moved this from Untriaged to In Review in workers-sdk Sep 12, 2025
@petebacondarwin petebacondarwin changed the title Use native node:vm modue when available Use native node:vm module when available Sep 12, 2025
@petebacondarwin petebacondarwin marked this pull request as ready for review October 6, 2025 11:53
@petebacondarwin petebacondarwin requested a review from vicb October 6, 2025 11:53
vicb
vicb previously requested changes Oct 6, 2025
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.

This PR is a breaking change for compat date >= 2025-10-01 as some workerd function throws when unenv polyfill would not.

Could you please details all of those difference in the PR description.

IIRC Next.js uses some of those vm APIs so OpenNext might break after updating wrangler past this PR. We should at least run the Open Next e2e test suite with a compat date after October 1st.

@petebacondarwin
Copy link
Contributor Author

There are two main differences between the two implementations:

  • workerd will throw when you call createContext() whereas unenv returns a fake context object
  • workerd will throw if you create a new Script whereas unenv returns a fake script object

If these two are changed then the rest of the differences go away.

@petebacondarwin
Copy link
Contributor Author

Blocked on cloudflare/workerd#5606

@petebacondarwin petebacondarwin marked this pull request as draft November 28, 2025 12:46
@petebacondarwin petebacondarwin moved this from In Review to In Progress in workers-sdk Nov 28, 2025
@petebacondarwin
Copy link
Contributor Author

The upstream PR has now landed, so this will be unblocked when it is released tomorrow.

@github-project-automation github-project-automation bot moved this from In Progress to Approved in workers-sdk Dec 2, 2025
@vicb vicb marked this pull request as ready for review December 2, 2025 18:58
@vicb vicb removed the blocked Blocked on other work label Dec 2, 2025
@vicb
Copy link
Contributor

vicb commented Dec 3, 2025

rebased + bump workerd to 1202 where the console implementation has been merged

@vicb vicb merged commit 0aa959a into main Dec 4, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Dec 4, 2025
@vicb vicb deleted the pbd/unenv/vm branch December 4, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants