PlayForm / Compress

🗜️ Compress —
https://NPMJS.Org/@playform/compress
MIT License
469 stars 12 forks source link

Build error on Vercel: (intermediate value).black is not a function #233

Closed FlipFloop closed 7 months ago

FlipFloop commented 7 months ago

Fails on NodeJS v18 and v20.


error   (intermediate value).black is not a function
--
12:17:59.685 | File:
12:17:59.685 | /vercel/path0/node_modules/.pnpm/astro-compress@2.2.4/node_modules/astro-compress/Target/Function/Integration.js:2:59
12:17:59.685 | Code:
12:17:59.685 | 1 \| let p;var P=(...[r={}])=>{Object.entries(r).forEach(([e,a])=>Object.defineProperty(r,e,{value:a===!0?u[e]:r[e]}));const{Path:o,Cache:s,Logger:g,Map:l,Exclude:h,Action:d,CSS:S,HTML:b,Image:j,JavaScript:A,SVG:T,Parser:y}=f(u,r),n=new Set;return typeof o<"u"&&(Array.isArray(o)\|\|o instanceof Set)&&o.forEach(e=>n.add(e)),typeof y=="object"&&Object.entries(y).forEach(([e,a])=>Object.defineProperty(y,e,{value:Array.isArray(a)?a:[a]})),{name:"astro-compress",hooks:{"astro:config:done":async({config:{outDir:{pathname:e}}})=>{p=(await import("path")).parse(e).dir.replace(/\\/g,"/"),p.startsWith("/")&&(p=p.substring(1))},"astro:build:done":async({dir:e})=>{if(console.log(`
12:17:59.685 | > 2 \| ${(await import("kleur")).bgGreen((await import("kleur")).black(" astro-compress processing "))}`),typeof l=="object"){n.size\|\|n.add(e),typeof s=="object"&&s.Search===x&&(s.Search=e);for(const[a,i]of Object.entries({CSS:S,HTML:b,Image:j,JavaScript:A,SVG:T})){if(!(i&&l[a])\|\|typeof i!="object")return;m=f(d,f(d,{Wrote:async({Buffer:t,Input:c})=>{switch(a){case"CSS":return(await import("csso")).minify(t.toString(),i.csso).css;case"HTML":return await(await import("html-minifier-terser")).minify(t.toString(),i["html-minifier-terser"]);case"JavaScript":return(await(await import("terser")).minify(t.toString(),i.terser)).code??t;case"Image":return await(await import("../Function/Image/Writesharp.js")).default(i.sharp,{Buffer:t,Input:c});case"SVG":{const{data:I}=(await import("svgo")).optimize(t.toString(),i.svgo);return I??t}default:return t}},Fulfilled:async t=>t.Files>0?`${(await import("kleur")).green(`\u2713 Successfully compressed a total of ${t.Files} ${a} ${t.Files===1?"file":"files"} for ${await(await import("files-pipe/Target/Function/Bytes.js")).default(t.Info.Total)}.`)}`:!1})),a==="Image"&&(m=f(m,{Read:async({Input:t})=>{const{format:c}=await w(t).metadata();return w(t,{failOn:"none",sequentialRead:!0,unlimited:!0,animated:c==="webp"\|\|c==="gif"})}}));for(const t of n)await(await(await(await new(await import("files-pipe")).default(s,g).In(t)).By(l[a]??"**/*")).Not(h)).Pipe(m)}}}}}};const{default:u}=await import("../Variable/Option.js"),{default:{Cache:{Search:x}}}=await import("files-pipe/Target/Variable/Option.js"),{default:f}=await import("typescript-esbuild/Target/Function/Merge.js"),{default:w}=await import("sharp");let m;export{u as Default,w as Defaultsharp,f as Merge,x as Search,p as System,m as _Action,P as default};
12:17:59.685 | \|                                                           ^
12:17:59.685 | Stacktrace:
12:17:59.685 | TypeError: (intermediate value).black is not a function
12:17:59.685 | at astro:build:done (file:///vercel/path0/node_modules/.pnpm/astro-compress@2.2.4/node_modules/astro-compress/Target/Function/Integration.js:2:59)
12:17:59.685 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
12:17:59.685 | at async withTakingALongTimeMsg (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/integrations/index.js:18:18)
12:17:59.685 | at async runHookBuildDone (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/integrations/index.js:328:7)
12:17:59.685 | at async AstroBuilder.build (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:145:5)
12:17:59.685 | at async AstroBuilder.run (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:165:7)
12:17:59.685 | at async build (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/core/build/index.js:44:3)
12:17:59.686 | at async build (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/cli/build/index.js:21:3)
12:17:59.686 | at async runCommand (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/cli/index.js:116:7)
12:17:59.686 | at async cli (file:///vercel/path0/node_modules/.pnpm/astro@3.6.4_sass@1.69.5_typescript@5.3.2/node_modules/astro/dist/cli/index.js:144:5)
12:17:59.686 |  
12:17:59.801 | ELIFECYCLE  Command failed with exit code 1.
12:17:59.817 | Error: Command "pnpm run build" exited with 1

Here is my package.json

"dependencies": {
    "@astrojs/mdx": "^1.1.5",
    "@astrojs/react": "^3.0.6",
    "@astrojs/sitemap": "^3.0.3",
    "@astrojs/vercel": "^5.2.0",
    "@mojs/core": "^1.7.1",
    "@mojs/player": "^1.3.0",
    "@react-three/drei": "^9.90.0",
    "@react-three/fiber": "^8.15.12",
    "@react-three/offscreen": "^0.0.8",
    "@react-three/postprocessing": "^2.15.11",
    "@types/react": "^18.2.41",
    "@types/react-dom": "^18.2.17",
    "@types/three": "^0.159.0",
    "astro": "^3.6.4",
    "astro-compress": "^2.2.4",
    "astro-icon": "^0.8.1",
    "astro-particles": "^2.10.0",
    "csv-parse": "^5.5.2",
    "highcharts": "^11.2.0",
    "lamina": "^1.1.23",
    "leaflet": "^1.9.4",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "three": "^0.159.0",
    "tsparticles": "^2.12.0",
    "tsparticles-engine": "^2.12.0"
  },
  "devDependencies": {
    "astro-robots-txt": "^1.0.0",
    "astro-seo": "^0.8.0",
    "autoprefixer": "^10.4.16",
    "cssnano": "^6.0.1",
    "prettier-plugin-astro": "^0.12.2",
    "sass": "^1.69.5",
    "typescript": "^5.3.2"
  }
eidmanna commented 7 months ago

I can confirm this error:

@astrojs/sitemap: sitemap-index.xml created at dist

error (intermediate value).black is not a function File: C:\Users\cherie\Documents\evang9\meka1\node_modules\astro-compress\Target\Function\Integration.js:2:59 Code: 1 | let p;var P=(...[r={}])=>{Object.entries(r).forEach(([e,a])=>Object.defineProperty(r,e,{value:a===!0?u[e]:r[e]}));const{Path:o,Cache:s,Logger:g,Map:l,Exclude:h,Action:d,CSS:S,HTML:b,Image:j,JavaScript:A,SVG:T,Parser:y}=f(u,r),n=new Set;return typeof o<"u"&&(Array.isArray(o)||o instanceof Set)&&o.forEach(e=>n.add(e)),typeof y=="object"&&Object.entries(y).forEach(([e,a])=>Object.defineProperty(y,e,{value:Array.isArray(a)?a:[a]})),{name:"astro-compress",hooks:{"astro:config:done":async({config:{outDir:{pathname:e}}})=>{p=(await import("path")).parse(e).dir.replace(/\/g,"/"),p.startsWith("/")&&(p=p.substring(1))},"astro:build:done":async({dir:e})=>{if(console.log(`

2 | ${(await import("kleur")).bgGreen((await import("kleur")).black(" astro-compress processing "))}),typeof l=="object"){n.size||n.add(e),typeof s=="object"&&s.Search===x&&(s.Search=e);for(const[a,i]of Object.entries({CSS:S,HTML:b,Image:j,JavaScript:A,SVG:T})){if(!(i&&l[a])||typeof i!="object")return;m=f(d,f(d,{Wrote:async({Buffer:t,Input:c})=>{switch(a){case"CSS":return(await import("csso")).minify(t.toString(),i.csso).css;case"HTML":return await(await import("html-minifier-terser")).minify(t.toString(),i["html-minifier-terser"]);case"JavaScript":return(await(await import("terser")).minify(t.toString(),i.terser)).code??t;case"Image":return await(await import("../Function/Image/Writesharp.js")).default(i.sharp,{Buffer:t,Input:c});case"SVG":{const{data:I}=(await import("svgo")).optimize(t.toString(),i.svgo);return I??t}default:return t}},Fulfilled:async t=>t.Files>0?${(await import("kleur")).green(\u2713 Successfully compressed a total of ${t.Files} ${a} ${t.Files===1?"file":"files"} for ${await(await import("files-pipe/Target/Function/Bytes.js")).default(t.Info.Total)}.)}`:!1})),a==="Image"&&(m=f(m,{Read:async({Input:t})=>{const{format:c}=await w(t).metadata();return w(t,{failOn:"none",sequentialRead:!0,unlimited:!0,animated:c==="webp"||c==="gif"})}}));for(const t of n)await(await(await(await new(await import("files-pipe")).default(s,g).In(t)).By(l[a]??"*/")).Not(h)).Pipe(m)}}}}}};const{default:u}=await import("../Variable/Option.js"),{default:{Cache:{Search:x}}}=await import("files-pipe/Target/Variable/Option.js"),{default:f}=await import("typescript-esbuild/Target/Function/Merge.js"),{default:w}=await import("sharp");let m;export{u as Default,w as Defaultsharp,f as Merge,x as Search,p as System,m as _Action,P as default}; | ^ Stacktrace: TypeError: (intermediate value).black is not a function at astro:build:done (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro-compress/Target/Function/Integration.js:2:59) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async withTakingALongTimeMsg (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/integrations/index.js:18:18) at async runHookBuildDone (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/integrations/index.js:328:7) at async AstroBuilder.build (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/core/build/index.js:145:5) at async AstroBuilder.run (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/core/build/index.js:165:7) at async build (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/core/build/index.js:44:3) at async build (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/cli/build/index.js:21:3) at async runCommand (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/cli/index.js:116:7) at async cli (file:///C:/Users/cherie/Documents/evang9/meka1/node_modules/astro/dist/cli/index.js:144:5)

eidmanna commented 7 months ago

Workaround: Downgrade to "astro-compress": "2.2.3", will fix this error.

matteocodogno commented 7 months ago

Same error on netlify

NikolaRHristov commented 7 months ago

AstroCompress v2.2.4 has been deprecated and is unpublished.

NikolaRHristov commented 7 months ago

Fixed in v2.2.5