Skip to content

Commit b23223e

Browse files
committed
fix(loadLibrary): prefix all module paths with file:/// before dynamically importing them
Fixes joshbolduc#744, but opens the path to previously inaccessible bugs e.g. ``` RangeError: Found rules without implementation: extends. Supported rules are: body-case, body-empty, body-full-stop, body-leading-blank, body-max-length, body-max-line-length, body-min-length, footer-empty, footer-leading-blank, footer-max-length, footer-max-line-length, footer-min-length, header-case, header-full-stop, header-max-length, header-min-length, header-trim, references-empty, scope-case, scope-empty, scope-enum, scope-max-length, scope-min-length, signed-off-by, subject-case, subject-empty, subject-full-stop, subject-max-length, subject-min-length, subject-exclamation-mark, trailer-exists, type-case, type-empty, type-enum, type-max-length, type-min-length. at lint (file:///c:/Repos/HaloSPV3/hce.shared-config/node_modules/@commitlint/lint/lib/lint.js:48:15) at async lint (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:213:22) at async handleAsync (c:\Repos\BinToss\joshbulduc.vscode-commitlint\dist\worker\index.js:238:22) ```
1 parent 0eee374 commit b23223e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/worker/loadLibrary.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { IpcRequestContext } from '../ipcTypes';
33
import { getPrefixForLibraryLoad } from './utils/getPrefixForLibraryLoad';
44
import { getSystemGlobalLibraryPath } from './utils/getSystemGlobalLibraryPath';
55
import { isNodeExceptionCode } from './utils/isNodeExceptionCode';
6+
import { pathToFileURL } from 'url'
67

78
interface BaseLoadResult<T> {
89
result: Promise<UnwrapDefault<T>>;
@@ -35,7 +36,7 @@ const unwrapDefaultExport = <T>(module: T): UnwrapDefault<T> => {
3536
};
3637

3738
const importDefaultExport = async <T>(path: string) => {
38-
const result = (await import(path)) as T;
39+
const result = (await import(pathToFileURL(path).href)) as T;
3940
return unwrapDefaultExport(result);
4041
};
4142

0 commit comments

Comments
 (0)