dom_global_native.mjs simply exports global = globalThis
. It's a counterpart to dom_global_shim
. When writing code to run in both non-DOM and DOM environments, configure your bundler or importmap to import dom_global_shim
in non-browsers, and dom_global_native
in browsers.
In code intended only for browsers, simply use DOM globals. In code intended only for Deno or Node, simply import dom_global_shim
.
/*
Use a bundler or importmap to alias this import to one of:
https://cdn.jsdelivr.net/npm/@mitranim/[email protected]/dom_global_native.mjs
https://cdn.jsdelivr.net/npm/@mitranim/[email protected]/dom_global_shim.mjs
*/
import * as dg from 'dom_global'
console.log(dg.global)
The following APIs are exported but undocumented. Check dom_global_native.mjs.