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] = &[
"_stream_writable",
"_tls_common",
"_tls_wrap",
"assert",
"assert/strict",
"async_hooks",
"buffer",
// "assert",
// "assert/strict",
// "async_hooks",
// "buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
// "crypto",
"dgram",
"diagnostics_channel",
// "diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
// "events",
"fs",
"fs/promises",
"http",
......@@ -100,21 +100,21 @@ const NODEJS_MODULE_NAMES: &[&str] = &[
"module",
"net",
"os",
"path",
"path/posix",
"path/win32",
// "path",
// "path/posix",
// "path/win32",
"perf_hooks",
"process",
// "process",
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
"stream",
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
// "stream",
// "stream/consumers",
// "stream/promises",
// "stream/web",
// "string_decoder",
"sys",
"timers",
"timers/promises",
......@@ -122,8 +122,8 @@ const NODEJS_MODULE_NAMES: &[&str] = &[
"trace_events",
"tty",
"url",
"util",
"util/types",
// "util",
// "util/types",
"v8",
"vm",
"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', () => {
},
},
])('$title statically importing node.js module', ({ init, url }) => {
const moduleName = 'path'
const moduleName = 'fs'
const importStatement = `import { basename } from "${moduleName}"`
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