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

Add builtin modules with node: prefix #13311

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions lib/node/NodeTargetPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,95 @@ const ExternalsPlugin = require("../ExternalsPlugin");
/** @typedef {import("../Compiler")} Compiler */

const builtins = [
"node:assert",
"assert",
"node:async_hooks",
"async_hooks",
"node:buffer",
"buffer",
"node:child_process",
"child_process",
"node:cluster",
"cluster",
"node:console",
"console",
"node:constants",
"constants",
"node:crypto",
"crypto",
"node:dgram",
"dgram",
"node:dns",
"dns",
"node:dns/promises",
"dns/promises",
"node:domain",
"domain",
"node:events",
"events",
"node:fs",
"fs",
"node:fs/promises",
"fs/promises",
"node:http",
"http",
"node:http2",
"http2",
"node:https",
"https",
"node:inspector",
"inspector",
"node:module",
"module",
"node:net",
"net",
"node:os",
"os",
"node:path",
"path",
"node:perf_hooks",
"perf_hooks",
"node:process",
"process",
"node:punycode",
"punycode",
"node:querystring",
"querystring",
"node:readline",
"readline",
"node:repl",
"repl",
"node:stream",
"stream",
"node:stream/promises",
"stream/promises",
"node:string_decoder",
"string_decoder",
"node:sys",
"sys",
"node:timers",
"timers",
"node:timers/promises",
"timers/promises",
"node:tls",
"tls",
"node:trace_events",
"trace_events",
"node:tty",
"tty",
"node:url",
"url",
"node:util",
"util",
"node:v8",
"v8",
"node:vm",
"vm",
"node:wasi",
"wasi",
"node:worker_threads",
"worker_threads",
"node:zlib",
"zlib",

// cspell:word pnpapi
Expand Down
2 changes: 1 addition & 1 deletion test/configCases/target/amd-unnamed/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
it("should run", function() {});

it("should name define", function() {
var fs = require("fs");
var fs = require("node:fs");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add new tests, don't modify exists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote above, I don't understand how to add new tests here - I tried :)

var source = fs.readFileSync(__filename, "utf-8");

expect(source).toMatch(/define\(\[[^\]]*\], (function)?\(/);
Expand Down