1
0
mirror of https://github.com/SillyTavern/SillyTavern.git synced 2025-04-03 13:41:07 +02:00

Use file URL for import

This commit is contained in:
Cohee 2023-12-23 19:46:32 +02:00
parent 8e1a84691b
commit fd373fb821

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