Skip to content

Commit

Permalink
fix: pathToFileURL().href
Browse files Browse the repository at this point in the history
related issue nodejs/node#34765
  • Loading branch information
luwes committed Feb 1, 2024
1 parent 81b5d47 commit 67f3814
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -62,14 +62,7 @@ export async function getVideoConfig(): Promise<VideoConfigComplete> {
}

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);
}

0 comments on commit 67f3814

Please sign in to comment.