Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unplugin

Package Overview
Dependencies
Maintainers
2
Versions
94
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 1.16.0 to 2.0.0-beta.1

dist/index.cjs

41

dist/index.d.ts
import * as _farmfe_core from '@farmfe/core';
import { JsPlugin, CompilationContext } from '@farmfe/core';
import * as _rspack_core_dist_config_types from '@rspack/core/dist/config/types';
import { CompilationContext, JsPlugin } from '@farmfe/core';
import * as _rspack_core from '@rspack/core';
import { Compiler as Compiler$1, Compilation as Compilation$1, LoaderContext as LoaderContext$1, RspackPluginInstance } from '@rspack/core';
export { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core';
import * as webpack from 'webpack';
import { Compiler, Compilation, LoaderContext, WebpackPluginInstance } from 'webpack';
export { Compiler as WebpackCompiler, WebpackPluginInstance } from 'webpack';
import * as rolldown_dist_types_plugin from 'rolldown/dist/types/plugin';
import * as rolldown from 'rolldown';
import { Plugin as Plugin$2 } from 'rolldown';
export { Plugin as RolldownPlugin } from 'rolldown';
import * as vite from 'vite';

@@ -14,9 +18,5 @@ import { Plugin as Plugin$1 } from 'vite';

export { Plugin as RollupPlugin } from 'rollup';
import { Compiler as Compiler$1, Compilation as Compilation$1, LoaderContext as LoaderContext$1, RspackPluginInstance } from '@rspack/core';
export { Compiler as RspackCompiler, RspackPluginInstance } from '@rspack/core';
import * as esbuild from 'esbuild';
import { PluginBuild, OnLoadResult, Loader, BuildOptions, Plugin as Plugin$3 } from 'esbuild';
export { Plugin as EsbuildPlugin } from 'esbuild';
import { Plugin as Plugin$2 } from 'rolldown';
export { Plugin as RolldownPlugin } from 'rolldown';
import VirtualModulesPlugin from 'webpack-virtual-modules';

@@ -42,2 +42,10 @@

type Thenable<T> = T | Promise<T>;
/**
* Null or whatever
*/
type Nullable<T> = T | null | undefined;
/**
* Array, or not yet
*/
type Arrayable<T> = T | Array<T>;
interface SourceMapCompact {

@@ -52,5 +60,2 @@ file?: string;

}
interface JsPluginExtended extends JsPlugin {
[key: string]: any;
}
type TransformResult = string | {

@@ -183,12 +188,2 @@ code: string;

}
declare module 'webpack' {
interface Compiler {
$unpluginContext: Record<string, ResolvedUnpluginOptions>;
}
}
declare module '@rspack/core' {
interface Compiler {
$unpluginContext: Record<string, ResolvedUnpluginOptions>;
}
}

@@ -200,7 +195,7 @@ declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;

/** @experimental do not use it in production */
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? rolldown_dist_types_plugin.Plugin<any>[] : rolldown_dist_types_plugin.Plugin<any>>;
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, Nested extends true ? rolldown.Plugin<any>[] : rolldown.Plugin<any>>;
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, webpack.WebpackPluginInstance>;
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _rspack_core_dist_config_types.RspackPluginInstance>;
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _rspack_core.RspackPluginInstance>;
declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginFactoryOutput<UserOptions, _farmfe_core.JsPlugin>;
export { type ExternalIdResult, type JsPluginExtended, type NativeBuildContext, 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, createUnplugin, createVitePlugin, createWebpackPlugin };
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, createUnplugin, createVitePlugin, createWebpackPlugin };

@@ -1,32 +0,6 @@

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/rspack/loaders/load.ts
var load_exports = {};
__export(load_exports, {
default: () => load
});
module.exports = __toCommonJS(load_exports);
// src/utils.ts
var import_path = require("path");
import { isAbsolute, normalize } from "path";
function normalizeAbsolutePath(path) {
if ((0, import_path.isAbsolute)(path))
return (0, import_path.normalize)(path);
if (isAbsolute(path))
return normalize(path);
else

@@ -37,5 +11,5 @@ return path;

// src/rspack/context.ts
var import_buffer = require("buffer");
var import_path2 = require("path");
var import_acorn = require("acorn");
import { Buffer } from "buffer";
import { resolve } from "path";
import { Parser } from "acorn";
function createBuildContext(compiler, compilation, loaderContext) {

@@ -52,3 +26,3 @@ return {

addWatchFile(file) {
compilation.fileDependencies.add((0, import_path2.resolve)(process.cwd(), file));
compilation.fileDependencies.add(resolve(process.cwd(), file));
},

@@ -59,3 +33,3 @@ getWatchFiles() {

parse(code, opts = {}) {
return import_acorn.Parser.parse(code, {
return Parser.parse(code, {
sourceType: "module",

@@ -74,3 +48,3 @@ ecmaVersion: "latest",

new sources.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
)

@@ -98,8 +72,8 @@ );

// src/rspack/utils.ts
var import_path3 = require("path");
import { basename, dirname, resolve as resolve2 } from "path";
function decodeVirtualModuleId(encoded, _plugin) {
return decodeURIComponent((0, import_path3.basename)(encoded));
return decodeURIComponent(basename(encoded));
}
function isVirtualModuleId(encoded, plugin) {
return (0, import_path3.dirname)(encoded) === plugin.__virtualModulePrefix;
return dirname(encoded) === plugin.__virtualModulePrefix;
}

@@ -109,8 +83,6 @@

async function load(source, map) {
var _a;
const callback = this.async();
const { unpluginName } = this.query;
const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
const { plugin } = this.query;
let id = this.resource;
if (!(plugin == null ? void 0 : plugin.load) || !id)
if (!plugin?.load || !id)
return callback(null, source, map);

@@ -135,1 +107,4 @@ if (isVirtualModuleId(id, plugin))

}
export {
load as default
};

@@ -1,31 +0,5 @@

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/rspack/loaders/transform.ts
var transform_exports = {};
__export(transform_exports, {
default: () => transform
});
module.exports = __toCommonJS(transform_exports);
// src/rspack/context.ts
var import_buffer = require("buffer");
var import_path = require("path");
var import_acorn = require("acorn");
import { Buffer } from "buffer";
import { resolve } from "path";
import { Parser } from "acorn";
function createBuildContext(compiler, compilation, loaderContext) {

@@ -42,3 +16,3 @@ return {

addWatchFile(file) {
compilation.fileDependencies.add((0, import_path.resolve)(process.cwd(), file));
compilation.fileDependencies.add(resolve(process.cwd(), file));
},

@@ -49,3 +23,3 @@ getWatchFiles() {

parse(code, opts = {}) {
return import_acorn.Parser.parse(code, {
return Parser.parse(code, {
sourceType: "module",

@@ -64,3 +38,3 @@ ecmaVersion: "latest",

new sources.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : import_buffer.Buffer.from(emittedFile.source)
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
)

@@ -89,15 +63,7 @@ );

async function transform(source, map) {
var _a;
const callback = this.async();
let unpluginName;
if (typeof this.query === "string") {
const query = new URLSearchParams(this.query);
unpluginName = query.get("unpluginName");
} else {
unpluginName = this.query.unpluginName;
}
const { plugin } = this.query;
if (!plugin?.transform)
return callback(null, source, map);
const id = this.resource;
const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
if (!(plugin == null ? void 0 : plugin.transform))
return callback(null, source, map);
const context = createContext(this);

@@ -119,1 +85,4 @@ const res = await plugin.transform.call(

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

@@ -1,64 +0,21 @@

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/webpack/loaders/load.ts
var load_exports = {};
__export(load_exports, {
default: () => load
});
module.exports = __toCommonJS(load_exports);
// src/utils.ts
var import_path = require("path");
import { isAbsolute, normalize } from "path";
function normalizeAbsolutePath(path) {
if ((0, import_path.isAbsolute)(path))
return (0, import_path.normalize)(path);
if (isAbsolute(path))
return normalize(path);
else
return path;
}
function resolveQuery(query) {
if (typeof query === "string") {
return new URLSearchParams(query).get("unpluginName");
} else {
return query.unpluginName;
}
}
// src/webpack/context.ts
var import_buffer = require("buffer");
var import_module = require("module");
var import_path2 = require("path");
var import_process = __toESM(require("process"));
var import_acorn = require("acorn");
import { Buffer } from "buffer";
import { createRequire } from "module";
import { resolve } from "path";
import process from "process";
import { Parser } from "acorn";
var require2 = createRequire(import.meta.url);
function getSource(fileSource) {
const webpackRequire = (0, import_module.createRequire)(require.resolve("webpack"));
const RawSource = webpackRequire("webpack-sources").RawSource;
return new RawSource(
typeof fileSource === "string" ? fileSource : import_buffer.Buffer.from(fileSource.buffer).toString("utf-8")
const webpack = require2("webpack");
return new webpack.sources.RawSource(
typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer)
);

@@ -69,3 +26,3 @@ }

parse(code, opts = {}) {
return import_acorn.Parser.parse(code, {
return Parser.parse(code, {
sourceType: "module",

@@ -78,3 +35,3 @@ ecmaVersion: "latest",

addWatchFile(id) {
options.addWatchFile((0, import_path2.resolve)(import_process.default.cwd(), id));
options.addWatchFile(resolve(process.cwd(), id));
},

@@ -117,8 +74,6 @@ emitFile(emittedFile) {

async function load(source, map) {
var _a;
const callback = this.async();
const unpluginName = resolveQuery(this.query);
const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
const { plugin } = this.query;
let id = this.resource;
if (!(plugin == null ? void 0 : plugin.load) || !id)
if (!plugin?.load || !id)
return callback(null, source, map);

@@ -146,1 +101,4 @@ if (id.startsWith(plugin.__virtualModulePrefix))

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

@@ -1,57 +0,12 @@

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/webpack/loaders/transform.ts
var transform_exports = {};
__export(transform_exports, {
default: () => transform
});
module.exports = __toCommonJS(transform_exports);
// src/utils.ts
function resolveQuery(query) {
if (typeof query === "string") {
return new URLSearchParams(query).get("unpluginName");
} else {
return query.unpluginName;
}
}
// src/webpack/context.ts
var import_buffer = require("buffer");
var import_module = require("module");
var import_path = require("path");
var import_process = __toESM(require("process"));
var import_acorn = require("acorn");
import { Buffer } from "buffer";
import { createRequire } from "module";
import { resolve } from "path";
import process from "process";
import { Parser } from "acorn";
var require2 = createRequire(import.meta.url);
function getSource(fileSource) {
const webpackRequire = (0, import_module.createRequire)(require.resolve("webpack"));
const RawSource = webpackRequire("webpack-sources").RawSource;
return new RawSource(
typeof fileSource === "string" ? fileSource : import_buffer.Buffer.from(fileSource.buffer).toString("utf-8")
const webpack = require2("webpack");
return new webpack.sources.RawSource(
typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer)
);

@@ -62,3 +17,3 @@ }

parse(code, opts = {}) {
return import_acorn.Parser.parse(code, {
return Parser.parse(code, {
sourceType: "module",

@@ -71,3 +26,3 @@ ecmaVersion: "latest",

addWatchFile(id) {
options.addWatchFile((0, import_path.resolve)(import_process.default.cwd(), id));
options.addWatchFile(resolve(process.cwd(), id));
},

@@ -110,7 +65,5 @@ emitFile(emittedFile) {

async function transform(source, map) {
var _a;
const callback = this.async();
const unpluginName = resolveQuery(this.query);
const plugin = (_a = this._compiler) == null ? void 0 : _a.$unpluginContext[unpluginName];
if (!(plugin == null ? void 0 : plugin.transform))
const { plugin } = this.query;
if (!plugin?.transform)
return callback(null, source, map);

@@ -137,1 +90,4 @@ const context = createContext(this);

}
export {
transform as default
};
{
"name": "unplugin",
"type": "commonjs",
"version": "1.16.0",
"packageManager": "pnpm@8.15.9",
"type": "module",
"version": "2.0.0-beta.1",
"packageManager": "pnpm@9.14.2",
"description": "Unified plugin system for build tools",

@@ -15,14 +15,10 @@ "license": "MIT",

".": {
"types": {
"import": "./dist/index.d.mts",
"require": "./dist/index.d.ts"
},
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.js",
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.js"
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.cjs",
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.cjs"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",

@@ -33,3 +29,3 @@ "files": [

"engines": {
"node": ">=14.0.0"
"node": ">=18.12.0"
},

@@ -46,3 +42,3 @@ "scripts": {

"prepublishOnly": "nr build",
"release": "bumpp --all -x 'npx conventional-changelog -p angular -i CHANGELOG.md -s' && npm publish",
"release": "bumpp --all && npm publish",
"test": "nr test:build && vitest run --pool=forks",

@@ -57,33 +53,31 @@ "test:build": "jiti scripts/buildFixtures.ts"

"@ampproject/remapping": "^2.3.0",
"@antfu/eslint-config": "^3.8.0",
"@antfu/ni": "^0.23.0",
"@antfu/eslint-config": "^3.11.2",
"@antfu/ni": "^0.23.1",
"@farmfe/cli": "1.0.3",
"@farmfe/core": "1.3.12",
"@rspack/cli": "^1.0.14",
"@rspack/core": "^1.0.14",
"@rspack/cli": "^1.1.4",
"@rspack/core": "^1.1.4",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.8.1",
"@types/webpack-sources": "^3.2.3",
"bumpp": "^9.7.1",
"conventional-changelog-cli": "^5.0.0",
"@types/node": "^22.10.1",
"bumpp": "^9.8.1",
"esbuild": "^0.24.0",
"esbuild-plugin-copy": "^2.1.1",
"eslint": "^9.13.0",
"eslint": "^9.15.0",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
"jiti": "^2.3.3",
"jiti": "^2.4.0",
"lint-staged": "^15.2.10",
"magic-string": "^0.30.12",
"magic-string": "^0.30.14",
"picocolors": "^1.1.1",
"rolldown": "^0.13.2",
"rollup": "^4.24.2",
"rolldown": "^0.14.0",
"rollup": "^4.27.4",
"simple-git-hooks": "^2.11.1",
"tsup": "^8.3.5",
"typescript": "^5.6.3",
"typescript": "~5.6.3",
"unplugin": "workspace:*",
"unplugin-unused": "^0.2.3",
"vite": "^5.4.10",
"vitest": "^2.1.4",
"webpack": "^5.95.0",
"webpack-cli": "4.10.0"
"vite": "^6.0.1",
"vitest": "^2.1.6",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},

@@ -90,0 +84,0 @@ "simple-git-hooks": {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc