Use file URL for import

This commit is contained in:
Cohee 2023-12-23 19:46:32 +02:00
parent 8e1a84691b
commit fd373fb821
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
const url = require('url');
const express = require('express');
const { getConfigValue } = require('./util');
const enableServerPlugins = getConfigValue('enableServerPlugins', false);
@ -130,7 +131,8 @@ async function loadFromPackage(app, packageJsonPath, exitHooks) {
*/
async function loadFromFile(app, pluginFilePath, exitHooks) {
try {
const plugin = await import(pluginFilePath);
const fileUrl = url.pathToFileURL(pluginFilePath).toString();
const plugin = await import(fileUrl);
console.log(`Initializing plugin from ${pluginFilePath}`);
return await initPlugin(app, plugin, exitHooks);
} catch (error) {