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

fix(ext/node): have process global available in Node context #27562

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ext/node/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,24 @@ const fn str_to_utf16<const N: usize>(s: &str) -> [u16; N] {
// - clearTimeout (both, but different implementation)
// - global (node only)
// - performance (both, but different implementation)
// - process (always available in Node, while the availability in Deno depends
// on project creation time in Deno Deploy)
// - setImmediate (node only)
// - setInterval (both, but different implementation)
// - setTimeout (both, but different implementation)
// - window (deno only)

// UTF-16 encodings of the managed globals. THIS LIST MUST BE SORTED.
#[rustfmt::skip]
const MANAGED_GLOBALS: [&[u16]; 12] = [
const MANAGED_GLOBALS: [&[u16]; 13] = [
&str_to_utf16::<6>("Buffer"),
&str_to_utf16::<17>("WorkerGlobalScope"),
&str_to_utf16::<14>("clearImmediate"),
&str_to_utf16::<13>("clearInterval"),
&str_to_utf16::<12>("clearTimeout"),
&str_to_utf16::<6>("global"),
&str_to_utf16::<11>("performance"),
&str_to_utf16::<7>("process"),
&str_to_utf16::<4>("self"),
&str_to_utf16::<12>("setImmediate"),
&str_to_utf16::<11>("setInterval"),
Expand Down
4 changes: 3 additions & 1 deletion ext/node/polyfills/01_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ Module.prototype.require = function (id) {
// wrapper function we run the users code in. The only observable difference is
// that in Deno `arguments.callee` is not null.
Module.wrapper = [
"(function (exports, require, module, __filename, __dirname, Buffer, clearImmediate, clearInterval, clearTimeout, global, setImmediate, setInterval, setTimeout, performance) { (function (exports, require, module, __filename, __dirname) {",
"(function (exports, require, module, __filename, __dirname, Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout, performance) { (function (exports, require, module, __filename, __dirname) {",
"\n}).call(this, exports, require, module, __filename, __dirname); })",
];
Module.wrap = function (script) {
Expand Down Expand Up @@ -1031,6 +1031,7 @@ Module.prototype._compile = function (content, filename, format) {
clearInterval,
clearTimeout,
global,
process,
setImmediate,
setInterval,
setTimeout,
Expand All @@ -1049,6 +1050,7 @@ Module.prototype._compile = function (content, filename, format) {
clearInterval,
clearTimeout,
global,
process,
setImmediate,
setInterval,
setTimeout,
Expand Down
Loading