Merge pull request #2407 from LLukas22/esm_url_scheme

Fix `config.ts` not loading in Jetbrains Editors
This commit is contained in:
Nate Sesti 2024-09-28 19:46:10 -07:00 • committed by GitHub
commit c8efb94f7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -595,7 +595,20 @@ async function loadFullConfigNode(
try {
// Try config.ts first
const configJsPath = getConfigJsPath();
const module = await import(configJsPath);
let module: any;
try {
module = await import(configJsPath);
} catch (e) {
console.log(e)
console.log("Could not load config.ts as absolute path, retrying as file url ...");
try {
module = await import(`file://${configJsPath}`);
} catch (e) {
throw new Error("Could not load config.ts as file url either", { cause: e });
}
}
if (typeof require !== "undefined") {
delete require.cache[require.resolve(configJsPath)];
}