Unverified Commit b3e434ed authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

fix: Allow subset of node.js APIs for edge (#69675)

### What?

Allow using modules listed in
https://developers.cloudflare.com/workers/runtime-apis/nodejs/ in edge
runtime.

### Why?

It's supported.

### How?
parent 2aa2bca7
...@@ -76,21 +76,21 @@ const NODEJS_MODULE_NAMES: &[&str] = &[ ...@@ -76,21 +76,21 @@ const NODEJS_MODULE_NAMES: &[&str] = &[
"_stream_writable", "_stream_writable",
"_tls_common", "_tls_common",
"_tls_wrap", "_tls_wrap",
"assert", // "assert",
"assert/strict", // "assert/strict",
"async_hooks", // "async_hooks",
"buffer", // "buffer",
"child_process", "child_process",
"cluster", "cluster",
"console", "console",
"constants", "constants",
"crypto", // "crypto",
"dgram", "dgram",
"diagnostics_channel", // "diagnostics_channel",
"dns", "dns",
"dns/promises", "dns/promises",
"domain", "domain",
"events", // "events",
"fs", "fs",
"fs/promises", "fs/promises",
"http", "http",
...@@ -100,21 +100,21 @@ const NODEJS_MODULE_NAMES: &[&str] = &[ ...@@ -100,21 +100,21 @@ const NODEJS_MODULE_NAMES: &[&str] = &[
"module", "module",
"net", "net",
"os", "os",
"path", // "path",
"path/posix", // "path/posix",
"path/win32", // "path/win32",
"perf_hooks", "perf_hooks",
"process", // "process",
"punycode", "punycode",
"querystring", "querystring",
"readline", "readline",
"readline/promises", "readline/promises",
"repl", "repl",
"stream", // "stream",
"stream/consumers", // "stream/consumers",
"stream/promises", // "stream/promises",
"stream/web", // "stream/web",
"string_decoder", // "string_decoder",
"sys", "sys",
"timers", "timers",
"timers/promises", "timers/promises",
...@@ -122,8 +122,8 @@ const NODEJS_MODULE_NAMES: &[&str] = &[ ...@@ -122,8 +122,8 @@ const NODEJS_MODULE_NAMES: &[&str] = &[
"trace_events", "trace_events",
"tty", "tty",
"url", "url",
"util", // "util",
"util/types", // "util/types",
"v8", "v8",
"vm", "vm",
"wasi", "wasi",
......
// Allowed because a subset of Node.js APIs are allowed.
import 'node:util'
import 'node:stream'
import 'node:process'
import 'node:path'
import 'node:events'
import 'node:diagnostics_channel'
import 'node:crypto'
import 'node:buffer'
import 'node:async_hooks'
import 'node:assert'
// Allowed because a subset of Node.js APIs are allowed.
import 'node:util';
import 'node:stream';
import 'node:process';
import 'node:path';
import 'node:events';
import 'node:diagnostics_channel';
import 'node:crypto';
import 'node:buffer';
import 'node:async_hooks';
import 'node:assert';
...@@ -78,7 +78,7 @@ describe('Edge runtime code with imports', () => { ...@@ -78,7 +78,7 @@ describe('Edge runtime code with imports', () => {
}, },
}, },
])('$title statically importing node.js module', ({ init, url }) => { ])('$title statically importing node.js module', ({ init, url }) => {
const moduleName = 'path' const moduleName = 'fs'
const importStatement = `import { basename } from "${moduleName}"` const importStatement = `import { basename } from "${moduleName}"`
beforeEach(() => init(importStatement)) beforeEach(() => init(importStatement))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment