1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

fix(std/node): only define Node.js globals when loading std/node/global (#8281)

This commit is contained in:
Guy Bedford 2020-11-07 11:27:07 -08:00 committed by GitHub
parent bb1a673b21
commit 9fc5b6510c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 21 deletions

View file

@ -599,10 +599,3 @@ export default class Buffer extends Uint8Array {
}
export { Buffer };
Object.defineProperty(globalThis, "Buffer", {
value: Buffer,
enumerable: false,
writable: true,
configurable: true,
});

View file

@ -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 {};

View file

@ -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;
}