diff --git a/@commitlint/resolve-extends/package.json b/@commitlint/resolve-extends/package.json index 740268faf9..69994ed0fd 100644 --- a/@commitlint/resolve-extends/package.json +++ b/@commitlint/resolve-extends/package.json @@ -44,7 +44,8 @@ "@commitlint/types": "^19.0.0", "global-directory": "^4.0.1", "import-meta-resolve": "^4.0.0", - "lodash.mergewith": "^4.6.2" + "lodash.mergewith": "^4.6.2", + "resolve-from": "^5.0.0" }, "gitHead": "d829bf6260304ca8d6811f329fcdd1b6c50e9749" } diff --git a/@commitlint/resolve-extends/src/index.ts b/@commitlint/resolve-extends/src/index.ts index 744f357cff..f699e5840f 100644 --- a/@commitlint/resolve-extends/src/index.ts +++ b/@commitlint/resolve-extends/src/index.ts @@ -5,6 +5,7 @@ import {pathToFileURL, fileURLToPath} from 'url'; import globalDirectory from 'global-directory'; import {moduleResolve} from 'import-meta-resolve'; import mergeWith from 'lodash.mergewith'; +import resolveFrom_ from 'resolve-from'; import {validateConfig} from '@commitlint/config-validator'; import type {ParserPreset, UserConfig} from '@commitlint/types'; @@ -58,7 +59,15 @@ export const resolveFrom = (lookup: string, parent?: string): string => { } } - throw resolveError; + try { + /** + * Yarn P'n'P does not support pure ESM well, this is only a workaround for + * @see https://github.com/conventional-changelog/commitlint/issues/3936 + */ + return resolveFrom_(path.dirname(fileURLToPath(base)), lookup); + } catch { + throw resolveError; + } }; /**