From 67f38148816f51285c6bdf18c8cce075466e2481 Mon Sep 17 00:00:00 2001 From: Wesley Luyten Date: Wed, 31 Jan 2024 19:29:23 -0600 Subject: [PATCH] fix: pathToFileURL().href related issue https://github.com/nodejs/node/issues/34765 --- src/config.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/config.ts b/src/config.ts index e26f018..3211426 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,6 @@ import { env } from 'node:process'; import path from 'node:path'; -import { fileURLToPath, pathToFileURL } from 'node:url'; +import { pathToFileURL } from 'node:url'; /** * Video configurations @@ -62,14 +62,7 @@ export async function getVideoConfig(): Promise { } async function importConfig(file: string) { - const dirname = path.dirname(fileURLToPath(import.meta.url)); const absFilePath = path.resolve(file); - // Windows uses backslashes, so we need to replace them - // with forward slashes for the dynamic import statement to work. - const filePath = path - .relative(dirname, absFilePath) - .split(path.sep) - .join('/'); - console.log(filePath); - return import(/* webpackIgnore: true */ `${filePath}`); + const fileUrl = pathToFileURL(absFilePath).href; + return import(/* webpackIgnore: true */ fileUrl); }