I am setting globalThis.document in my main.ts and expected this to be available to imported modules, but get an error when I execute:
deno run -c tsconfig.json main.ts
error: Uncaught ReferenceError: document is not defined
Is this behaviour correct? Is there another way to inject globals, to implement SSR for example via a simulated DOM?
tsconfig.json:
{
"compilerOptions": {
"target": "ES2015",
"lib": [
"dom",
"esnext"
]
}
}
main.ts:
globalThis.document = {} as any;
window.document = {} as any;
import {
attr,
customElement,
FASTElement,
html,
Observable,
} from "https://cdn.skypack.dev/@microsoft/fast-element?dts";