vite-plugin-esi
Advanced tools
+5
-1
@@ -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; |
+14
-6
@@ -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; |
+2
-1
@@ -1,1 +0,2 @@ | ||
| export {}; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
+1
-2
| { | ||
| "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" |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
8918
8.24%100
19.05%0
-100%No
NaN