Socket
Socket
Sign inDemoInstall

unplugin

Package Overview
Dependencies
Maintainers
1
Versions
87
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 0.7.2 to 0.8.0

108

dist/index.js

@@ -20,3 +20,6 @@ "use strict";

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -996,9 +999,13 @@

} else {
map = remapping(sourcemapList[0], function loader(sourcefile) {
if (sourcefile === filename && sourcemapList[mapIndex]) {
return sourcemapList[mapIndex++];
} else {
return { ...nullSourceMap };
}
}, true);
map = remapping(
sourcemapList[0],
function loader(sourcefile) {
if (sourcefile === filename && sourcemapList[mapIndex]) {
return sourcemapList[mapIndex++];
} else {
return { ...nullSourceMap };
}
},
true
);
}

@@ -1090,3 +1097,7 @@ if (!map.file) {

const isEntry = args.kind === "entry-point";
const result = await plugin.resolveId(args.path, isEntry ? void 0 : args.importer, { isEntry });
const result = await plugin.resolveId(
args.path,
isEntry ? void 0 : args.importer,
{ isEntry }
);
if (typeof result === "string") {

@@ -1101,2 +1112,3 @@ return { path: result, namespace: plugin.name };

onLoad({ filter: onLoadFilter }, async (args) => {
const id = args.path + args.suffix;
const errors = [];

@@ -1115,3 +1127,3 @@ const warnings = [];

if (plugin.load) {
const result = await plugin.load.call(Object.assign(context, pluginContext), args.path);
const result = await plugin.load.call(Object.assign(context, pluginContext), id);
if (typeof result === "string") {

@@ -1138,7 +1150,7 @@ code = result;

}
if (!plugin.transformInclude || plugin.transformInclude(args.path)) {
if (!plugin.transformInclude || plugin.transformInclude(id)) {
if (!code) {
code = await import_fs.default.promises.readFile(args.path, "utf8");
}
const result = await plugin.transform.call(Object.assign(context, pluginContext), code, args.path);
const result = await plugin.transform.call(Object.assign(context, pluginContext), code, id);
if (typeof result === "string") {

@@ -1247,3 +1259,5 @@ code = result;

addWatchFile(id) {
(compilation.fileDependencies ?? compilation.compilationDependencies).add((0, import_path4.resolve)(process.cwd(), id));
(compilation.fileDependencies ?? compilation.compilationDependencies).add(
(0, import_path4.resolve)(process.cwd(), id)
);
},

@@ -1253,10 +1267,17 @@ emitFile(emittedFile) {

if (emittedFile.source && outFileName) {
compilation.emitAsset(outFileName, import_webpack_sources.default ? new import_webpack_sources.default.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
});
compilation.emitAsset(
outFileName,
import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
}
);
}
},
getWatchFiles() {
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
return Array.from(
compilation.fileDependencies ?? compilation.compilationDependencies
);
}

@@ -1283,6 +1304,9 @@ };

const rawPlugin = factory(userOptions, meta);
const plugin = Object.assign(rawPlugin, {
__unpluginMeta: meta,
__virtualModulePrefix: virtualModulePrefix
});
const plugin = Object.assign(
rawPlugin,
{
__unpluginMeta: meta,
__virtualModulePrefix: virtualModulePrefix
}
);
const injected = compiler.$unpluginContext || {};

@@ -1297,20 +1321,22 @@ compiler.$unpluginContext = injected;

if (plugin.transform) {
const useLoader = [{
loader: TRANSFORM_LOADER,
ident: plugin.name,
options: {
unpluginName: plugin.name
}
}];
const useNone = [];
compiler.options.module.rules.push({
include(id) {
if (id == null) {
return false;
enforce: plugin.enforce,
use: (data) => {
if (data.resource == null) {
return useNone;
}
if (plugin.transformInclude) {
return plugin.transformInclude(slash(id));
} else {
return true;
const id = slash(data.resource + (data.resourceQuery || ""));
if (!plugin.transformInclude || plugin.transformInclude(id)) {
return useLoader;
}
},
enforce: plugin.enforce,
use: [{
loader: TRANSFORM_LOADER,
options: {
unpluginName: plugin.name
}
}]
return useNone;
}
});

@@ -1384,6 +1410,10 @@ }

if (compiler.modifiedFiles) {
compiler.modifiedFiles.forEach((file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "update" }))));
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" }))));
compiler.removedFiles.forEach(
(file) => promises.push(Promise.resolve(plugin.watchChange.call(context, file, { event: "delete" })))
);
}

@@ -1390,0 +1420,0 @@ await Promise.all(promises);

@@ -20,3 +20,6 @@ "use strict";

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -46,3 +49,5 @@

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

@@ -52,10 +57,17 @@ emitFile(emittedFile) {

if (emittedFile.source && outFileName) {
compilation.emitAsset(outFileName, import_webpack_sources.default ? new import_webpack_sources.default.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
});
compilation.emitAsset(
outFileName,
import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
}
);
}
},
getWatchFiles() {
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
return Array.from(
compilation.fileDependencies ?? compilation.compilationDependencies
);
}

@@ -62,0 +74,0 @@ };

@@ -20,3 +20,6 @@ "use strict";

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -46,3 +49,5 @@

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

@@ -52,10 +57,17 @@ emitFile(emittedFile) {

if (emittedFile.source && outFileName) {
compilation.emitAsset(outFileName, import_webpack_sources.default ? new import_webpack_sources.default.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
});
compilation.emitAsset(
outFileName,
import_webpack_sources.default ? new import_webpack_sources.default.RawSource(
typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)
) : {
source: () => emittedFile.source,
size: () => emittedFile.source.length
}
);
}
},
getWatchFiles() {
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
return Array.from(
compilation.fileDependencies ?? compilation.compilationDependencies
);
}

@@ -62,0 +74,0 @@ };

{
"name": "unplugin",
"version": "0.7.2",
"packageManager": "pnpm@7.5.1",
"version": "0.8.0",
"packageManager": "pnpm@7.6.0",
"description": "Unified plugin system for build tools",

@@ -33,3 +33,3 @@ "repository": "unjs/unplugin",

"dependencies": {
"acorn": "^8.7.1",
"acorn": "^8.8.0",
"chokidar": "^3.5.3",

@@ -41,7 +41,7 @@ "webpack-sources": "^3.2.3",

"@ampproject/remapping": "^2.2.0",
"@antfu/ni": "^0.16.3",
"@antfu/ni": "^0.17.2",
"@nuxtjs/eslint-config-typescript": "^10.0.0",
"@types/express": "^4.17.13",
"@types/fs-extra": "^9.0.13",
"@types/node": "^18.0.0",
"@types/node": "^18.6.1",
"@types/webpack-sources": "^3.2.0",

@@ -51,4 +51,4 @@ "bumpp": "^8.2.1",

"enhanced-resolve": "^5.10.0",
"esbuild": "^0.14.49",
"eslint": "^8.19.0",
"esbuild": "^0.14.50",
"eslint": "^8.20.0",
"fast-glob": "^3.2.11",

@@ -58,8 +58,8 @@ "fs-extra": "^10.1.0",

"magic-string": "^0.26.2",
"rollup": "^2.76.0",
"tsup": "^6.1.3",
"rollup": "^2.77.0",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"vite": "^2.9.14",
"vitest": "^0.18.0",
"webpack": "^5.73.0",
"vite": "^3.0.3",
"vitest": "^0.19.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"

@@ -66,0 +66,0 @@ },

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

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