Skip to content

Commit f06401f

Browse files
committed
Also use import when loading plugins
1 parent 23f29f3 commit f06401f

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/lib/utils/plugins.ts

+7-17
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,13 @@ export async function loadPlugins(
1313
const pluginDisplay = getPluginDisplayName(plugin);
1414

1515
try {
16-
let instance: any;
17-
try {
18-
// eslint-disable-next-line @typescript-eslint/no-require-imports
19-
instance = require(plugin);
20-
} catch (error: any) {
21-
if (error.code === "ERR_REQUIRE_ESM") {
22-
// On Windows, we need to ensure this path is a file path.
23-
// Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME
24-
const esmPath = isAbsolute(plugin)
25-
? pathToFileURL(plugin).toString()
26-
: plugin;
27-
instance = await import(esmPath);
28-
} else {
29-
throw error;
30-
}
31-
}
32-
const initFunction = instance.load;
16+
// On Windows, we need to ensure this path is a file path.
17+
// Or we'll get ERR_UNSUPPORTED_ESM_URL_SCHEME
18+
const esmPath = isAbsolute(plugin)
19+
? pathToFileURL(plugin).toString()
20+
: plugin;
21+
let instance: any = await import(esmPath);
22+
const initFunction = instance.load || instance.default?.load;
3323

3424
if (typeof initFunction === "function") {
3525
await initFunction(app);

0 commit comments

Comments
 (0)