-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetEsModules.js
More file actions
37 lines (33 loc) · 930 Bytes
/
getEsModules.js
File metadata and controls
37 lines (33 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.46/deno-dom-wasm.ts";
const file = Deno.args[0];
// Create a global window object using DOMParser
const window = new DOMParser().parseFromString(
"<!DOCTYPE html><html><body></body></html>",
"text/html",
);
// Mock global objects
globalThis.document = window;
globalThis.window = window;
globalThis.location = new URL("https://zaubrik.de");
globalThis.HTMLElement = class {
constructor() {
this.style = {};
}
};
globalThis.window.customElements = {};
globalThis.window.customElements.define = function () {
return;
};
import(file)
.then((module) => {
const modulesString = Object.entries(module)
.reduce((acc, [key, value]) => {
acc += key === "default" ? `${value.name} (default)\n` : `${key}\n`;
return acc;
}, "")
.trim();
console.log(modulesString);
})
.catch((err) => {
console.log(err);
});