From 14563086f72658bb03d5afc09a88feca85c18890 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Fri, 3 Feb 2023 08:21:03 +0200 Subject: [PATCH] 1.1.28 Fixes Version 1.1.27 breaks Astro dev and build #63 --- CHANGELOG.md | 4 ++++ dist/index.js | 2 +- dist/options/critters.js | 1 + package.json | 4 ++-- src/index.ts | 19 +++++++++---------- src/options/critters.ts | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 dist/options/critters.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a0b6a2..6ad208f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.28 + +- Bug fix + ## 1.1.27 - Cleanup diff --git a/dist/index.js b/dist/index.js index 2db110c..36b5698 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -import n from"./options/index.js";import{fileURLToPath as f}from"url";import p from"files-pipeline/dist/lib/apply-to.js";import o from"files-pipeline/dist/lib/deepmerge.js";import{files as c}from"files-pipeline";import l from"critters";var g=(t={})=>{for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]===!0&&(t[e]=n[e]);t=o(n,t);const a=new Set;if(typeof t.path<"u")if(t.path instanceof Array||t.path instanceof Set)for(const e of t.path)a.add(e);else a.add(t.path);return{name:"astro-critters",hooks:{"astro:build:done":async()=>{if(t.critters)for(const e of a){const i=await p(e,r=>r instanceof URL?f(r):r),s=new l(o(t.critters,{path:i instanceof Map?i.keys().next().value:i,logLevel:(()=>{switch(t.logger){case 0:return"silent";case 1:return"silent";case 2:return"info";default:return"info"}})()}));await(await(await(await new c(t.logger).in(e)).by("**/*.html")).not(t.exclude)).pipeline(o(n.pipeline,{wrote:async r=>s.process(r.buffer)}))}}}}};export{g as default}; +import f from"critters";import n from"./options/index.js";import o from"files-pipeline/dist/lib/deepmerge.js";import{files as p}from"files-pipeline";import{fileURLToPath as c}from"url";import l from"files-pipeline/dist/lib/apply-to.js";var g=(t={})=>{for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]===!0&&(t[e]=n[e]);t=o(n,t);const i=new Set;if(typeof t.path<"u")if(t.path instanceof Array||t.path instanceof Set)for(const e of t.path)i.add(e);else i.add(t.path);return{name:"astro-critters",hooks:{"astro:build:done":async()=>{if(t.critters)for(const e of i){const a=await l(e,r=>r instanceof URL?c(r):r),s=new f(o(t.critters,{path:a instanceof Map?a.keys().next().value:a,logLevel:(()=>{switch(t.logger){case 0:return"silent";case 1:return"silent";case 2:return"info";default:return"info"}})()}));await(await(await(await new p(t.logger).in(e)).by("**/*.html")).not(t.exclude)).pipeline(o(n.pipeline,{wrote:async r=>s.process(r.buffer.toString())}))}}}}};export{g as default}; diff --git a/dist/options/critters.js b/dist/options/critters.js new file mode 100644 index 0000000..b17496f --- /dev/null +++ b/dist/options/critters.js @@ -0,0 +1 @@ +var e={preload:"media",inlineFonts:!0,compress:!0,pruneSource:!0};export{e as default}; diff --git a/package.json b/package.json index aa59aeb..e320f66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "astro-critters", - "version": "1.1.27", + "version": "1.1.28", "type": "module", "description": "🦔 AstroJS GoogleChromeLabs critters integration. Inline your critical CSS with Astro.", "repository": { @@ -24,7 +24,7 @@ "performance" ], "scripts": { - "build": "lightrix build src/index.ts src/options/index.ts" + "build": "lightrix build src/index.ts src/options/*.ts" }, "dependencies": { "critters": "0.0.16", diff --git a/src/index.ts b/src/index.ts index 2d925ff..33c4cd9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,24 +1,23 @@ -import type { AstroIntegration } from "astro"; - import type { executions, optionPath, } from "files-pipeline/dist/options/index.js"; -import type { Options } from "./options/index.js"; +// @ts-ignore +import Critters from "critters"; import defaults from "./options/index.js"; +import deepmerge from "files-pipeline/dist/lib/deepmerge.js"; +import { files } from "files-pipeline"; + import { fileURLToPath } from "url"; import applyTo from "files-pipeline/dist/lib/apply-to.js"; -import deepmerge from "files-pipeline/dist/lib/deepmerge.js"; -import { files } from "files-pipeline"; +import type { AstroIntegration } from "astro"; -// critters -// @ts-ignore -import Critters from "critters"; +import type { Options } from "./options/index.js"; export default (options: Options = {}): AstroIntegration => { for (const option in options) { @@ -80,7 +79,7 @@ export default (options: Options = {}): AstroIntegration => { return "info"; } })(), - }) + } satisfies Options["critters"]) ); await ( @@ -92,7 +91,7 @@ export default (options: Options = {}): AstroIntegration => { ).pipeline( deepmerge(defaults["pipeline"], { wrote: async (current) => - critters.process(current.buffer), + critters.process(current.buffer.toString()), } satisfies executions) ); } diff --git a/src/options/critters.ts b/src/options/critters.ts index f0a14e7..94a12be 100644 --- a/src/options/critters.ts +++ b/src/options/critters.ts @@ -11,4 +11,4 @@ export default { inlineFonts: true, compress: true, pruneSource: true, -}; +} satisfies CRITTERS;