Compress
Compress copied to clipboard
Fatal error on build (Deno Adapter)
Hi Guys, I've an issue using this plugin on build. It's might be compatibility issue with Deno Adapter. Here is the evidences:
Details:
❯ pnpm run build
> @apps/[email protected] build /Users/rio/Projects/JS/web/apps/astro-blog
> astro build
11:02:51 PM [build] output target: server
11:02:51 PM [build] deploy adapter: @astrojs/deno
11:02:51 PM [build] Collecting build info...
11:02:51 PM [build] Completed in 280ms.
11:02:51 PM [build] Building server entrypoints...
🌼 daisyUI components 2.33.0 https://github.com/saadeghi/daisyui
✔︎ Including: base, components, themes[1], utilities
11:02:54 PM [build] Completed in 2.23s.
building client
Completed in 295ms.
finalizing server assets
11:02:54 PM [build] Rearranging server assets...
@astrojs/sitemap: Skipped!
No pages found! We can only detect sitemap routes for "static" builds. Since you are using an SSR adapter, we recommend manually listing your sitemap routes using the "customPages" integration option.
Example: `sitemap({ customPages: ['https://example.com/route'] })`
Compressed about.39dc5942.css for 1 Bytes (1.61% reduction).
Compressed about.d36aaeb4.css for 2.36 KB (5.69% reduction).
Compressed blog.0b6c13c9.css for 1 Bytes (0.28% reduction).
Successfully compressed a total of 3 CSS files for 2.37 KB.
Compressed client.8e9befd7.js for 1.1 KB (0.79% reduction).
Compressed entry.mjs for 495.85 KB (50.75% reduction).
Successfully compressed a total of 2 JS files for 496.95 KB.
Compressed favicon.svg for 84 Bytes (9.62% reduction).
Successfully compressed a total of 1 SVG file for 84 Bytes.
✘ [ERROR] Could not resolve "stream"
dist/server/entry.mjs:73:87825:
73 │ ...ct.createElement("div")}),t,n,{}),r)throw r;return a}async function getNodeWritable(){let{Writable:e}=await import("stream");return e}async function renderToStaticMarkup$1(e,t,{default:n,...r},a){delete t.class;const o={};for(const[e,t]o...
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
error Build failed with 1 error:
dist/server/entry.mjs:73:87825: ERROR: Could not resolve "stream"
File:
dist/server/entry.mjs
Code:
1623 | }).join("");
> 1624 | let error = new Error(`${text}${summary}`);
| ^
1625 | error.errors = errors;
1626 | error.warnings = warnings;
1627 | return error;
Stacktrace:
Error: Build failed with 1 error:
dist/server/entry.mjs:73:87825: ERROR: Could not resolve "stream"
at failureErrorWithLog (/Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1624:15)
at /Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1266:28
at runOnEndCallbacks (/Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1179:65)
at buildResponseToResult (/Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1264:7)
at /Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1377:14
at /Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:678:9
at handleIncomingPacket (/Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:775:9)
at Socket.readFromStdout (/Users/rio/Projects/JS/web/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:644:7)
at Socket.emit (node:events:527:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
ELIFECYCLE Command failed with exit code 1.
Thank you, :)
Can I take a look at your astro.config.mjs
?
Hi @riobahtiar could you please share a reproduction if possible,
Hi @nikolaxhristov @aFuzzyBear , Sorry for late reply. Here is my setup
-
package.json
{
"name": "@apps/astro-blog",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev --port 3000",
"start": "astro dev",
"build": "astro build",
"preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs",
"astro": "astro"
},
"dependencies": {
"@astrojs/deno": "^1.2.0",
"@astrojs/mdx": "^0.11.4",
"@astrojs/prefetch": "^0.0.8",
"@astrojs/react": "^1.2.0",
"@astrojs/rss": "^1.0.2",
"@astrojs/sitemap": "^1.0.0",
"@astrojs/tailwind": "^2.1.0",
"@mdx-js/rollup": "^2.1.5",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"astro": "^1.5.0",
"astro-compress": "^1.0.12",
"autoprefixer": "^10.4.12",
"daisyui": "^2.31.0",
"postcss": "^8.4.18",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-ui": "workspace:*",
"rollup": "^3.2.1",
"tailwindcss": "^3.2"
},
"devDependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.0",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/line-clamp": "^0.4.2",
"@tailwindcss/typography": "^0.5.7"
}
}
-
astro.config.mjs
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
// https://astro.build/config
import deno from "@astrojs/deno";
// https://astro.build/config
import react from "@astrojs/react";
// https://astro.build/config
import tailwind from "@astrojs/tailwind";
// https://astro.build/config
import prefetch from "@astrojs/prefetch";
// https://astro.build/config
import compress from "astro-compress";
// https://astro.build/config
export default defineConfig({
site: "https://rio.deno.dev",
integrations: [mdx(), sitemap(), react(), tailwind(), prefetch(), compress()],
output: "server",
adapter: deno()
});
Thank you
@riobahtiar Can you try a reproduction of the repo on stackblitz or codesandbox?