Skip to content

Fail more gracefully on partially Node.js compatible runtime environments #25

@lovell

Description

@lovell

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions