Skip to content

Commit a08e577

Browse files
authored
Web: resolve only plugins with name that matches specific pattern (#828)
1 parent 5ec4583 commit a08e577

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

mwdb/web/vite.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import checker from "vite-plugin-checker";
55
import fs from "fs";
66
import { join, resolve } from "path";
77

8-
function findInstalledPlugins(namespace) {
9-
const modulesDir = join(__dirname, "node_modules", namespace);
8+
function findInstalledPlugins() {
9+
const modulesDir = join(__dirname, "node_modules", "@mwdb-web");
10+
const packageDirPattern = /^plugin-[a-zA-Z0-9\-_]+$/g;
11+
1012
if (!fs.existsSync(modulesDir)) return [];
11-
return fs.readdirSync(modulesDir);
13+
return fs.readdirSync(modulesDir).filter(dir => dir.match(packageDirPattern));
1214
}
1315

1416
function pluginLoader() {
@@ -34,7 +36,7 @@ function pluginLoader() {
3436
},
3537
load(id) {
3638
if (id === resolvedVirtualModuleId) {
37-
const plugins = findInstalledPlugins("@mwdb-web");
39+
const plugins = findInstalledPlugins();
3840
const exports = plugins
3941
.map(
4042
(pluginName, index) =>

0 commit comments

Comments
 (0)