Support extending ESM based configurations (#3037)
Co-authored-by: Matt Travi <programmer@travi.org>
This commit is contained in:
co-authored by
Matt Travi
parent
250e7ae2c5
commit
6900865324
+12
-4
@@ -1,6 +1,5 @@
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { dirname, extname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
import { castArray, isNil, isPlainObject, isString, pickBy } from "lodash-es";
|
||||
import { readPackageUp } from "read-pkg-up";
|
||||
@@ -14,7 +13,6 @@ import { parseConfig, validatePlugin } from "./plugins/utils.js";
|
||||
|
||||
const debug = debugConfig("semantic-release:config");
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const CONFIG_NAME = "release";
|
||||
|
||||
@@ -35,7 +33,17 @@ export default async (context, cliOptions) => {
|
||||
options = {
|
||||
...(await castArray(extendPaths).reduce(async (eventualResult, extendPath) => {
|
||||
const result = await eventualResult;
|
||||
const extendsOptions = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath));
|
||||
const resolvedPath = resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath);
|
||||
const importAssertions =
|
||||
extname(resolvedPath) === ".json"
|
||||
? {
|
||||
assert: {
|
||||
type: "json",
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const { default: extendsOptions } = await import(resolvedPath, importAssertions);
|
||||
|
||||
// For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
|
||||
// so those plugin will be loaded relative to the config file
|
||||
|
||||
Reference in New Issue
Block a user