@visulima/packem-rollup 1.0.0-alpha.20 → 1.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## @visulima/packem-rollup [1.0.0-alpha.21](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.20...@visulima/packem-rollup@1.0.0-alpha.21) (2025-10-08)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* update dependencies and improve minification options ([25b69b5](https://github.com/visulima/packem/commit/25b69b50f7631655303a417e61f3a37e2aa3c017))
|
|
6
|
+
|
|
1
7
|
## @visulima/packem-rollup [1.0.0-alpha.20](https://github.com/visulima/packem/compare/@visulima/packem-rollup@1.0.0-alpha.19...@visulima/packem-rollup@1.0.0-alpha.20) (2025-10-08)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
|
@@ -27,7 +27,7 @@ interface ParseLiteralsOptions {
|
|
|
27
27
|
fileName?: string;
|
|
28
28
|
strategy?: Partial<Strategy$1<unknown>>;
|
|
29
29
|
}
|
|
30
|
-
declare
|
|
30
|
+
declare const parseLiterals: (source: string, options?: ParseLiteralsOptions) => Template[];
|
|
31
31
|
|
|
32
32
|
interface Strategy<O = unknown, C = unknown> {
|
|
33
33
|
combineHTMLStrings: (parts: TemplatePart[], placeholder: string) => string;
|
|
@@ -85,12 +85,11 @@ declare function minifyHTMLLiterals<S extends Strategy>(source: string, options?
|
|
|
85
85
|
interface MinifyHTMLLiteralsOptions {
|
|
86
86
|
exclude?: FilterPattern;
|
|
87
87
|
failOnError?: boolean;
|
|
88
|
-
|
|
89
|
-
include?: string | string[];
|
|
88
|
+
include?: FilterPattern;
|
|
90
89
|
minifyHTMLLiterals?: typeof minifyHTMLLiterals;
|
|
91
90
|
options?: Partial<Options>;
|
|
92
91
|
}
|
|
93
|
-
declare const minifyHTMLLiteralsPlugin: ({ exclude, failOnError,
|
|
92
|
+
declare const minifyHTMLLiteralsPlugin: ({ exclude, failOnError, include, logger, minifyHTMLLiterals, options, }: MinifyHTMLLiteralsOptions & {
|
|
94
93
|
logger: PailServerType;
|
|
95
94
|
}) => Plugin;
|
|
96
95
|
|
|
@@ -20,7 +20,7 @@ declare namespace minifyHTMLLiteralsPlugin {
|
|
|
20
20
|
export interface ParseLiteralsOptions {
|
|
21
21
|
fileName?: string;
|
|
22
22
|
strategy?: Partial<Strategy$1<unknown>>; }
|
|
23
|
-
export
|
|
23
|
+
export const parseLiterals: (source: string, options?: ParseLiteralsOptions) => Template[];
|
|
24
24
|
export interface Strategy<O = unknown, C = unknown> {
|
|
25
25
|
combineHTMLStrings: (parts: TemplatePart[], placeholder: string) => string;
|
|
26
26
|
getPlaceholder: (parts: TemplatePart[]) => string;
|
|
@@ -66,11 +66,10 @@ declare namespace minifyHTMLLiteralsPlugin {
|
|
|
66
66
|
export interface MinifyHTMLLiteralsOptions {
|
|
67
67
|
exclude?: FilterPattern;
|
|
68
68
|
failOnError?: boolean;
|
|
69
|
-
|
|
70
|
-
include?: string | string[];
|
|
69
|
+
include?: FilterPattern;
|
|
71
70
|
minifyHTMLLiterals?: typeof minifyHTMLLiterals;
|
|
72
71
|
options?: Partial<Options>; }
|
|
73
|
-
export const minifyHTMLLiteralsPlugin: ({ exclude, failOnError,
|
|
72
|
+
export const minifyHTMLLiteralsPlugin: ({ exclude, failOnError, include, logger, minifyHTMLLiterals, options, }: MinifyHTMLLiteralsOptions & {
|
|
74
73
|
logger: PailServerType;
|
|
75
74
|
}) => Plugin;
|
|
76
75
|
import _default = minifyHTMLLiteralsPlugin;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var g=(t,e)=>b(t,"name",{value:e,configurable:!0});import{createFilter as E}from"@rollup/pluginutils";import H from"magic-string";import p from"typescript";import N from"clean-css";import{minify as j}from"html-minifier-next";let y;const A={getHeadTemplatePart(t){const e=t.getFullText(y),i=e.indexOf("`")+1,r=p.isTemplateHead(t)?-2:-1;return{end:t.end+r,start:t.pos+i,text:e.slice(i,e.length+r)}},getMiddleTailTemplatePart(t){const e=t.getText(y),i=p.isTemplateMiddle(t)?2:1;return{end:t.end-i,start:t.getStart(y)+1,text:e.slice(1,e.length-i)}},getRootNode(t,e=""){return p.createSourceFile(e,t,p.ScriptTarget.ESNext)},getTaggedTemplateTemplate(t){return t.template},getTagText(t){return t.tag.getText(y)},getTemplateParts(t){return p.isNoSubstitutionTemplateLiteral(t)?[this.getHeadTemplatePart(t)]:[this.getHeadTemplatePart(t.head),...t.templateSpans.map(e=>this.getMiddleTailTemplatePart(e.literal))]},isTaggedTemplate:p.isTaggedTemplateExpression,isTemplate:p.isTemplateLiteral,walkChildNodes(t,e){e(t),p.forEachChild(t,i=>{this.walkChildNodes(i,e)})},walkNodes(t,e){y=t,this.walkChildNodes(t,e),y=void 0}};var k=Object.defineProperty,V=g((t,e)=>k(t,"name",{value:e,configurable:!0}),"i");const W=V((t,e={})=>{const i={...A,...e.strategy},r=[],s=[];return i.walkNodes(i.getRootNode(t,e.fileName),n=>{if(i.isTaggedTemplate(n)){const a=i.getTaggedTemplateTemplate(n);s.push(a),r.push({parts:i.getTemplateParts(a),tag:i.getTagText(n)})}else i.isTemplate(n)&&!s.includes(n)&&r.push({parts:i.getTemplateParts(n)})}),r},"parseLiterals");var $=Object.defineProperty,C=g((t,e)=>$(t,"name",{value:e,configurable:!0}),"f");const S={One:"1",Two:"2",Zero:"0"},F=C(t=>{const e={[S.One]:{tidySelectors:!1,transform:void 0},[S.Two]:{tidySelectors:!1,transform:void 0},[S.Zero]:{}};if(t===void 0)return e;if(typeof t=="number"){const i=t.toString();return{...e,[i]:{...e[i]}}}return t},"optimizationLevelFrom"),R={},B={caseSensitive:!0,collapseWhitespace:!0,decodeEntities:!0,minifyCSS:R,minifyJS:!0,processConditionalComments:!0,removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,useShortDoctype:!0},_={combineHTMLStrings(t,e){return t.map(i=>i.text).join(e)},getPlaceholder(t){let e="@TEMPLATE_EXPRESSION";for(;t.some(i=>i.text.includes(e+"();"));)e+="_";return e+"();"},minifyCSS(t,e={}){const i=P(e),r=new N(i).minify(t);if(r.errors&&r.errors.length>0)throw new Error(r.errors.join(`
|
|
2
2
|
|
|
3
|
-
`));return i.level[S.One].tidySelectors&&(r.styles=
|
|
3
|
+
`));return i.level[S.One].tidySelectors&&(r.styles=x(t,r.styles)),r.styles},async minifyHTML(t,e={}){let i;e.minifyCSS?i=e.minifyCSS!==!0&&typeof e.minifyCSS!="function"?{...e.minifyCSS}:{}:i=!1;let r=!1;i&&(r=P(i));let s=await j(t,{...e,minifyCSS:r});if(e.collapseWhitespace){const n=[...s.matchAll(/<svg/g)].reverse();for(const a of n){const o=a.index,f=s.indexOf("</svg",o);if(f===-1)continue;const u=s.slice(0,Math.max(0,o));let l=s.substring(o,f);const d=s.slice(Math.max(0,f));l=l.replaceAll(/\r?\n/g,""),s=u+l+d}}return r&&r.level[S.One].tidySelectors&&(s=x(t,s)),s},splitHTMLByPlaceholder(t,e){const i=t.split(e);if(e.endsWith(";")){const r=e.slice(0,Math.max(0,e.length-1));for(let s=i.length-1;s>=0;s--){const n=i[s];n!==void 0&&i.splice(s,1,...n.split(r))}}return i}},P=C((t={})=>{const e=F(t.level),i=typeof t.level=="object"&&t.level[1]&&t.level[1].transform;return e[S.One].transform=(r,s)=>s.startsWith("@TEMPLATE_EXPRESSION")&&!s.endsWith(";")?s=`${s};`:i?i(r,s):s,{...t,level:e}},"adjustMinifyCSSOptions"),x=C((t,e)=>{const i=/(:.+\((.*)\))\s*\{/g;let r;for(;(r=i.exec(t))!=null;){const s=r[1],n=r[2];if(!s||!n||!/\s/.test(n))continue;const a=n.replaceAll(/\s/g,""),o=s.replace(n,a),f=e.indexOf(o);if(f===-1)continue;const u=f+o.length;e=e.slice(0,Math.max(0,f))+s+e.slice(Math.max(0,u))}return e},"fixCleanCssTidySelectors");var G=Object.defineProperty,M=g((t,e)=>G(t,"name",{value:e,configurable:!0}),"l");const I=M((t,e)=>t.generateMap({file:`${e}.map`,hires:!0,source:e}),"defaultGenerateSourceMap"),X=M(t=>{const e=t.tag&&t.tag.toLowerCase();return!!e&&(e.includes("html")||e.includes("svg"))},"defaultShouldMinify"),Z=M(t=>!!t.tag&&t.tag.toLowerCase().includes("css"),"defaultShouldMinifyCSS"),z={ensureHTMLPartsValid(t,e){if(t.length!==e.length)throw new Error("splitHTMLByPlaceholder() must return same number of strings as template parts")},ensurePlaceholderValid(t){if(typeof t!="string"||t.length===0)throw new Error("getPlaceholder() must return a non-empty string")}};async function w(t,e={}){e.minifyOptions={...B,...e.minifyOptions},e.MagicString||(e.MagicString=H),e.parseLiterals||(e.parseLiterals=W),e.shouldMinify||(e.shouldMinify=X),e.shouldMinifyCSS||(e.shouldMinifyCSS=Z),e.parseLiteralsOptions={fileName:e.fileName,...e.parseLiteralsOptions};const i=e.parseLiterals(t,e.parseLiteralsOptions),r=e.strategy||_,{shouldMinify:s,shouldMinifyCSS:n}=e;let a;e.validate!==!1&&(a=e.validate||z);const o=new e.MagicString(t);for(const l of i){const d=s(l),O=!!r.minifyCSS&&n(l);if(d||O){const v=r.getPlaceholder(l.parts);a&&a.ensurePlaceholderValid(v);const T=r.combineHTMLStrings(l.parts,v);let h;if(O){const c=(e.minifyOptions||{}).minifyCSS;if(typeof c=="function"){const m=c(T);h=typeof m=="string"?m:await m}else if(c===!1)h=T;else{const m=typeof c=="object"?c:void 0;h=await r.minifyCSS(T,m)}}else h=await r.minifyHTML(T,e.minifyOptions);const L=r.splitHTMLByPlaceholder(h,v);a&&a.ensureHTMLPartsValid(l.parts,L),l.parts.forEach((c,m)=>{c.start<c.end&&L[m]!==void 0&&o.overwrite(c.start,c.end,L[m])})}}const f=o.toString();if(t===f)return null;let u;return e.generateSourceMap!==!1&&(u=(e.generateSourceMap||I)(o,e.fileName??"")),{code:f,map:u}}g(w,"minifyHTMLLiterals");M(w,"minifyHTMLLiterals");var D=Object.defineProperty,J=g((t,e)=>D(t,"name",{value:e,configurable:!0}),"o");const te=J(({exclude:t,failOnError:e=!1,include:i,logger:r,minifyHTMLLiterals:s,options:n})=>{s||(s=w);const a=E(i,t),o=n||{};return{name:"packem:minify-html-literals",async transform(f,u){if(a(u))try{return await s(f,{...o,fileName:u})}catch(l){const d=l instanceof Error?l.message:l;e?this.error(d):r.warn({message:d,prefix:"plugin:minify-html-literals"})}}}},"minifyHTMLLiteralsPlugin");export{te as default,te as minifyHTMLLiteralsPlugin};
|