🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

unplugin

Package Overview
Dependencies
Maintainers
0
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin - npm Package Compare versions

Comparing version

to
2.2.1

dist/context-BAPWNxD6.cjs

362

dist/index.d.ts

@@ -1,175 +0,273 @@

import { CompilationContext, JsPlugin } from '@farmfe/core';
import { Compiler as Compiler$1, Compilation as Compilation$1, LoaderContext as LoaderContext$1, RspackPluginInstance } from '@rspack/core';
import type { CompilationContext, JsPlugin } from '@farmfe/core';
import type { Compilation, Compiler, LoaderContext, RspackPluginInstance } from '@rspack/core';
export { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core';
import { PluginBuild, Loader, BuildOptions, Plugin as Plugin$4 } from 'esbuild';
import type { BuildOptions, Plugin, Loader, PluginBuild } from 'esbuild';
export { Plugin as EsbuildPlugin } from 'esbuild';
import { Plugin as Plugin$3 } from 'rolldown';
import type { Plugin as Plugin$1 } from 'rolldown';
export { Plugin as RolldownPlugin } from 'rolldown';
import { PluginContextMeta, EmittedAsset, AstNode, SourceMapInput, Plugin } from 'rollup';
import type { AstNode, EmittedAsset, PluginContextMeta, Plugin as Plugin$2, SourceMapInput } from 'rollup';
export { Plugin as RollupPlugin } from 'rollup';
import { Plugin as Plugin$2 } from 'unloader';
import type { Plugin as Plugin$3 } from 'unloader';
export { Plugin as UnloaderPlugin } from 'unloader';
import { Plugin as Plugin$1 } from 'vite';
import type { Plugin as Plugin$4 } from 'vite';
export { Plugin as VitePlugin } from 'vite';
import { Compiler, Compilation, LoaderContext, WebpackPluginInstance } from 'webpack';
import type { Compilation as Compilation$1, Compiler as Compiler$1, LoaderContext as LoaderContext$1, WebpackPluginInstance } from 'webpack';
export { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack';
import VirtualModulesPlugin from 'webpack-virtual-modules';
import type VirtualModulesPlugin from 'webpack-virtual-modules';
type Thenable<T> = T | Promise<T>;
/**
* Null or whatever
*/
* Null or whatever
*/
type Nullable<T> = T | null | undefined;
/**
* Array, or not yet
*/
* Array, or not yet
*/
type Arrayable<T> = T | Array<T>;
interface SourceMapCompact {
file?: string;
mappings: string;
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: (string | null)[];
version: number;
file?: string;
mappings: string;
names: string[];
sourceRoot?: string;
sources: string[];
sourcesContent?: (string | null)[];
version: number;
}
type TransformResult = string | {
code: string;
map?: SourceMapInput | SourceMapCompact | null;
code: string
map?: SourceMapInput | SourceMapCompact | null
} | null | undefined | void;
interface ExternalIdResult {
id: string;
external?: boolean;
id: string;
external?: boolean;
}
type NativeBuildContext = {
framework: 'webpack';
compiler: Compiler;
compilation?: Compilation;
loaderContext?: LoaderContext<{
unpluginName: string;
}>;
framework: "webpack"
compiler: Compiler$1
compilation?: Compilation$1
loaderContext?: LoaderContext$1<{
unpluginName: string
}>
} | {
framework: 'esbuild';
build: PluginBuild;
framework: "esbuild"
build: PluginBuild
} | {
framework: 'rspack';
compiler: Compiler$1;
compilation: Compilation$1;
loaderContext?: LoaderContext$1;
framework: "rspack"
compiler: Compiler
compilation: Compilation
loaderContext?: LoaderContext
} | {
framework: 'farm';
context: CompilationContext;
framework: "farm"
context: CompilationContext
};
interface UnpluginBuildContext {
addWatchFile: (id: string) => void;
emitFile: (emittedFile: EmittedAsset) => void;
getWatchFiles: () => string[];
parse: (input: string, options?: any) => AstNode;
getNativeBuildContext?: () => NativeBuildContext;
addWatchFile: (id: string) => void;
emitFile: (emittedFile: EmittedAsset) => void;
getWatchFiles: () => string[];
parse: (input: string, options?: any) => AstNode;
getNativeBuildContext?: () => NativeBuildContext;
}
interface UnpluginOptions {
name: string;
enforce?: 'post' | 'pre' | undefined;
buildStart?: (this: UnpluginBuildContext) => Promise<void> | void;
buildEnd?: (this: UnpluginBuildContext) => Promise<void> | void;
transform?: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
load?: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
resolveId?: (this: UnpluginBuildContext & UnpluginContext, id: string, importer: string | undefined, options: {
isEntry: boolean;
}) => Thenable<string | ExternalIdResult | null | undefined>;
watchChange?: (this: UnpluginBuildContext, id: string, change: {
event: 'create' | 'update' | 'delete';
}) => void;
writeBundle?: (this: void) => Promise<void> | void;
/**
* Custom predicate function to filter modules to be loaded.
* When omitted, all modules will be included (might have potential perf impact on Webpack).
*/
loadInclude?: (id: string) => boolean | null | undefined;
/**
* Custom predicate function to filter modules to be transformed.
* When omitted, all modules will be included (might have potential perf impact on Webpack).
*/
transformInclude?: (id: string) => boolean | null | undefined;
rollup?: Partial<Plugin>;
webpack?: (compiler: Compiler) => void;
rspack?: (compiler: Compiler$1) => void;
vite?: Partial<Plugin$1>;
unloader?: Partial<Plugin$2>;
rolldown?: Partial<Plugin$3>;
esbuild?: {
onResolveFilter?: RegExp;
onLoadFilter?: RegExp;
loader?: Loader | ((code: string, id: string) => Loader);
setup?: (build: PluginBuild) => void | Promise<void>;
config?: (options: BuildOptions) => void;
};
farm?: Partial<JsPlugin>;
name: string;
enforce?: "post" | "pre" | undefined;
buildStart?: (this: UnpluginBuildContext) => Promise<void> | void;
buildEnd?: (this: UnpluginBuildContext) => Promise<void> | void;
transform?: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
load?: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
resolveId?: (this: UnpluginBuildContext & UnpluginContext, id: string, importer: string | undefined, options: {
isEntry: boolean
}) => Thenable<string | ExternalIdResult | null | undefined>;
watchChange?: (this: UnpluginBuildContext, id: string, change: {
event: "create" | "update" | "delete"
}) => void;
writeBundle?: (this: void) => Promise<void> | void;
/**
* Custom predicate function to filter modules to be loaded.
* When omitted, all modules will be included (might have potential perf impact on Webpack).
*/
loadInclude?: (id: string) => boolean | null | undefined;
/**
* Custom predicate function to filter modules to be transformed.
* When omitted, all modules will be included (might have potential perf impact on Webpack).
*/
transformInclude?: (id: string) => boolean | null | undefined;
rollup?: Partial<Plugin$2>;
webpack?: (compiler: Compiler$1) => void;
rspack?: (compiler: Compiler) => void;
vite?: Partial<Plugin$4>;
unloader?: Partial<Plugin$3>;
rolldown?: Partial<Plugin$1>;
esbuild?: {
onResolveFilter?: RegExp
onLoadFilter?: RegExp
loader?: Loader | ((code: string, id: string) => Loader)
setup?: (build: PluginBuild) => void | Promise<void>
config?: (options: BuildOptions) => void
};
farm?: Partial<JsPlugin>;
}
interface ResolvedUnpluginOptions extends UnpluginOptions {
__vfs?: VirtualModulesPlugin;
__vfsModules?: Set<string>;
__virtualModulePrefix: string;
__vfs?: VirtualModulesPlugin;
__vfsModules?: Set<string>;
__virtualModulePrefix: string;
}
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions) => Return : (options: UserOptions) => Return;
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin> : Plugin>;
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$1> : Plugin$1>;
rolldown: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$3> : Plugin$3>;
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
esbuild: UnpluginFactoryOutput<UserOptions, Plugin$4>;
unloader: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$2> : Plugin$2>;
farm: UnpluginFactoryOutput<UserOptions, JsPlugin>;
raw: UnpluginFactory<UserOptions, Nested>;
type UnpluginFactory<
UserOptions,
Nested extends boolean = boolean
> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
type UnpluginFactoryOutput<
UserOptions,
Return
> = undefined extends UserOptions ? (options?: UserOptions) => Return : (options: UserOptions) => Return;
interface UnpluginInstance<
UserOptions,
Nested extends boolean = boolean
> {
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$2> : Plugin$2>;
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$4> : Plugin$4>;
rolldown: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$1> : Plugin$1>;
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
esbuild: UnpluginFactoryOutput<UserOptions, Plugin>;
unloader: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<Plugin$3> : Plugin$3>;
farm: UnpluginFactoryOutput<UserOptions, JsPlugin>;
raw: UnpluginFactory<UserOptions, Nested>;
}
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
framework: 'rollup' | 'vite' | 'rolldown' | 'farm' | 'unloader';
framework: "rollup" | "vite" | "rolldown" | "farm" | "unloader"
} | {
framework: 'webpack';
webpack: {
compiler: Compiler;
};
framework: "webpack"
webpack: {
compiler: Compiler$1
}
} | {
framework: 'esbuild';
/** Set the host plugin name of esbuild when returning multiple plugins */
esbuildHostName?: string;
framework: "esbuild"
/** Set the host plugin name of esbuild when returning multiple plugins */
esbuildHostName?: string
} | {
framework: 'rspack';
rspack: {
compiler: Compiler$1;
};
framework: "rspack"
rspack: {
compiler: Compiler
}
});
interface UnpluginMessage {
name?: string;
id?: string;
message: string;
stack?: string;
code?: string;
plugin?: string;
pluginCode?: unknown;
loc?: {
column: number;
file?: string;
line: number;
};
meta?: any;
name?: string;
id?: string;
message: string;
stack?: string;
code?: string;
plugin?: string;
pluginCode?: unknown;
loc?: {
column: number
file?: string
line: number
};
meta?: any;
}
interface UnpluginContext {
error: (message: string | UnpluginMessage) => void;
warn: (message: string | UnpluginMessage) => void;
error: (message: string | UnpluginMessage) => void;
warn: (message: string | UnpluginMessage) => void;
}
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
declare function createEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['esbuild'];
declare function createRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['rollup'];
declare function createVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['vite'];
declare function createUnplugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
declare function createEsbuildPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["esbuild"];
declare function createRollupPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rollup"];
declare function createVitePlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["vite"];
/** @experimental do not use it in production */
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['rolldown'];
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['webpack'];
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['rspack'];
declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['farm'];
declare function createUnloaderPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>['unloader'];
declare function createRolldownPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rolldown"];
declare function createWebpackPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["webpack"];
declare function createRspackPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rspack"];
declare function createFarmPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["farm"];
declare function createUnloaderPlugin<
UserOptions,
Nested extends boolean = boolean
>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["unloader"];
export { type Arrayable, type ExternalIdResult, type NativeBuildContext, type Nullable, type ResolvedUnpluginOptions, type SourceMapCompact, type Thenable, type TransformResult, type UnpluginBuildContext, type UnpluginContext, type UnpluginContextMeta, type UnpluginFactory, type UnpluginFactoryOutput, type UnpluginInstance, type UnpluginMessage, type UnpluginOptions, createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin };
export { createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin };
export type { Arrayable, ExternalIdResult, NativeBuildContext, Nullable, ResolvedUnpluginOptions, SourceMapCompact, Thenable, TransformResult, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginMessage, UnpluginOptions };

@@ -6,3 +6,3 @@ import { parse } from "./context-CyqyI0ug.js";

import { contextOptionsFromCompilation, createBuildContext$1, normalizeMessage$1 } from "./context-Cvtxr8zI.js";
import fs, { existsSync } from "node:fs";
import fs from "node:fs";
import path, { extname, resolve } from "node:path";

@@ -65,3 +65,3 @@ import { Buffer as Buffer$1 } from "node:buffer";

const bufLength = 1024 * 16;
const td = typeof TextDecoder !== "undefined" ? /* #__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
const td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);

@@ -473,3 +473,3 @@ return out.toString();

this.sourcesContent = sourcesContent;
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
const from = resolve$1(sourceRoot || "", stripFilename(mapUrl));

@@ -480,10 +480,10 @@ this.resolvedSources = sources.map((s) => resolve$1(s || "", from));

this._encoded = mappings;
this._decoded = undefined;
this._decoded = void 0;
} else {
this._encoded = undefined;
this._encoded = void 0;
this._decoded = maybeSort(mappings, isString$1);
}
this._decodedMemo = memoizedState();
this._bySources = undefined;
this._bySourceMemos = undefined;
this._bySources = void 0;
this._bySourceMemos = void 0;
}

@@ -551,3 +551,3 @@ };

const index = get(setarr, key);
if (index !== undefined) return index;
if (index !== void 0) return index;
const { array, _indexes: indexes } = cast$1(setarr);

@@ -562,3 +562,3 @@ const length = array.push(key);

const index = get(setarr, key);
if (index === undefined) return;
if (index === void 0) return;
const { array, _indexes: indexes } = cast$1(setarr);

@@ -570,3 +570,3 @@ for (let i = index + 1; i < array.length; i++) {

}
indexes[key] = undefined;
indexes[key] = void 0;
array.pop();

@@ -633,5 +633,5 @@ }

version: 3,
file: map.file || undefined,
file: map.file || void 0,
names: names.array,
sourceRoot: map.sourceRoot || undefined,
sourceRoot: map.sourceRoot || void 0,
sources: sources.array,

@@ -712,3 +712,3 @@ sourcesContent,

//#region node_modules/.pnpm/@ampproject+remapping@2.3.0/node_modules/@ampproject/remapping/dist/remapping.mjs
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject("", -1, -1, "", null, false);
const SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
const EMPTY_SOURCES = [];

@@ -805,3 +805,3 @@ function SegmentObject(source, line, column, name, content, ignore) {

const map = maps.pop();
for (let i = 0; i < maps.length; i++) if (maps[i].sources.length > 1) throw new Error(`Transformation map ${i} must have exactly one source file.\n` + "Did you specify these with the most recent transformation maps first?");
for (let i = 0; i < maps.length; i++) if (maps[i].sources.length > 1) throw new Error(`Transformation map ${i} must have exactly one source file.\nDid you specify these with the most recent transformation maps first?`);
let tree = build(map, loader, "", 0);

@@ -819,4 +819,4 @@ for (let i = maps.length - 1; i >= 0; i--) tree = MapSource(maps[i], [tree]);

source: sourceFile || "",
content: undefined,
ignore: undefined
content: void 0,
ignore: void 0
};

@@ -826,4 +826,4 @@ const sourceMap = loader(ctx.source, ctx);

if (sourceMap) return build(new TraceMap(sourceMap, source), loader, source, depth);
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false;
const sourceContent = content !== void 0 ? content : sourcesContent ? sourcesContent[i] : null;
const ignored = ignore !== void 0 ? ignore : ignoreList ? ignoreList.includes(i) : false;
return OriginalSource(source, sourceContent, ignored);

@@ -875,3 +875,3 @@ });

//#region src/esbuild/utils.ts
const ExtToLoader$1 = {
const ExtToLoader = {
".js": "js",

@@ -894,3 +894,3 @@ ".mjs": "js",

function guessLoader(code, id) {
return ExtToLoader$1[path.extname(id).toLowerCase()] || "js";
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
}

@@ -927,3 +927,3 @@ function unwrapLoader(loader, code, id) {

let mapIndex = 1;
const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === undefined;
const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === void 0;
if (useArrayInterface) map = remapping(sourcemapList, () => null, true);

@@ -1088,3 +1088,3 @@ else map = remapping(sourcemapList[0], (sourcefile) => {

if (plugin.resolveId) onResolve({ filter: onResolveFilter }, async (args) => {
if (initialOptions.external?.includes(args.path)) return undefined;
if (initialOptions.external?.includes(args.path)) return void 0;
const { errors, warnings, mixedContext } = createPluginContext(context);

@@ -1099,3 +1099,3 @@ const isEntry = args.kind === "entry-point";

// whereas the equivalent on other bundlers is`undefined.`
isEntry ? undefined : args.importer,
isEntry ? void 0 : args.importer,
{ isEntry }

@@ -1132,3 +1132,3 @@ );

}
if (code === undefined) return null;
if (code === void 0) return null;
if (map) code = processCodeWithSourceMap(map, code);

@@ -1182,3 +1182,3 @@ return {

addWatchFile(id) {
context.addWatchFile(currentResolveId || id, id);
context.addWatchFile(id, currentResolveId || id);
},

@@ -1214,28 +1214,9 @@ emitFile(emittedFile) {

//#region src/farm/utils.ts
const ExtToLoader = {
".js": "js",
".mjs": "js",
".cjs": "js",
".jsx": "jsx",
".ts": "ts",
".cts": "ts",
".mts": "ts",
".tsx": "tsx",
".json": "json",
".toml": "toml",
".text": "text",
".wasm": "wasm",
".napi": "napi",
".node": "napi"
};
function guessIdLoader(id) {
return ExtToLoader[path.extname(id).toLowerCase()] || "js";
}
function convertEnforceToPriority(value) {
const defaultPriority = 100;
const enforceToPriority = {
pre: 101,
post: 99
pre: 102,
post: 98
};
return enforceToPriority[value] !== undefined ? enforceToPriority[value] : defaultPriority;
return enforceToPriority[value] !== void 0 ? enforceToPriority[value] : defaultPriority;
}

@@ -1297,3 +1278,3 @@ function convertWatchEventChange(value) {

function getContentValue(content) {
if (content === null || content === undefined) throw new Error("Content cannot be null or undefined");
if (content === null || content === void 0) throw new Error("Content cannot be null or undefined");
const strContent = typeof content === "string" ? content : content.code || "";

@@ -1335,2 +1316,32 @@ return encodeStr(strContent);

}
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);
}

@@ -1372,7 +1383,7 @@ //#endregion

filters: {
sources: [".*", ...filters],
sources: filters.length ? filters : [".*"],
importers: [".*"]
},
async executor(params, context) {
const resolvedIdPath = path.resolve(process.cwd(), params.importer ?? "");
const resolvedIdPath = path.resolve(params.importer ?? "");
let isEntry = false;

@@ -1400,10 +1411,2 @@ if (isObject(params.kind) && "entry" in params.kind) {

if (!isStartsWithSlash(params.source)) return null;
const rootAbsolutePath = path.resolve(params.source);
if (existsSync(rootAbsolutePath)) return {
resolvedPath: removeQuery(encodeStr(rootAbsolutePath)),
query: customParseQueryString(rootAbsolutePath),
sideEffects: false,
external: false,
meta: {}
};
}

@@ -1419,3 +1422,3 @@ };

const id = appendQuery(resolvedPath, params.query);
const loader = guessIdLoader(resolvedPath);
const loader = formatTransformModuleType(id);
const shouldLoadInclude = plugin.loadInclude?.(id);

@@ -1443,3 +1446,3 @@ if (!shouldLoadInclude) return null;

const id = appendQuery(resolvedPath, params.query);
const loader = params.moduleType ?? guessIdLoader(params.resolvedPath);
const loader = formatTransformModuleType(id);
const shouldTransformInclude = plugin.transformInclude?.(id);

@@ -1453,3 +1456,3 @@ const farmContext = createFarmContext(context, id);

moduleType: loader,
sourceMap: JSON.stringify(resource.map)
sourceMap: typeof resource.map === "object" && resource.map !== null ? JSON.stringify(resource.map) : void 0
};

@@ -1491,12 +1494,12 @@ return transformFarmResult;

const rawPlugins = toArray(factory(userOptions, meta));
const plugins = rawPlugins.map((plugin) => toRollupPlugin(plugin));
const plugins = rawPlugins.map((plugin) => toRollupPlugin(plugin, "rollup"));
return plugins.length === 1 ? plugins[0] : plugins;
};
}
function toRollupPlugin(plugin, containRollupOptions = true) {
function toRollupPlugin(plugin, key) {
if (plugin.transform && plugin.transformInclude) {
const _transform = plugin.transform;
plugin.transform = function(code, id) {
plugin.transform = function(code, id, ...args) {
if (plugin.transformInclude && !plugin.transformInclude(id)) return null;
return _transform.call(this, code, id);
return _transform.call(this, code, id, ...args);
};

@@ -1506,8 +1509,8 @@ }

const _load = plugin.load;
plugin.load = function(id) {
plugin.load = function(id, ...args) {
if (plugin.loadInclude && !plugin.loadInclude(id)) return null;
return _load.call(this, id);
return _load.call(this, id, ...args);
};
}
if (plugin.rollup && containRollupOptions) Object.assign(plugin, plugin.rollup);
if (plugin[key]) Object.assign(plugin, plugin[key]);
return plugin;

@@ -1523,4 +1526,3 @@ }

const plugins = rawPlugins.map((rawPlugin) => {
const plugin = toRollupPlugin(rawPlugin, false);
if (rawPlugin.rolldown) Object.assign(plugin, rawPlugin.rolldown);
const plugin = toRollupPlugin(rawPlugin, "rolldown");
return plugin;

@@ -1533,3 +1535,3 @@ });

//#endregion
//#region node_modules/.pnpm/tsdown@0.5.9_@babel+runtime@7.26.7_typescript@5.7.3/node_modules/tsdown/esm-shims.js
//#region node_modules/.pnpm/tsdown@0.6.9_publint@0.3.5_typescript@5.8.2_unplugin-unused@0.4.1/node_modules/tsdown/esm-shims.js
const getFilename = () => fileURLToPath(import.meta.url);

@@ -1567,3 +1569,3 @@ const getDirname = () => path.dirname(getFilename());

const requestContext = resolveData.contextInfo;
let importer = requestContext.issuer !== "" ? requestContext.issuer : undefined;
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
const isEntry = requestContext.issuer === "";

@@ -1650,4 +1652,3 @@ if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));

const plugins = rawPlugins.map((rawPlugin) => {
const plugin = toRollupPlugin(rawPlugin, false);
if (rawPlugin.unloader) Object.assign(plugin, rawPlugin.unloader);
const plugin = toRollupPlugin(rawPlugin, "unloader");
return plugin;

@@ -1666,4 +1667,3 @@ });

const plugins = rawPlugins.map((rawPlugin) => {
const plugin = toRollupPlugin(rawPlugin, false);
if (rawPlugin.vite) Object.assign(plugin, rawPlugin.vite);
const plugin = toRollupPlugin(rawPlugin, "vite");
return plugin;

@@ -1709,3 +1709,3 @@ });

const requestContext = request.context;
let importer = requestContext.issuer !== "" ? requestContext.issuer : undefined;
let importer = requestContext.issuer !== "" ? requestContext.issuer : void 0;
const isEntry = requestContext.issuer === "";

@@ -1744,2 +1744,3 @@ if (importer?.startsWith(plugin.__virtualModulePrefix)) importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));

resolved = normalizeAbsolutePath(plugin.__virtualModulePrefix + encodeURIComponent(resolved));
// webpack virtual module should pass in the correct path
if (!plugin.__vfsModules.has(resolved)) {

@@ -1746,0 +1747,0 @@ plugin.__vfs.writeModule(resolved, "");

@@ -1,5 +0,7 @@

import { LoaderContext } from '@rspack/core';
import type { LoaderContext } from '@rspack/core';
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
export { load as default };

@@ -1,5 +0,7 @@

import { LoaderContext } from '@rspack/core';
import type { LoaderContext } from '@rspack/core';
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
export { transform as default };

@@ -1,5 +0,7 @@

import { LoaderContext } from 'webpack';
import type { LoaderContext } from 'webpack';
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
export { load as default };

@@ -1,5 +0,7 @@

import { LoaderContext } from 'webpack';
import type { LoaderContext } from 'webpack';
declare function transform(this: LoaderContext<any>, source: string, map: any): Promise<void>;
export { transform as default };
{
"name": "unplugin",
"type": "module",
"version": "2.2.0",
"packageManager": "pnpm@10.3.0",
"version": "2.2.1",
"packageManager": "pnpm@10.6.4",
"description": "Unified plugin system for build tools",

@@ -45,3 +45,3 @@ "license": "MIT",

"dependencies": {
"acorn": "^8.14.0",
"acorn": "^8.14.1",
"webpack-virtual-modules": "^0.6.2"

@@ -51,34 +51,34 @@ },

"@ampproject/remapping": "^2.3.0",
"@antfu/eslint-config": "^4.2.0",
"@antfu/ni": "^23.3.1",
"@antfu/eslint-config": "^4.10.1",
"@antfu/ni": "^24.2.0",
"@farmfe/cli": "^1.0.4",
"@farmfe/core": "^1.6.6",
"@rspack/cli": "^1.2.2",
"@rspack/core": "^1.2.2",
"@farmfe/core": "^1.7.1",
"@rspack/cli": "^1.2.8",
"@rspack/core": "^1.2.8",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.13.1",
"ansis": "^3.12.0",
"bumpp": "^10.0.3",
"esbuild": "^0.25.0",
"@types/node": "^22.13.10",
"ansis": "^3.17.0",
"bumpp": "^10.1.0",
"esbuild": "^0.25.1",
"esbuild-plugin-copy": "^2.1.1",
"eslint": "^9.20.0",
"eslint": "^9.22.0",
"fast-glob": "^3.3.3",
"fs-extra": "^11.3.0",
"jiti": "^2.4.2",
"lint-staged": "^15.4.3",
"lint-staged": "^15.5.0",
"magic-string": "^0.30.17",
"rolldown": "^1.0.0-beta.3",
"rollup": "^4.34.6",
"rolldown": "^1.0.0-beta.6",
"rollup": "^4.36.0",
"simple-git-hooks": "^2.11.1",
"tsdown": "^0.5.9",
"typescript": "~5.7.3",
"unloader": "^0.2.2",
"tsdown": "^0.6.9",
"typescript": "~5.8.2",
"unloader": "^0.4.1",
"unplugin": "workspace:*",
"vite": "^6.1.0",
"vitest": "^3.0.5",
"webpack": "^5.97.1",
"vite": "^6.2.2",
"vitest": "^3.0.9",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1"
},
"resolutions": {
"esbuild": "^0.25.0"
"esbuild": "^0.25.1"
},

@@ -85,0 +85,0 @@ "simple-git-hooks": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet