diff --git a/package-lock.json b/package-lock.json index 2667fe3..f529086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "ts-standard": "^12.0.2", "typescript": "^5.2.2", "vite": "^4.4.11", + "vite-plugin-dynamic-import": "^1.5.0", "vite-plugin-node-polyfills": "^0.15.0" } }, @@ -1927,6 +1928,12 @@ "safe-array-concat": "^1.0.1" } }, + "node_modules/es-module-lexer": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.1.tgz", + "integrity": "sha512-JUFAyicQV9mXc3YRxPnDlrfBKpqt6hUYzz9/boprUJHs4e4KVr3XwOF70doO6gwXUor6EWZJAyWAfKki84t20Q==", + "dev": true + }, "node_modules/es-set-tostringtag": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", @@ -5930,6 +5937,18 @@ } } }, + "node_modules/vite-plugin-dynamic-import": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.5.0.tgz", + "integrity": "sha512-Qp85c+AVJmLa8MLni74U4BDiWpUeFNx7NJqbGZyR2XJOU7mgW0cb7nwlAMucFyM4arEd92Nfxp4j44xPi6Fu7g==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "es-module-lexer": "^1.2.1", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.1" + } + }, "node_modules/vite-plugin-node-polyfills": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/vite-plugin-node-polyfills/-/vite-plugin-node-polyfills-0.15.0.tgz", diff --git a/package.json b/package.json index 681f14b..d62f652 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "ts-standard": "^12.0.2", "typescript": "^5.2.2", "vite": "^4.4.11", + "vite-plugin-dynamic-import": "^1.5.0", "vite-plugin-node-polyfills": "^0.15.0" }, "dependencies": { diff --git a/src/statusbar.ts b/src/statusbar.ts index 6f6ed86..74a2146 100644 --- a/src/statusbar.ts +++ b/src/statusbar.ts @@ -3,12 +3,12 @@ import { StatusItem } from './types' class StatusBar { pluginList: string[] = [ - './modules/appLauncher.ts', - './modules/apps.ts', - './modules/weather.ts', - './modules/clock.ts', - './modules/switcher.ts', - './modules/battery.ts' + 'appLauncher', + 'apps', + 'weather', + 'clock', + 'switcher', + 'battery' ] plugins: StatusItem[] = [] @@ -40,7 +40,7 @@ class StatusBar { window.preloader.setStatus('importing default plugins...') for (const pluginPath of this.pluginList) { - const plugin = await import(pluginPath) + const plugin = await import(`./modules/${pluginPath}.ts`) window.preloader.setStatus(`importing default plugins\n${pluginPath}`) this.add(plugin) diff --git a/vite.config.js b/vite.config.js index ff70d3f..ed22f22 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,8 +1,10 @@ import { defineConfig } from 'vite' import { nodePolyfills } from 'vite-plugin-node-polyfills' +import dynamicImport from 'vite-plugin-dynamic-import' export default defineConfig({ plugins: [ - nodePolyfills() + nodePolyfills(), + dynamicImport() ] })