site-panzai/node_modules/unplugin/dist/index.mjs

1432 lines
51 KiB
JavaScript
Raw Permalink Normal View History

2026-11-13 13:57:04 +01:00
import { a as normalizeObjectHook, c as setParseImpl, n as normalizeAbsolutePath, o as toArray, r as transformUse, s as parse, t as createCachedIdFilter } from "./webpack-like-BSTzHRun.mjs";
import { r as normalizeMessage$1, t as createBuildContext$2 } from "./context-CR8OxsIs.mjs";
import { i as isVirtualModuleId, n as decodeVirtualModuleId, r as encodeVirtualModuleId, t as FakeVirtualModulesPlugin } from "./utils-FDqLgfZL.mjs";
import { i as normalizeMessage$2, n as createBuildContext$3, t as contextOptionsFromCompilation } from "./context-VOLsP74b.mjs";
import { createRequire } from "node:module";
import path, { extname, isAbsolute, resolve } from "node:path";
import { Buffer as Buffer$1 } from "node:buffer";
import fs from "node:fs";
import { fileURLToPath } from "node:url";
import remapping from "@jridgewell/remapping";
import * as querystring from "node:querystring";
import process$1 from "node:process";
// \0rolldown/runtime.js
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
// package.json
var version$1 = "3.7.0";
// src/esbuild/utils.ts
const ExtToLoader$1 = {
".js": "js",
".mjs": "js",
".cjs": "js",
".jsx": "jsx",
".ts": "ts",
".cts": "ts",
".mts": "ts",
".tsx": "tsx",
".css": "css",
".less": "css",
".stylus": "css",
".scss": "css",
".sass": "css",
".json": "json",
".txt": "text"
};
function guessLoader$1(code, id) {
return ExtToLoader$1[path.extname(id).toLowerCase()] || "js";
}
function unwrapLoader$1(loader, code, id) {
if (typeof loader === "function") return loader(code, id);
return loader;
}
function fixSourceMap(map) {
if (!Object.hasOwn(map, "toString")) Object.defineProperty(map, "toString", {
enumerable: false,
value: function toString() {
return JSON.stringify(this);
}
});
if (!Object.hasOwn(map, "toUrl")) Object.defineProperty(map, "toUrl", {
enumerable: false,
value: function toUrl() {
return `data:application/json;charset=utf-8;base64,${Buffer$1.from(this.toString()).toString("base64")}`;
}
});
return map;
}
const nullSourceMap = {
names: [],
sources: [],
mappings: "",
version: 3
};
function combineSourcemaps(filename, sourcemapList, preserveSources = false) {
sourcemapList = sourcemapList.filter((m) => m.sources);
if (sourcemapList.length === 0 || sourcemapList.every((m) => m.sources.length === 0)) return { ...nullSourceMap };
let map;
let mapIndex = 1;
if (!sourcemapList.slice(0, -1).some((m) => m.sources.length !== 1)) map = remapping(sourcemapList, () => null, !preserveSources);
else {
const normalizedFilename = filename.replace(/\\/g, "/");
const windows = /^[a-z]:\//i.test(normalizedFilename) || normalizedFilename.startsWith("//");
const paths = windows ? path.win32 : path.posix;
map = remapping(sourcemapList[0], (sourcefile) => {
let source = sourcefile.replace(/\\/g, "/");
if (preserveSources && source !== normalizedFilename && source.startsWith("file:")) try {
source = fileURLToPath(source, { windows }).replace(/\\/g, "/");
} catch {
return null;
}
if ((sourcefile === filename || preserveSources && (source === normalizedFilename || paths.isAbsolute(normalizedFilename) && (paths.isAbsolute(source) || !/^[a-z][a-z\d+.-]*:/i.test(source)) && paths.resolve(paths.dirname(normalizedFilename), source) === paths.normalize(normalizedFilename))) && sourcemapList[mapIndex]) return sourcemapList[mapIndex++];
else return preserveSources ? null : { ...nullSourceMap };
}, !preserveSources);
}
if (!map.file) delete map.file;
return map;
}
function createBuildContext$1(build) {
const { initialOptions } = build;
return {
parse,
addWatchFile() {
throw new Error("unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)");
},
emitFile(emittedFile) {
const outFileName = emittedFile.fileName || emittedFile.name;
if (initialOptions.outdir && emittedFile.source && outFileName) {
const outPath = path.resolve(initialOptions.outdir, outFileName);
const outDir = path.dirname(outPath);
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
fs.writeFileSync(outPath, emittedFile.source);
}
},
getWatchFiles() {
return [];
},
getNativeBuildContext() {
return {
framework: "esbuild",
build
};
}
};
}
function createPluginContext$1(context) {
const errors = [];
const warnings = [];
const pluginContext = {
error(message) {
errors.push(normalizeMessage(message));
},
warn(message) {
warnings.push(normalizeMessage(message));
}
};
const watchFiles = [];
return {
errors,
warnings,
mixedContext: {
...context,
...pluginContext,
addWatchFile(id) {
watchFiles.push(id);
},
getWatchFiles() {
return watchFiles;
}
}
};
}
function normalizeMessage(message) {
if (typeof message === "string") message = { message };
return {
id: message.id,
pluginName: message.plugin,
text: message.message,
location: message.loc ? {
file: message.loc.file,
line: message.loc.line,
column: message.loc.column
} : null,
detail: message.meta,
notes: []
};
}
function processCodeWithSourceMap(map, code) {
if (map) {
if (!map.sourcesContent || map.sourcesContent.length === 0) map.sourcesContent = [code];
map = fixSourceMap(map);
code += `\n//# sourceMappingURL=${map.toUrl()}`;
}
return code;
}
// src/bun/utils.ts
const ExtToLoader = {
".js": "js",
".mjs": "js",
".cjs": "js",
".jsx": "jsx",
".ts": "ts",
".cts": "ts",
".mts": "ts",
".tsx": "tsx",
".css": "css",
".less": "css",
".stylus": "css",
".scss": "css",
".sass": "css",
".json": "json",
".txt": "text"
};
function guessLoader(id) {
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
}
function unwrapLoader(loader, code, id) {
if (typeof loader === "function") return loader(code, id);
return loader;
}
function createBuildContext(build) {
const watchFiles = [];
return {
addWatchFile(file) {
watchFiles.push(file);
},
getWatchFiles() {
return watchFiles;
},
emitFile(emittedFile) {
const outFileName = emittedFile.fileName || emittedFile.name;
const outdir = build?.config?.outdir;
if (outdir && emittedFile.source && outFileName) {
const outPath = path.resolve(outdir, outFileName);
const outDir = path.dirname(outPath);
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
fs.writeFileSync(outPath, emittedFile.source);
}
},
parse,
getNativeBuildContext() {
return {
framework: "bun",
build
};
}
};
}
function createPluginContext(buildContext) {
const errors = [];
const warnings = [];
return {
errors,
warnings,
mixedContext: {
...buildContext,
error(error) {
errors.push(error);
},
warn(warning) {
warnings.push(warning);
}
}
};
}
// src/bun/index.ts
function toBunNamespace(name) {
return name.replace(/[^\w$-]/g, "-");
}
function getBunPlugin(factory) {
return (userOptions) => {
if (typeof Bun === "undefined") throw new ReferenceError("Bun is not supported in this environment");
if (!Bun.semver.satisfies(Bun.version, ">=1.2.22")) throw new Error("Bun 1.2.22 or higher is required, please upgrade Bun");
const meta = {
framework: "bun",
versions: {
bun: Bun.version,
unplugin: version$1
}
};
const plugins = toArray(factory(userOptions, meta));
return {
name: (plugins.length === 1 ? plugins[0].name : meta.bunHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
async setup(build) {
const context = createBuildContext(build);
for (const plugin of plugins) await plugin.bun?.setup?.(build);
if (plugins.some((plugin) => plugin.buildStart)) build.onStart(async () => {
for (const plugin of plugins) if (plugin.buildStart) await plugin.buildStart.call(context);
});
const resolveIdHooks = plugins.filter((plugin) => plugin.resolveId).map((plugin) => ({
plugin,
...normalizeObjectHook("resolveId", plugin.resolveId)
}));
const loadHooks = plugins.filter((plugin) => plugin.load).map((plugin) => ({
plugin,
...normalizeObjectHook("load", plugin.load)
}));
const transformHooks = plugins.filter((plugin) => plugin.transform).map((plugin) => ({
plugin,
...normalizeObjectHook("transform", plugin.transform)
}));
const virtualModulePlugins = /* @__PURE__ */ new Set();
for (const plugin of plugins) if (plugin.resolveId && plugin.load) virtualModulePlugins.add(plugin.name);
if (resolveIdHooks.length) build.onResolve({ filter: /.*/ }, async (args) => {
if (build.config?.external?.includes(args.path)) return;
for (const { plugin, handler, filter } of resolveIdHooks) {
const isEntry = args.kind === "entry-point-run" || args.kind === "entry-point-build";
const importer = isEntry ? void 0 : args.importer;
if (!filter(args.path, importer)) continue;
const { mixedContext, errors, warnings } = createPluginContext(context);
const result = await handler.call(mixedContext, args.path, importer, { isEntry });
for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
if (errors.length > 0) {
const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
}
if (typeof result === "string") {
if (!isAbsolute(result)) return {
path: result,
namespace: toBunNamespace(plugin.name)
};
return { path: result };
} else if (typeof result === "object" && result !== null) {
if (!isAbsolute(result.id)) return {
path: result.id,
external: result.external,
namespace: toBunNamespace(plugin.name)
};
return {
path: result.id,
external: result.external
};
}
}
});
async function processLoadTransform(id, namespace, loader) {
let code;
let hasResult = false;
let activePlugin;
const sourcemapResults = build.config.sourcemap && build.config.sourcemap !== "none" ? [] : void 0;
const namespaceLoadHooks = namespace === "file" ? loadHooks : loadHooks.filter((h) => h.plugin.name === namespace);
for (const { plugin, handler, filter } of namespaceLoadHooks) {
if (plugin.loadInclude && !plugin.loadInclude(id)) continue;
if (!filter(id)) continue;
const { mixedContext, errors, warnings } = createPluginContext(context);
const result = await handler.call(mixedContext, id);
for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
if (errors.length > 0) {
const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
}
if (typeof result === "string") {
code = result;
hasResult = true;
activePlugin = plugin;
break;
} else if (typeof result === "object" && result !== null) {
code = result.code;
sourcemapResults?.push(result);
hasResult = true;
activePlugin = plugin;
break;
}
}
const namespaceTransformHooks = (namespace === "file" ? transformHooks : transformHooks.filter((h) => h.plugin.name === namespace)).filter(({ plugin, idFilter }) => (!plugin.transformInclude || plugin.transformInclude(id)) && idFilter(id));
if (!hasResult && namespace === "file" && namespaceTransformHooks.length > 0) code = await Bun.file(id).text();
if (code !== void 0) for (const { plugin, handler, filter } of namespaceTransformHooks) {
if (!filter(id, code)) continue;
const { mixedContext, errors, warnings } = createPluginContext(context);
const result = await handler.call(mixedContext, code, id);
for (const warning of warnings) console.warn("[unplugin]", typeof warning === "string" ? warning : warning.message);
if (errors.length > 0) {
const errorMessage = errors.map((e) => typeof e === "string" ? e : e.message).join("\n");
throw new Error(`[unplugin] ${plugin.name}: ${errorMessage}`);
}
if (typeof result === "string") {
if (sourcemapResults && result !== code) sourcemapResults.length = 0;
code = result;
hasResult = true;
} else if (typeof result === "object" && result !== null) {
code = result.code;
sourcemapResults?.push(result);
hasResult = true;
}
}
if (hasResult && code !== void 0) {
const pluginLoader = activePlugin?.bun?.loader;
const resolvedLoader = (pluginLoader && unwrapLoader(pluginLoader, code, id)) ?? loader ?? guessLoader(id);
if (sourcemapResults && [
"js",
"jsx",
"ts",
"tsx"
].includes(resolvedLoader)) {
const sourcemaps = [];
for (let i = sourcemapResults.length - 1; i >= 0; i--) {
const result = sourcemapResults[i];
const map = result.map;
if (map) sourcemaps.push(typeof map === "string" ? JSON.parse(map) : map);
else if (i > 0 && result.code !== sourcemapResults[i - 1].code) break;
}
if (sourcemaps.length) code = processCodeWithSourceMap(combineSourcemaps(id, sourcemaps, true), code);
}
return {
contents: code,
loader: resolvedLoader
};
}
}
if (loadHooks.length || transformHooks.length) build.onLoad({
filter: /.*/,
namespace: "file"
}, async (args) => {
return processLoadTransform(args.path, "file", args.loader);
});
for (const pluginName of virtualModulePlugins) build.onLoad({
filter: /.*/,
namespace: toBunNamespace(pluginName)
}, async (args) => {
return processLoadTransform(args.path, pluginName, args.loader);
});
if (plugins.some((plugin) => plugin.buildEnd || plugin.writeBundle)) build.onEnd(async () => {
for (const plugin of plugins) {
if (plugin.buildEnd) await plugin.buildEnd.call(context);
if (plugin.writeBundle) await plugin.writeBundle();
}
});
}
};
};
}
// src/esbuild/index.ts
function getEsbuildPlugin(factory) {
return (userOptions) => {
const meta = {
framework: "esbuild",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta));
const setupPlugins = async (build) => {
const setup = buildSetup();
const loaders = [];
for (const plugin of plugins) {
const loader = {};
await setup(plugin)({
...build,
onLoad(_options, callback) {
loader.options = _options;
loader.onLoadCb = callback;
},
onTransform(_options, callback) {
loader.options ||= _options;
loader.onTransformCb = callback;
}
}, build);
if (loader.onLoadCb || loader.onTransformCb) loaders.push(loader);
}
if (loaders.length) build.onLoad(loaders.length === 1 ? loaders[0].options : { filter: /.*/ }, async (args) => {
function checkFilter(options) {
return loaders.length === 1 || !options?.filter || options.filter.test(args.path);
}
let result;
for (const { options, onLoadCb } of loaders) {
if (!checkFilter(options)) continue;
if (onLoadCb) result = await onLoadCb(args);
if (result?.contents != null) break;
}
let fsContentsCache;
let fsContentsCached = false;
for (const { options, onTransformCb } of loaders) {
if (!checkFilter(options)) continue;
if (onTransformCb) {
const _result = await onTransformCb({
...result,
...args,
async getContents() {
if (result?.contents != null) return result.contents;
if (fsContentsCached) return fsContentsCache;
try {
fsContentsCache = await fs.promises.readFile(args.path, "utf8");
fsContentsCached = true;
return fsContentsCache;
} catch (error) {
if (error?.code === "ENOENT") {
fsContentsCache = "";
fsContentsCached = true;
return fsContentsCache;
}
throw error;
}
}
});
if (_result?.contents != null) result = _result;
}
}
if (result?.contents != null) return result;
});
};
return {
name: (plugins.length === 1 ? plugins[0].name : meta.esbuildHostName) ?? `unplugin-host:${plugins.map((p) => p.name).join(":")}`,
setup: setupPlugins
};
};
}
function buildSetup() {
return (plugin) => {
return (build, rawBuild) => {
const context = createBuildContext$1(rawBuild);
const { onStart, onEnd, onResolve, onLoad, onTransform, initialOptions } = build;
const onResolveFilter = plugin.esbuild?.onResolveFilter ?? /.*/;
const onLoadFilter = plugin.esbuild?.onLoadFilter ?? /.*/;
const loader = plugin.esbuild?.loader ?? guessLoader$1;
plugin.esbuild?.config?.call(context, initialOptions);
if (plugin.buildStart) onStart(() => plugin.buildStart.call(context));
if (plugin.buildEnd || plugin.writeBundle) onEnd(async () => {
if (plugin.buildEnd) await plugin.buildEnd.call(context);
if (plugin.writeBundle) await plugin.writeBundle();
});
if (plugin.resolveId) {
const { handler, filter } = normalizeObjectHook("resolveId", plugin.resolveId);
onResolve({ filter: onResolveFilter }, async (args) => {
const id = args.path;
if (initialOptions.external?.includes(id)) return;
const isEntry = args.kind === "entry-point";
const importer = isEntry ? void 0 : args.importer;
if (!filter(id, importer)) return;
const { errors, warnings, mixedContext } = createPluginContext$1(context);
const result = await handler.call(mixedContext, id, importer, { isEntry });
if (typeof result === "string") return {
path: result,
namespace: plugin.name,
errors,
warnings,
watchFiles: mixedContext.getWatchFiles()
};
else if (typeof result === "object" && result !== null) return {
path: result.id,
external: result.external,
namespace: plugin.name,
errors,
warnings,
watchFiles: mixedContext.getWatchFiles()
};
});
}
if (plugin.load) {
const { handler, filter } = normalizeObjectHook("load", plugin.load);
onLoad({ filter: onLoadFilter }, async (args) => {
const id = args.path + (args.suffix || "");
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
if (!filter(id)) return;
const { errors, warnings, mixedContext } = createPluginContext$1(context);
let code;
let map;
const result = await handler.call(mixedContext, id);
if (typeof result === "string") code = result;
else if (typeof result === "object" && result !== null) {
code = result.code;
map = result.map;
}
if (code === void 0) return null;
if (map) code = processCodeWithSourceMap(map, code);
const resolveDir = path.dirname(args.path);
return {
contents: code,
errors,
warnings,
watchFiles: mixedContext.getWatchFiles(),
loader: unwrapLoader$1(loader, code, args.path),
resolveDir
};
});
}
if (plugin.transform) {
const { handler, filter, idFilter } = normalizeObjectHook("transform", plugin.transform);
onTransform({ filter: onLoadFilter }, async (args) => {
const id = args.path + (args.suffix || "");
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
if (!idFilter(id)) return;
let code = await args.getContents();
if (!filter(id, code)) return;
const { mixedContext, errors, warnings } = createPluginContext$1(context);
const resolveDir = path.dirname(args.path);
let map;
const result = await handler.call(mixedContext, code, id);
if (typeof result === "string") code = result;
else if (typeof result === "object" && result !== null) {
code = result.code;
map = typeof result.map === "string" ? JSON.parse(result.map) : result.map;
}
if (code !== void 0) {
if (map) code = processCodeWithSourceMap(map, code);
return {
contents: code,
errors,
warnings,
watchFiles: mixedContext.getWatchFiles(),
loader: unwrapLoader$1(loader, code, args.path),
resolveDir
};
}
});
}
if (plugin.esbuild?.setup) return plugin.esbuild.setup(rawBuild);
};
};
}
// src/farm/context.ts
function createFarmContext(context, currentResolveId) {
return {
parse,
addWatchFile(id) {
context.addWatchFile(id, currentResolveId || id);
},
emitFile(emittedFile) {
const outFileName = emittedFile.fileName || emittedFile.name;
if (emittedFile.source && outFileName) context.emitFile({
resolvedPath: outFileName,
name: outFileName,
content: [...Buffer$1.from(emittedFile.source)],
resourceType: extname(outFileName)
});
},
getWatchFiles() {
return context.getWatchFiles();
},
getNativeBuildContext() {
return {
framework: "farm",
context
};
}
};
}
function unpluginContext(context) {
return {
error: (error) => context.error(typeof error === "string" ? new Error(error) : error),
warn: (error) => context.warn(typeof error === "string" ? new Error(error) : error)
};
}
// src/farm/utils.ts
function convertEnforceToPriority(value) {
const defaultPriority = 100;
const enforceToPriority = {
pre: 102,
post: 98
};
return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
}
function convertWatchEventChange(value) {
return {
Added: "create",
Updated: "update",
Removed: "delete"
}[value];
}
function isString(variable) {
return typeof variable === "string";
}
function isObject(variable) {
return typeof variable === "object" && variable !== null;
}
function customParseQueryString(url) {
if (!url) return [];
const queryString = url.split("?")[1];
const parsedParams = querystring.parse(queryString);
const paramsArray = [];
for (const key in parsedParams) paramsArray.push([key, parsedParams[key]]);
return paramsArray;
}
function encodeStr(str) {
const len = str.length;
if (len === 0) return str;
const firstNullIndex = str.indexOf("\0");
if (firstNullIndex === -1) return str;
const result = Array.from({ length: len + countNulls(str, firstNullIndex) });
let pos = 0;
for (let i = 0; i < firstNullIndex; i++) result[pos++] = str[i];
for (let i = firstNullIndex; i < len; i++) {
const char = str[i];
if (char === "\0") {
result[pos++] = "\\";
result[pos++] = "0";
} else result[pos++] = char;
}
return path.posix.normalize(result.join(""));
}
function decodeStr(str) {
const len = str.length;
if (len === 0) return str;
const firstIndex = str.indexOf("\\0");
if (firstIndex === -1) return str;
const result = Array.from({ length: len - countBackslashZeros(str, firstIndex) });
let pos = 0;
for (let i = 0; i < firstIndex; i++) result[pos++] = str[i];
let i = firstIndex;
while (i < len) if (str[i] === "\\" && str[i + 1] === "0") {
result[pos++] = "\0";
i += 2;
} else result[pos++] = str[i++];
return path.posix.normalize(result.join(""));
}
function getContentValue(content) {
if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
return encodeStr(typeof content === "string" ? content : content.code || "");
}
function countNulls(str, startIndex) {
let count = 0;
const len = str.length;
for (let i = startIndex; i < len; i++) if (str[i] === "\0") count++;
return count;
}
function countBackslashZeros(str, startIndex) {
let count = 0;
const len = str.length;
for (let i = startIndex; i < len - 1; i++) if (str[i] === "\\" && str[i + 1] === "0") {
count++;
i++;
}
return count;
}
function removeQuery(pathe) {
const queryIndex = pathe.indexOf("?");
if (queryIndex !== -1) return path.posix.normalize(pathe.slice(0, queryIndex));
return path.posix.normalize(pathe);
}
function isStartsWithSlash(str) {
return str?.startsWith("/");
}
function appendQuery(id, query) {
if (!query.length) return id;
return `${id}?${stringifyQuery(query)}`;
}
function stringifyQuery(query) {
if (!query.length) return "";
let queryStr = "";
for (const [key, value] of query) queryStr += `${key}${value ? `=${value}` : ""}&`;
return `${queryStr.slice(0, -1)}`;
}
const CSS_LANGS_RES = [
[/\.(less)(?:$|\?)/, "less"],
[/\.(scss|sass)(?:$|\?)/, "sass"],
[/\.(styl|stylus)(?:$|\?)/, "stylus"],
[/\.(css)(?:$|\?)/, "css"]
];
const JS_LANGS_RES = [
[/\.(js|mjs|cjs)(?:$|\?)/, "js"],
[/\.(jsx)(?:$|\?)/, "jsx"],
[/\.(ts|cts|mts)(?:$|\?)/, "ts"],
[/\.(tsx)(?:$|\?)/, "tsx"]
];
function getCssModuleType(id) {
for (const [reg, lang] of CSS_LANGS_RES) if (reg.test(id)) return lang;
return null;
}
function getJsModuleType(id) {
for (const [reg, lang] of JS_LANGS_RES) if (reg.test(id)) return lang;
return null;
}
function formatLoadModuleType(id) {
const cssModuleType = getCssModuleType(id);
if (cssModuleType) return cssModuleType;
const jsModuleType = getJsModuleType(id);
if (jsModuleType) return jsModuleType;
return "js";
}
function formatTransformModuleType(id) {
return formatLoadModuleType(id);
}
// src/farm/index.ts
function getFarmPlugin(factory) {
return ((userOptions) => {
const plugins = toArray(factory(userOptions, {
framework: "farm",
versions: { unplugin: version$1 }
})).map((rawPlugin) => {
const plugin = toFarmPlugin(rawPlugin, userOptions);
if (rawPlugin.farm) Object.assign(plugin, rawPlugin.farm);
return plugin;
});
return plugins.length === 1 ? plugins[0] : plugins;
});
}
function toFarmPlugin(plugin, options) {
const farmPlugin = {
name: plugin.name,
priority: convertEnforceToPriority(plugin.enforce)
};
if (plugin.farm) Object.keys(plugin.farm).forEach((key) => {
const value = plugin.farm[key];
if (value) Reflect.set(farmPlugin, key, value);
});
if (plugin.buildStart) {
const _buildStart = plugin.buildStart;
farmPlugin.buildStart = { async executor(_, context) {
await _buildStart.call(createFarmContext(context));
} };
}
if (plugin.resolveId) {
const _resolveId = plugin.resolveId;
let filters = [];
if (options) filters = options?.filters ?? [];
farmPlugin.resolve = {
filters: {
sources: filters.length ? filters : [".*"],
importers: [".*"]
},
async executor(params, context) {
const importer = params.importer ? path.resolve(params.importer) : void 0;
const id = decodeStr(params.source);
const { handler, filter } = normalizeObjectHook("resolveId", _resolveId);
if (!filter(id, importer)) return null;
const isEntry = isObject(params.kind) && "entry" in params.kind;
const farmContext = createFarmContext(context, importer);
const resolveIdResult = await handler.call(Object.assign(unpluginContext(context), farmContext), id, importer, { isEntry });
if (isString(resolveIdResult)) return {
resolvedPath: removeQuery(encodeStr(resolveIdResult)),
query: customParseQueryString(resolveIdResult),
sideEffects: true,
external: false,
meta: {}
};
if (isObject(resolveIdResult)) return {
resolvedPath: removeQuery(encodeStr(resolveIdResult?.id)),
query: customParseQueryString(resolveIdResult?.id),
sideEffects: true,
external: Boolean(resolveIdResult?.external),
meta: {}
};
if (!isStartsWithSlash(params.source)) return null;
}
};
}
if (plugin.load) {
const _load = plugin.load;
farmPlugin.load = {
filters: { resolvedPaths: [".*"] },
async executor(params, context) {
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
const loader = formatTransformModuleType(id);
if (plugin.loadInclude && !plugin.loadInclude?.(id)) return null;
const { handler, filter } = normalizeObjectHook("load", _load);
if (!filter(id)) return null;
const farmContext = createFarmContext(context, id);
const content = await handler.call(Object.assign(unpluginContext(context), farmContext), id);
if (content == null) return null;
return {
content: getContentValue(content),
moduleType: loader
};
}
};
}
if (plugin.transform) {
const _transform = plugin.transform;
farmPlugin.transform = {
filters: {
resolvedPaths: [".*"],
moduleTypes: [".*"]
},
async executor(params, context) {
const id = appendQuery(decodeStr(params.resolvedPath), params.query);
const loader = formatTransformModuleType(id);
if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
const { handler, filter } = normalizeObjectHook("transform", _transform);
if (!filter(id, params.content)) return null;
const farmContext = createFarmContext(context, id);
const resource = await handler.call(Object.assign(unpluginContext(context), farmContext), params.content, id);
if (resource == null) return null;
return {
content: getContentValue(resource),
moduleType: loader,
sourceMap: typeof resource === "object" && typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
};
}
};
}
if (plugin.watchChange) {
const _watchChange = plugin.watchChange;
farmPlugin.updateModules = { async executor(param, context) {
const updatePathContent = param.paths[0];
const ModifiedPath = updatePathContent[0];
const eventChange = convertWatchEventChange(updatePathContent[1]);
await _watchChange.call(createFarmContext(context), ModifiedPath, { event: eventChange });
} };
}
if (plugin.buildEnd) {
const _buildEnd = plugin.buildEnd;
farmPlugin.buildEnd = { async executor(_, context) {
await _buildEnd.call(createFarmContext(context));
} };
}
if (plugin.writeBundle) {
const _writeBundle = plugin.writeBundle;
farmPlugin.finish = { async executor() {
await _writeBundle();
} };
}
return farmPlugin;
}
// src/rollup/index.ts
function getRollupPlugin(factory) {
return ((userOptions) => {
const meta = {
framework: "rollup",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta)).map((plugin) => toRollupPlugin(plugin, "rollup", meta));
return plugins.length === 1 ? plugins[0] : plugins;
});
}
function toRollupPlugin(plugin, key, meta) {
const nativeFilter = key === "rolldown";
if (plugin.resolveId && !nativeFilter && typeof plugin.resolveId === "object" && plugin.resolveId.filter) {
const resolveIdHook = plugin.resolveId;
const { handler, filter } = normalizeObjectHook("resolveId", resolveIdHook);
replaceHookHandler("resolveId", resolveIdHook, function(...args) {
const [id, importer] = args;
if (!supportNativeFilter(this, key, resolveIdHook) && !filter(id, importer)) return;
return handler.apply(this, args);
});
}
if (plugin.load && (plugin.loadInclude || !nativeFilter && typeof plugin.load === "object" && plugin.load.filter)) {
const loadHook = plugin.load;
const { handler, filter } = normalizeObjectHook("load", loadHook);
replaceHookHandler("load", loadHook, function(...args) {
const [id] = args;
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
if (!supportNativeFilter(this, key, loadHook) && !filter(id)) return;
return handler.apply(this, args);
});
}
if (plugin.transform && (plugin.transformInclude || !nativeFilter && typeof plugin.transform === "object" && plugin.transform.filter)) {
const transformHook = plugin.transform;
const { handler, filter } = normalizeObjectHook("transform", transformHook);
replaceHookHandler("transform", transformHook, function(...args) {
const [code, id] = args;
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
if (!supportNativeFilter(this, key, transformHook) && !filter(id, code)) return;
return handler.apply(this, args);
});
}
if (plugin[key]) Object.assign(plugin, plugin[key]);
const buildStartHook = plugin.buildStart;
const buildStartHandler = typeof buildStartHook === "object" ? buildStartHook?.handler : buildStartHook;
replaceHookHandler("buildStart", buildStartHook, function(...args) {
const versions = { unplugin: version$1 };
const viteVersion = this?.meta?.viteVersion;
if (viteVersion) versions.vite = viteVersion;
const rollupVersion = this?.meta?.rollupVersion;
if (rollupVersion) versions.rollup = rollupVersion;
const rolldownVersion = this?.meta?.rolldownVersion;
if (rolldownVersion) versions.rolldown = rolldownVersion;
const unloaderVersion = this?.meta?.unloaderVersion;
if (unloaderVersion) versions.unloader = unloaderVersion;
meta.versions = versions;
return buildStartHandler?.apply(this, args);
});
return plugin;
function replaceHookHandler(name, hook, handler) {
if (typeof hook === "object") hook.handler = handler;
else plugin[name] = handler;
}
}
function supportNativeFilter(context, framework, hook) {
if (typeof hook === "object" && Array.isArray(hook.filter)) return framework === "rolldown";
if (framework === "vite") return !!context?.meta?.viteVersion;
if (framework === "rolldown") return true;
const rollupVersion = context?.meta?.rollupVersion;
if (!rollupVersion) return false;
const [major, minor] = rollupVersion.split(".");
return Number(major) > 4 || Number(major) === 4 && Number(minor) >= 40;
}
// src/rolldown/index.ts
function getRolldownPlugin(factory) {
return ((userOptions) => {
const meta = {
framework: "rolldown",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta)).map((rawPlugin) => {
return toRollupPlugin(rawPlugin, "rolldown", meta);
});
return plugins.length === 1 ? plugins[0] : plugins;
});
}
// src/rspack/index.ts
const TRANSFORM_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/transform.mjs");
const LOAD_LOADER$1 = resolve(import.meta.dirname, "rspack/loaders/load.mjs");
function getRspackVersion(compiler) {
return compiler.rspack.rspackVersion ?? compiler.rspack.version;
}
function getRspackPlugin(factory) {
return (userOptions) => {
return { apply(compiler) {
const meta = {
framework: "rspack",
versions: {
rspack: getRspackVersion(compiler),
unplugin: version$1
},
rspack: { compiler }
};
applyRspackPlugins(compiler, toArray(factory(userOptions, meta)), meta);
} };
};
}
function getRspackPluginFromRaw(rawPlugins, meta) {
return { apply(compiler) {
applyRspackPlugins(compiler, rawPlugins, meta);
} };
}
function applyRspackPlugins(compiler, rawPlugins, meta) {
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process.cwd(), "node_modules/.virtual", compiler.rspack.experiments.VirtualModulesPlugin ? "" : process.pid.toString());
meta.versions = {
...meta.versions,
rspack: getRspackVersion(compiler),
unplugin: meta.versions.unplugin ?? version$1
};
if (meta.framework === "rspack") meta.rspack.compiler = compiler;
for (const rawPlugin of rawPlugins) {
const plugin = Object.assign({}, rawPlugin, {
__unpluginMeta: meta,
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
});
const externalModules = /* @__PURE__ */ new Set();
if (plugin.resolveId) {
let cachedResolveId;
const vfs = compiler.rspack.experiments.VirtualModulesPlugin ? new compiler.rspack.experiments.VirtualModulesPlugin() : new FakeVirtualModulesPlugin(plugin);
vfs.apply(compiler);
const vfsModules = /* @__PURE__ */ new Map();
plugin.__vfsModules = vfsModules;
plugin.__vfs = vfs;
compiler.hooks.compilation.tap(plugin.name, (compilation, { normalModuleFactory }) => {
normalModuleFactory.hooks.resolve.tapPromise(plugin.name, async (resolveData) => {
const id = normalizeAbsolutePath(resolveData.request);
const requestContext = resolveData.contextInfo;
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
const isEntry = requestContext.issuer === "";
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
const context = createBuildContext$2(compiler, compilation);
let error;
const pluginContext = {
error(msg) {
if (error == null) error = normalizeMessage$1(msg);
else console.error(`unplugin/rspack: multiple errors returned from resolveId hook: ${msg}`);
},
warn(msg) {
console.warn(`unplugin/rspack: warning from resolveId hook: ${msg}`);
}
};
const hook = plugin.resolveId;
const cwd = process.cwd();
let handler;
if (cachedResolveId?.hook === hook && cachedResolveId.cwd === cwd) handler = typeof hook === "function" ? hook : hook.handler;
else {
const normalized = normalizeObjectHook("resolveId", hook);
handler = normalized.handler;
cachedResolveId = {
hook,
cwd,
filter: normalized.filter
};
}
const { filter } = cachedResolveId;
if (!filter(id, importer)) return;
const resolveIdResult = await handler.call({
...context,
...pluginContext
}, id, importer, { isEntry });
if (error != null) throw error;
if (resolveIdResult == null) return;
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
let isVirtual = true;
try {
(compiler.inputFileSystem?.statSync ?? fs.statSync)(resolved);
isVirtual = false;
} catch {
isVirtual = !isVirtualModuleId(resolved, plugin);
}
if (isVirtual) {
const encodedVirtualPath = encodeVirtualModuleId(resolved, plugin);
if (!vfsModules.has(resolved)) {
const fsPromise = Promise.resolve(vfs.writeModule(encodedVirtualPath, ""));
vfsModules.set(resolved, fsPromise);
await fsPromise;
} else await vfsModules.get(resolved);
resolved = encodedVirtualPath;
}
resolveData.request = resolved;
});
});
}
if (plugin.load) {
const filter = createCachedIdFilter(() => plugin.load);
compiler.options.module.rules.unshift({
enforce: plugin.enforce,
include(id) {
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
if (!filter(id)) return false;
return !externalModules.has(id);
},
use: [{
loader: LOAD_LOADER$1,
options: { plugin }
}],
type: "javascript/auto"
});
}
if (plugin.transform) {
const filter = createCachedIdFilter(() => plugin.transform);
compiler.options.module.rules.unshift({
enforce: plugin.enforce,
use(data) {
return transformUse(data, plugin, TRANSFORM_LOADER$1, filter);
}
});
}
if (meta.framework === "rspack" && plugin.rspack) plugin.rspack(compiler);
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
const context = createBuildContext$2(compiler, compilation);
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
const promises = [];
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
await Promise.all(promises);
}
if (plugin.buildStart) return await plugin.buildStart.call(context);
});
if (plugin.buildEnd) compiler.hooks.thisCompilation.tap(plugin.name, (compilation) => {
compilation.hooks.processAssets.tapPromise({
name: plugin.name,
stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
}, async () => {
await plugin.buildEnd.call(createBuildContext$2(compiler, compilation));
});
});
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
await plugin.writeBundle();
});
}
}
// src/rsbuild/index.ts
function getRsbuildPlugin(factory) {
return (userOptions) => {
const meta = {
framework: "rsbuild",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta)).map((rawPlugin) => toRsbuildPlugin(rawPlugin, meta));
return plugins.length === 1 ? plugins[0] : plugins;
};
}
function toRsbuildPlugin(rawPlugin, meta) {
const rsbuildOptions = rawPlugin.rsbuild;
return {
...rsbuildOptions,
name: rsbuildOptions?.name ?? rawPlugin.name,
enforce: rsbuildOptions?.enforce ?? rawPlugin.enforce,
async setup(api) {
meta.versions = {
...meta.versions,
rsbuild: api.context.version,
unplugin: meta.versions.unplugin ?? version$1
};
api.modifyRspackConfig((config) => {
config.plugins.push(getRspackPluginFromRaw([rawPlugin], meta));
});
await rsbuildOptions?.setup?.(api);
}
};
}
// src/unloader/index.ts
function getUnloaderPlugin(factory) {
return ((userOptions) => {
const meta = {
framework: "unloader",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta)).map((rawPlugin) => {
return toRollupPlugin(rawPlugin, "unloader", meta);
});
return plugins.length === 1 ? plugins[0] : plugins;
});
}
// src/vite/index.ts
function getVitePlugin(factory) {
return ((userOptions) => {
const meta = {
framework: "vite",
versions: { unplugin: version$1 }
};
const plugins = toArray(factory(userOptions, meta)).map((rawPlugin) => {
return toRollupPlugin(rawPlugin, "vite", meta);
});
return plugins.length === 1 ? plugins[0] : plugins;
});
}
// src/webpack/index.ts
const TRANSFORM_LOADER = resolve(import.meta.dirname, "webpack/loaders/transform.mjs");
const LOAD_LOADER = resolve(import.meta.dirname, "webpack/loaders/load.mjs");
/** Innermost webpack input filesystem — the one that holds `_virtualFiles`. */
function virtualInputFileSystem(compiler) {
let input = compiler.inputFileSystem;
while (input?._inputFileSystem) input = input._inputFileSystem;
return input;
}
/**
* Recreate a missing in-memory virtual file before webpack reads it.
* A restored module already points at the `_virtual_` path, and that file
* exists only in memory, so a later process ENOENTs unless this runs even
* when `resolveId` does not.
*/
function ensureVirtualModule(plugin, compiler, file) {
if (!file || !plugin.__vfs) return;
const resource = normalizeAbsolutePath(file.split("?")[0].split("#")[0]);
if (!resource.startsWith(plugin.__virtualModulePrefix)) return;
if (fs.existsSync(resource)) return;
const input = virtualInputFileSystem(compiler);
if (input?._virtualFiles && Object.hasOwn(input._virtualFiles, resource)) return;
plugin.__vfs.writeModule(resource, "");
if (plugin.__vfsModules instanceof Set) plugin.__vfsModules.add(resource);
}
/** Webpack adapter for an unplugin factory. */
function getWebpackPlugin(factory) {
return (userOptions) => {
const VirtualModulesPlugin = __require("webpack-virtual-modules");
return { apply(compiler) {
const VIRTUAL_MODULE_PREFIX = resolve(compiler.options.context ?? process$1.cwd(), "_virtual_");
const meta = {
framework: "webpack",
versions: {
webpack: compiler.webpack?.version,
unplugin: version$1
},
webpack: { compiler }
};
const rawPlugins = toArray(factory(userOptions, meta));
for (const rawPlugin of rawPlugins) {
const plugin = Object.assign(rawPlugin, {
__unpluginMeta: meta,
__virtualModulePrefix: VIRTUAL_MODULE_PREFIX
});
const externalModules = /* @__PURE__ */ new Set();
if (plugin.resolveId) {
let cachedResolveId;
let vfs = compiler.options.plugins.find((i) => i instanceof VirtualModulesPlugin);
if (!vfs) {
vfs = new VirtualModulesPlugin();
compiler.options.plugins.push(vfs);
}
plugin.__vfsModules = /* @__PURE__ */ new Set();
plugin.__vfs = vfs;
compiler.hooks.compilation.tap(plugin.name, (compilation) => {
compilation.hooks.buildModule.tap(plugin.name, (module) => {
ensureVirtualModule(plugin, compiler, module.resource);
});
});
const resolverPlugin = { apply(resolver) {
const target = resolver.ensureHook("resolve");
resolver.getHook("resolve").tapAsync(plugin.name, async (request, resolveContext, callback) => {
if (!request.request) return callback();
if (normalizeAbsolutePath(request.request).startsWith(plugin.__virtualModulePrefix)) return callback();
try {
const id = normalizeAbsolutePath(request.request);
const requestContext = request.context;
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
const isEntry = requestContext.issuer === "";
if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
const fileDependencies = /* @__PURE__ */ new Set();
const context = createBuildContext$3({
addWatchFile(file) {
fileDependencies.add(file);
resolveContext.fileDependencies?.add(file);
},
getWatchFiles() {
return Array.from(fileDependencies);
}
}, compiler);
let error;
const pluginContext = {
error(msg) {
if (error == null) error = normalizeMessage$2(msg);
else console.error(`unplugin/webpack: multiple errors returned from resolveId hook: ${msg}`);
},
warn(msg) {
console.warn(`unplugin/webpack: warning from resolveId hook: ${msg}`);
}
};
const hook = plugin.resolveId;
const cwd = process$1.cwd();
let handler;
if (cachedResolveId?.hook === hook && cachedResolveId.cwd === cwd) handler = typeof hook === "function" ? hook : hook.handler;
else {
const normalized = normalizeObjectHook("resolveId", hook);
handler = normalized.handler;
cachedResolveId = {
hook,
cwd,
filter: normalized.filter
};
}
const { filter } = cachedResolveId;
if (!filter(id, importer)) return callback();
const resolveIdResult = await handler.call({
...context,
...pluginContext
}, id, importer, { isEntry });
if (error != null) return callback(error);
if (resolveIdResult == null) return callback();
let resolved = typeof resolveIdResult === "string" ? resolveIdResult : resolveIdResult.id;
if (typeof resolveIdResult === "string" ? false : resolveIdResult.external === true) externalModules.add(resolved);
if (!fs.existsSync(resolved)) {
resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
ensureVirtualModule(plugin, compiler, resolved);
}
const newRequest = {
...request,
request: resolved
};
resolver.doResolve(target, newRequest, null, resolveContext, callback);
} catch (error) {
callback(error instanceof Error ? error : new Error(String(error)));
}
});
} };
compiler.options.resolve.plugins = compiler.options.resolve.plugins || [];
compiler.options.resolve.plugins.push(resolverPlugin);
}
if (plugin.load) {
const filter = createCachedIdFilter(() => plugin.load);
compiler.options.module.rules.unshift({
include(id) {
return shouldLoad(id, plugin, externalModules, filter);
},
enforce: plugin.enforce,
use: [{
loader: LOAD_LOADER,
options: { plugin }
}],
type: "javascript/auto"
});
}
if (plugin.transform) {
const filter = createCachedIdFilter(() => plugin.transform);
compiler.options.module.rules.unshift({
enforce: plugin.enforce,
use(data) {
return transformUse(data, plugin, TRANSFORM_LOADER, filter);
}
});
}
if (plugin.webpack) plugin.webpack(compiler);
if (plugin.watchChange || plugin.buildStart) compiler.hooks.make.tapPromise(plugin.name, async (compilation) => {
const context = createBuildContext$3(contextOptionsFromCompilation(compilation), compiler, compilation);
if (plugin.watchChange && (compiler.modifiedFiles || compiler.removedFiles)) {
const promises = [];
if (compiler.modifiedFiles) compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
if (compiler.removedFiles) compiler.removedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" }))));
await Promise.all(promises);
}
if (plugin.buildStart) return await plugin.buildStart.call(context);
});
if (plugin.buildEnd) {
const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONAL;
if (processAssetsStage == null) compiler.hooks.emit.tapPromise(plugin.name, async (compilation) => {
await plugin.buildEnd.call(createBuildContext$3(contextOptionsFromCompilation(compilation), compiler, compilation));
});
else compiler.hooks.thisCompilation.tap(plugin.name, (compilation) => {
compilation.hooks.processAssets.tapPromise({
name: plugin.name,
stage: processAssetsStage
}, async () => {
await plugin.buildEnd.call(createBuildContext$3(contextOptionsFromCompilation(compilation), compiler, compilation));
});
});
}
if (plugin.writeBundle) compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
await plugin.writeBundle();
});
}
} };
};
}
function shouldLoad(id, plugin, externalModules, filter) {
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
if (plugin.loadInclude && !plugin.loadInclude(id)) return false;
if (!filter(id)) return false;
return !externalModules.has(id);
}
// src/define.ts
function createUnplugin(factory) {
return {
get esbuild() {
return getEsbuildPlugin(factory);
},
get rollup() {
return getRollupPlugin(factory);
},
get vite() {
return getVitePlugin(factory);
},
get rolldown() {
return getRolldownPlugin(factory);
},
get webpack() {
return getWebpackPlugin(factory);
},
get rspack() {
return getRspackPlugin(factory);
},
get rsbuild() {
return getRsbuildPlugin(factory);
},
get farm() {
return getFarmPlugin(factory);
},
get unloader() {
return getUnloaderPlugin(factory);
},
get bun() {
return getBunPlugin(factory);
},
get raw() {
return factory;
}
};
}
function createEsbuildPlugin(factory) {
return getEsbuildPlugin(factory);
}
function createRollupPlugin(factory) {
return getRollupPlugin(factory);
}
function createVitePlugin(factory) {
return getVitePlugin(factory);
}
function createRolldownPlugin(factory) {
return getRolldownPlugin(factory);
}
function createWebpackPlugin(factory) {
return getWebpackPlugin(factory);
}
function createRspackPlugin(factory) {
return getRspackPlugin(factory);
}
function createRsbuildPlugin(factory) {
return getRsbuildPlugin(factory);
}
function createFarmPlugin(factory) {
return getFarmPlugin(factory);
}
function createUnloaderPlugin(factory) {
return getUnloaderPlugin(factory);
}
function createBunPlugin(factory) {
return getBunPlugin(factory);
}
// src/index.ts
const version = version$1;
export { createBunPlugin, createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRsbuildPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin, setParseImpl, version };