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

Edge Runtime Incompatibility #31

Closed
LilaRest opened this issue Jan 22, 2025 · 5 comments
Closed

Edge Runtime Incompatibility #31

LilaRest opened this issue Jan 22, 2025 · 5 comments

Comments

@LilaRest
Copy link

Hello @ljharb!
First, thanks for all the hard work on your libraries.

Our NextJS builds are failing with the following error since our last dependencies upgrade:

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
The error was caused by importing 'traverse/index.js' in 'REDACTED'

After hours of investigation, it led us to this repository and is-generator-function. Those two are using Function('return async function () {}')(); which is considered dynamic code by the compiler.

We are not using these two libraries directly, but instead use traverse which indirectly relies on those two libraries. And it's likely that in the most recent version of traverse (or of one of its dependencies), is-async-function and is-generator-function have been introduced as dependencies, so breaking our builds.

Is there an easy way for you to remove these "dynamic code" parts to unlock edge runtime support? Or should we explore other solutions?

@ljharb
Copy link
Member

ljharb commented Jan 22, 2025

(linking to inspect-js/is-generator-function#44)

@ljharb ljharb closed this as completed in 09fd6c3 Jan 23, 2025
@ljharb
Copy link
Member

ljharb commented Jan 23, 2025

I've published async-function and refactored this package to use it, so now this package has no more Function usage - and async-function uses multiple entry points, only the "legacy" of which uses Function. The hope is that your bundler should automatically pick up the pure syntax version, and everything will Just Work without any configuration changes.

@LilaRest
Copy link
Author

Hey @ljharb! I just tested the fix and it did it!
Will you be pushing a similar fix for inspect-js/is-generator-function#44 ?
Thanks!

@ljharb
Copy link
Member

ljharb commented Jan 23, 2025

Awesome! Yep, I'm planning to do that as well, and I'll also update a number of other deeply-depended-on packages to use them too.

@LilaRest
Copy link
Author

@ljharb Fantastic! Thanks again!

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

No branches or pull requests

2 participants