mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 23:59:59 -05:00
fix(std/node): only define Node.js globals when loading std/node/global (#8281)
This commit is contained in:
parent
bb1a673b21
commit
9fc5b6510c
3 changed files with 25 additions and 21 deletions
|
@ -599,10 +599,3 @@ export default class Buffer extends Uint8Array {
|
|||
}
|
||||
|
||||
export { Buffer };
|
||||
|
||||
Object.defineProperty(globalThis, "Buffer", {
|
||||
value: Buffer,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import process from "./process.ts";
|
||||
import { Buffer as buffer } from "./buffer.ts";
|
||||
|
||||
Object.defineProperty(globalThis, Symbol.toStringTag, {
|
||||
value: "global",
|
||||
|
@ -10,4 +12,27 @@ Object.defineProperty(globalThis, Symbol.toStringTag, {
|
|||
// deno-lint-ignore no-explicit-any
|
||||
(globalThis as any)["global"] = globalThis;
|
||||
|
||||
// Define the type for the global declration
|
||||
type Process = typeof process;
|
||||
type Buffer = typeof buffer;
|
||||
|
||||
Object.defineProperty(globalThis, "process", {
|
||||
value: process,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
declare global {
|
||||
const process: Process;
|
||||
const Buffer: Buffer;
|
||||
}
|
||||
|
||||
Object.defineProperty(globalThis, "Buffer", {
|
||||
value: buffer,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
export {};
|
||||
|
|
|
@ -142,23 +142,9 @@ export const env = new Proxy(process.env, {});
|
|||
// import process from './std/node/process.ts'
|
||||
export default process;
|
||||
|
||||
// Define the type for the global declration
|
||||
type Process = typeof process;
|
||||
|
||||
Object.defineProperty(process, Symbol.toStringTag, {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: false,
|
||||
value: "process",
|
||||
});
|
||||
|
||||
Object.defineProperty(globalThis, "process", {
|
||||
value: process,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
declare global {
|
||||
const process: Process;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue