From cb3eea80ba5d7990dd25a1b7e4182367d85a65b9 Mon Sep 17 00:00:00 2001 From: Lorfdail Date: Mon, 9 Jun 2025 23:18:29 +0200 Subject: [PATCH] fix(#2140): SVGO fails with ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows (#2141) --- lib/svgo-node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/svgo-node.js b/lib/svgo-node.js index 236b3fcc..5849a719 100644 --- a/lib/svgo-node.js +++ b/lib/svgo-node.js @@ -2,13 +2,15 @@ import os from 'os'; import fs from 'fs/promises'; import path from 'path'; import * as svgo from './svgo.js'; +import url from 'url'; /** * @param {string} configFile * @returns {Promise} */ const importConfig = async (configFile) => { - const imported = await import(path.resolve(configFile)); + const resolvedPath = path.resolve(configFile); + const imported = await import(url.pathToFileURL(resolvedPath).toString()); const config = imported.default; if (config == null || typeof config !== 'object' || Array.isArray(config)) {