Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

vite-plugin-esi

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-esi - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+5
-1
dist/errors.js

@@ -1,2 +0,5 @@

export class TagsNotFoundError extends Error {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TagsNotFoundError = void 0;
class TagsNotFoundError extends Error {
constructor(message) {

@@ -7,1 +10,2 @@ super(message);

}
exports.TagsNotFoundError = TagsNotFoundError;
+7
-4

@@ -1,3 +0,5 @@

import { resolveESI, transformHtml } from './transform';
export default function esiPlugin(options) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const transform_1 = require("./transform");
function esiPlugin(options) {
var _a;

@@ -8,5 +10,5 @@ const shouldResolveESI = (_a = options.resolveESI) !== null && _a !== void 0 ? _a : true;

transformIndexHtml(inputHtml) {
const html = transformHtml(inputHtml, options.esi);
const html = (0, transform_1.transformHtml)(inputHtml, options.esi);
if (shouldResolveESI) {
return resolveESI(html);
return (0, transform_1.resolveESI)(html);
}

@@ -16,1 +18,2 @@ },

}
exports.default = esiPlugin;

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,6 +11,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import ESI from 'nodesi';
import { TagsNotFoundError } from './errors';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveESI = exports.transformHtml = void 0;
const nodesi_1 = __importDefault(require("nodesi"));
const errors_1 = require("./errors");
// Will transform the html by replacing the special comments with the esi tags
export function transformHtml(html, options) {
function transformHtml(html, options) {
const regex = /<!--*\s*vite-plugin-esi\s(name="(?<name>[a-zA-Z0-9]+)").*->/g; // example <!-- vite-plugin-esi name="header" -->

@@ -19,3 +25,3 @@ return html.replace(regex, (_match, _, __, ___, ____, groups) => {

if (!tags) {
throw new TagsNotFoundError(`no tags found for ${groups.name}`);
throw new errors_1.TagsNotFoundError(`no tags found for ${groups.name}`);
}

@@ -30,5 +36,6 @@ return tags

}
export function resolveESI(html, options) {
exports.transformHtml = transformHtml;
function resolveESI(html, options) {
return __awaiter(this, void 0, void 0, function* () {
const esi = new ESI(options);
const esi = new nodesi_1.default(options);
const resolvedHtml = yield esi.process(html);

@@ -38,1 +45,2 @@ return resolvedHtml;

}
exports.resolveESI = resolveESI;

@@ -1,1 +0,2 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
{
"name": "vite-plugin-esi",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"repository": {

@@ -9,0 +8,0 @@ "url": "https://github.com/marcusthelin/vite-plugin-esi"