mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
- node:punycode: encode, decode, toASCII, toUnicode, ucs2.decode, ucs2.encode and version, ported from the punycode.js 2.1.0 Node bundles (scr_url.c), with its RangeErrors. DEP0040 follows Node: a static ES import reports before any module evaluates and before the program can register a 'warning' listener; require() reports on the next tick, once for both spellings, not when a dependency under node_modules loads the module first, and not under process.noDeprecation. - node:constants: the frozen object Node builds from os.constants' dlopen, errno, priority and signals groups, fs.constants (node_constants.cc order and guards) and crypto.constants (scr_os.c); its bindings read it as a checked-dynamic value. These unblock tr46 (whatwg-url, node-fetch@2) and graceful-fs (fs-extra). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
// DEP0040 for require("punycode"): reported once, on the next tick after
|
|
// the requiring turn, to the stderr report and the 'warning' listeners;
|
|
// require("node:punycode") is the same module and does not report again.
|
|
// process.noDeprecation drops the report and the listener call. The program
|
|
// re-runs itself per case and prints each child's output with process ids
|
|
// normalized.
|
|
"use strict";
|
|
const { spawnSync } = require("child_process");
|
|
|
|
const mode = process.argv[2];
|
|
if (mode === "direct") {
|
|
process.on("warning", (w) => console.log("listener", w.name, w.code, w.message));
|
|
process.nextTick(() => console.log("earlier tick"));
|
|
console.log("before require");
|
|
const direct = require("punycode");
|
|
console.log("after require", direct.toASCII("bücher.de"));
|
|
const prefixed = require("node:punycode");
|
|
console.log("prefixed", prefixed.toUnicode("xn--bcher-kva.de"));
|
|
setTimeout(() => console.log("timer"), 0);
|
|
} else if (mode === "silenced") {
|
|
process.on("warning", (w) => console.log("listener", w.code));
|
|
process.noDeprecation = true;
|
|
const silencedModule = require("punycode");
|
|
console.log("silenced", silencedModule.encode("ü"));
|
|
} else {
|
|
for (const child of ["direct", "silenced"]) {
|
|
const run = spawnSync(process.execPath, [process.argv[1], child], { encoding: "utf8" });
|
|
console.log(`== ${child}: status ${run.status}`);
|
|
console.log(run.stdout);
|
|
console.log(run.stderr.replace(/\(node:\d+\)/g, "(node:<pid>)"));
|
|
}
|
|
}
|