Some JavaScript runtime environments have limitations/assumptions, for example:
"Node.js APIs are available under the node: prefix, and this prefix must be used when importing modules, both in your code and the npm packages you depend on." https://developers.cloudflare.com/workers/runtime-apis/nodejs/
We could improve support for these environments by failing more gracefully.
For example, when requireing Node.js modules, an alternative "safe require" function could be used that tries e.g. child_process then node:child_process then otherwise returns null. Failure to require a module should probably lead to APIs also returning null.
Ideally we'll be able to add an integration test for this e.g. by running Wrangler "locally" within CI.
See also #24 for some previous discussion.
Some JavaScript runtime environments have limitations/assumptions, for example:
We could improve support for these environments by failing more gracefully.
For example, when
requireing Node.js modules, an alternative "safe require" function could be used that tries e.g.child_processthennode:child_processthen otherwise returnsnull. Failure torequirea module should probably lead to APIs also returningnull.Ideally we'll be able to add an integration test for this e.g. by running Wrangler "locally" within CI.
See also #24 for some previous discussion.