beesbuild
Version:
构建工具链
30 lines (29 loc) • 913 B
JavaScript
import nodeResolve from "@rollup/plugin-node-resolve";
import { flattenDeep, mergeWith } from "lodash-unified";
import { DEFAULT_EXTENSIONS } from "../../variables.mjs";
import { aliasPlugin } from "./alias.mjs";
const nodeResolvePlugin = (option, ctx) => {
const rollup = ctx == null ? void 0 : ctx.options.rollup;
const plugins = [aliasPlugin(rollup == null ? void 0 : rollup.alias, ctx)];
if ((option != null ? option : false) === false) return [];
if (typeof option === "boolean") {
option = {};
}
plugins.push(
nodeResolve(
mergeWith(
{
rootDir: ctx == null ? void 0 : ctx.options.rootDir,
extensions: DEFAULT_EXTENSIONS,
// 将自定义选项传递给解析插件
moduleDirectories: ["node_modules"]
},
option != null ? option : {}
)
)
);
return flattenDeep(plugins);
};
export {
nodeResolvePlugin
};