From 8936e44d0014b95cc89bc4ecfe0d17ca259bb4f2 Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 8 Oct 2023 09:17:30 +0200 Subject: [PATCH] test no fs writing --- plugins/2-register-components.ts | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 plugins/2-register-components.ts diff --git a/plugins/2-register-components.ts b/plugins/2-register-components.ts deleted file mode 100644 index e413747..0000000 --- a/plugins/2-register-components.ts +++ /dev/null @@ -1,27 +0,0 @@ -import * as fs from "fs"; - -export default defineNitroPlugin(async () => { - console.log("Building registry of custom elements..."); - const rawKeys = await useStorage().getKeys("/assets/components"); - const keys = rawKeys.map((key) => key.replace("assets:components:", "")); - console.log("Found components:", keys); - const imports = keys.map((key, index) => { - return `import C${index} from "./${key}"`; - }); - - const registryObject = `const registry = { - ${keys - .map((key, index) => { - const name = key.replace(".js", "").replace(".ts", ""); - return `"${name}": C${index}`; - }) - .join(",")}}`; - - const customElementsDefine = `Object.keys(registry).forEach((key) => {if(window?.hasOwnProperty("customElements"))customElements.define(key, registry[key]);})`; - - if (!fs.existsSync("./public/.output")) fs.mkdirSync("./public/.output"); - fs.writeFileSync( - "./public/.output/registry.js", - [...imports, registryObject, customElementsDefine].join(";") - ); -});