Skip to content

fix(server): support access globalThis in esm vm#4953

Merged
9aoy merged 2 commits intomainfrom
esm-global-this
Apr 3, 2025
Merged

fix(server): support access globalThis in esm vm#4953
9aoy merged 2 commits intomainfrom
esm-global-this

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Apr 3, 2025

Summary

Fix ssr render error. support access globalThis attributes in esm vm, like TextEncoder.

We need to use vm.SourceTextModule to run ESM code in the current context like it was possible with CJS with vm.runInThisContext.

  • Remove context specified, run esm code in current context (allow access globalThis attributes).
  • Use vm.SyntheticModule instead of legacy hard code which dependent context

https://nodejs.org/api/vm.html

image image

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Apr 3, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit ddfb0b7
🔍 Latest deploy log https://app.netlify.com/sites/rsbuild/deploys/67ee349d6a44e80008fda58e
😎 Deploy Preview https://deploy-preview-4953--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 73 (🟢 up 3 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@9aoy 9aoy enabled auto-merge (squash) April 3, 2025 08:34
@9aoy 9aoy requested a review from chenjiahan April 3, 2025 08:35
@9aoy 9aoy merged commit 6169d5c into main Apr 3, 2025
14 checks passed
@9aoy 9aoy deleted the esm-global-this branch April 3, 2025 08:53
@chenjiahan chenjiahan mentioned this pull request Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants