-
Notifications
You must be signed in to change notification settings - Fork 72
Fixes #319 - Image optimization and basic caching #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,35 @@ import { defineConfig } from "vite"; | |
| import react from "@vitejs/plugin-react"; | ||
| import path from "path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [react()], | ||
| plugins: [ | ||
| react(), | ||
| ViteImageOptimizer({ | ||
| png: { quality: 80 }, | ||
| jpeg: { quality: 80 }, | ||
| jpg: { quality: 80 }, | ||
| webp: { lossless: true }, | ||
| }) | ||
| ], | ||
|
Comment on lines
+5
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -C 2 'assetsInlineLimit|ViteImageOptimizer' vite.config.js
fd -HI -t f -e png -e jpg -e jpeg -e webp . \
--exclude node_modules \
--exclude distRepository: AURORALAOrg/aurora-frontend Length of output: 1361 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- vite.config.js ---'
cat -n vite.config.js
printf '%s\n' '--- package manifests ---'
for f in package.json package-lock.json npm-shrinkwrap.json pnpm-lock.yaml yarn.lock; do
if [ -f "$f" ]; then
printf '\n[%s]\n' "$f"
rg -n -C 3 'vite|vite-plugin-image-optimizer|sharp|pngquant|jpeg|webp' "$f" | head -160
fi
done
printf '%s\n' '--- image references ---'
rg -n -C 2 '\.(png|jpe?g|webp)(\?[^"'\'']*)?["'\'']|/.*\.(png|jpe?g|webp)' --glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' . | head -240Repository: AURORALAOrg/aurora-frontend Length of output: 17702 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- vite.config.js ---'
cat -n vite.config.js
printf '%s\n' '--- package manifests ---'
for f in package.json package-lock.json npm-shrinkwrap.json pnpm-lock.yaml yarn.lock; do
if [ -f "$f" ]; then
printf '\n[%s]\n' "$f"
rg -n -C 3 'vite|vite-plugin-image-optimizer|sharp|pngquant|jpeg|webp' "$f" | head -160
fi
done
printf '%s\n' '--- image references ---'
rg -n -C 2 '\.(png|jpe?g|webp)(\?[^"'\'']*)?["'\'']|/.*\.(png|jpe?g|webp)' \
--glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' . | head -240Repository: AURORALAOrg/aurora-frontend Length of output: 16152 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
printf '%s\n' '--- vite-plugin-image-optimizer package metadata ---'
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/1.1.7 \
| jq -r '.dist.tarball, .dist.integrity'
tarball="$tmpdir/plugin.tgz"
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tarball"
mkdir "$tmpdir/package"
tar -xzf "$tarball" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- package files ---'
find "$tmpdir/package" -maxdepth 3 -type f -print | sort
printf '%s\n' '--- plugin hook and asset handling ---'
rg -n -C 5 'generateBundle|writeBundle|load|transform|emitFile|asset|public|inline|sharp|squoosh' \
"$tmpdir/package" | head -260
printf '%s\n' '--- repository image sizes ---'
find public src/assets -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.webp' \) -print0 |
xargs -0 stat -c '%s %n' | sort -n
printf '%s\n' '--- JavaScript image imports ---'
rg -n -C 2 '(^|[^A-Za-z0-9_])import .* from ["'\''][^"'\'']+\.(png|jpe?g|webp)|(^|[^A-Za-z0-9_])import ["'\''][^"'\'']+\.(png|jpe?g|webp)' \
--glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' srcRepository: AURORALAOrg/aurora-frontend Length of output: 18046 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
printf '%s\n' '--- vite-plugin-image-optimizer package metadata ---'
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/1.1.7 |
jq -r '.dist.tarball, .dist.integrity'
tarball="$tmpdir/plugin.tgz"
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tarball"
mkdir "$tmpdir/package"
tar -xzf "$tarball" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- package files ---'
find "$tmpdir/package" -maxdepth 3 -type f -print | sort
printf '%s\n' '--- plugin hook and asset handling ---'
rg -n -C 5 'generateBundle|writeBundle|load|transform|emitFile|asset|public|inline|sharp|squoosh' \
"$tmpdir/package" | head -260
printf '%s\n' '--- repository image sizes ---'
find public src/assets -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.webp' \) -print0 |
xargs -0 stat -c '%s %n' | sort -n
printf '%s\n' '--- JavaScript image imports ---'
rg -n -C 2 '(^|[^A-Za-z0-9_])import .* from ["'\''][^"'\'']+\.(png|jpe?g|webp)|(^|[^A-Za-z0-9_])import ["'\''][^"'\'']+\.(png|jpe?g|webp)' \
--glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' srcRepository: AURORALAOrg/aurora-frontend Length of output: 18046 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tmpdir/plugin.tgz"
mkdir "$tmpdir/package"
tar -xzf "$tmpdir/plugin.tgz" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- plugin implementation outline ---'
wc -c "$tmpdir/package"/dist/index.*
sed -n '1,220p' "$tmpdir/package/dist/index.mjs"
printf '%s\n' '--- plugin hook names ---'
grep -oE 'name:|buildStart|configResolved|resolveId|load|transform|transformIndexHtml|generateBundle|writeBundle|closeBundle|publicDir|includePublic|emitFile' \
"$tmpdir/package/dist/index.mjs" | sort | uniq -c
printf '%s\n' '--- relevant README sections ---'
sed -n '83,115p' "$tmpdir/package/README.md"
sed -n '188,210p' "$tmpdir/package/README.md"
printf '%s\n' '--- image files and byte sizes ---'
find public src/assets -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.webp' \) -print |
while IFS= read -r f; do
bytes=$(wc -c < "$f")
printf '%s %s\n' "$bytes" "$f"
done | sort -nRepository: AURORALAOrg/aurora-frontend Length of output: 10243 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tmpdir/plugin.tgz"
mkdir "$tmpdir/package"
tar -xzf "$tmpdir/plugin.tgz" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- complete plugin lifecycle implementation ---'
nl -ba "$tmpdir/package/dist/index.mjs" | sed -n '120,290p'
printf '%s\n' '--- all source image imports and CSS image URLs ---'
rg -n -C 2 'import[^;\n]*\.(png|jpe?g|webp)|url\([^)]*\.(png|jpe?g|webp)|src/assets/.*\.(png|jpe?g|webp)' \
--glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' .
printf '%s\n' '--- all files under public and src/assets ---'
find public src/assets -type f -print | sortRepository: AURORALAOrg/aurora-frontend Length of output: 255 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tmpdir/plugin.tgz"
mkdir "$tmpdir/package"
tar -xzf "$tmpdir/plugin.tgz" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- complete plugin lifecycle implementation ---'
cat -n "$tmpdir/package/dist/index.mjs" | sed -n '120,300p'
printf '%s\n' '--- all source image imports and CSS image URLs ---'
rg -n -C 2 'import[^;\n]*\.(png|jpe?g|webp)|url\([^)]*\.(png|jpe?g|webp)|src/assets/.*\.(png|jpe?g|webp)' \
--glob '!node_modules/**' --glob '!dist/**' --glob '!*.lock' . || true
printf '%s\n' '--- all files under public and src/assets ---'
find public src/assets -type f -print | sortRepository: AURORALAOrg/aurora-frontend Length of output: 18904 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL https://registry.npmjs.org/vite-plugin-image-optimizer/-/vite-plugin-image-optimizer-1.1.7.tgz \
-o "$tmpdir/plugin.tgz"
mkdir "$tmpdir/package"
tar -xzf "$tmpdir/plugin.tgz" -C "$tmpdir/package" --strip-components=1
printf '%s\n' '--- optimizer peer dependencies ---'
cat "$tmpdir/package/package.json" | jq '{dependencies, peerDependencies, peerDependenciesMeta, optionalDependencies}'
printf '%s\n' '--- project optimizer dependencies ---'
rg -n -C 2 '"(sharp|svgo)"|^(sharp|svgo)@' package.json yarn.lock || true
printf '%s\n' '--- public processing implementation ---'
cat -n "$tmpdir/package/dist/index.mjs" | sed -n '290,355p'Repository: AURORALAOrg/aurora-frontend Length of output: 2298 Add 🤖 Prompt for AI AgentsSource: MCP tools |
||
| resolve: { | ||
| alias: { | ||
| "@": fileURLToPath(new URL("./src", import.meta.url)), | ||
| }, | ||
| }, | ||
| build: { | ||
| rollupOptions: { | ||
| output: { | ||
| assetFileNames: 'assets/[name].[hash].[ext]', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
rg -n -C 6 \
'generateBundle|bundler\[filePath\]\.source' \
node_modules/vite-plugin-image-optimizerRepository: AURORALAOrg/aurora-frontend Length of output: 318 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- tracked candidate files ---'
git ls-files | rg '(^|/)(vite\.config\.js|package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml)$'
printf '%s\n' '--- Vite configuration ---'
vite_cfg="$(git ls-files | rg '(^|/)vite\.config\.js$' | head -n 1)"
if [ -n "$vite_cfg" ]; then
cat -n "$vite_cfg"
fi
printf '%s\n' '--- dependency declarations and lockfile references ---'
rg -n -C 4 'vite-plugin-image-optimizer|imageOptimizer|vite|rollup' \
package.json package-lock.json npm-shrinkwrap.json yarn.lock pnpm-lock.yaml 2>/dev/null || true
printf '%s\n' '--- plugin references in tracked source ---'
rg -n -C 5 'ViteImageOptimizer|vite-plugin-image-optimizer|imageOptimizer' . \
-g '!node_modules' -g '!dist' -g '!build' 2>/dev/null || trueRepository: AURORALAOrg/aurora-frontend Length of output: 9271 🌐 Web query:
💡 Result: In the context of Citations:
🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
import json
import urllib.request
urls = [
"https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/src/index.ts",
"https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/package.json",
]
for url in urls:
print(f"--- {url} ---")
try:
with urllib.request.urlopen(url, timeout=15) as response:
print(response.read().decode())
except Exception as exc:
print(f"ERROR: {exc}")
PYRepository: AURORALAOrg/aurora-frontend Length of output: 645 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
fetch() {
printf '%s\n' "--- $1 ---"
curl -fsSLk --max-time 20 "$1"
printf '\n'
}
fetch 'https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/src/index.ts'
fetch 'https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/package.json'
fetch 'https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/OutputBundle.ts'
fetch 'https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/Chunk.ts'Repository: AURORALAOrg/aurora-frontend Length of output: 11290 🏁 Script executed: #!/usr/bin/env bash
set -u
for path in src/Bundle.ts src/Chunk.ts src/OutputAsset.ts src/OutputBundle.ts src/utils/FileEmitter.ts src/utils/RenderedSource.ts; do
url="https://raw.githubusercontent.com/rollup/rollup/v4.46.2/$path"
printf '%s\n' "--- $path ---"
curl -fsSLk --max-time 20 "$url" 2>/dev/null || printf '%s\n' '(not found)'
done
printf '%s\n' '--- Rollup v4.46.2 source references for assetFileNames and hash resolution ---'
curl -fsSLk --max-time 30 \
'https://api.github.com/repos/rollup/rollup/git/trees/v4.46.2?recursive=1' 2>/dev/null |
jq -r '.tree[]?.path' |
rg 'asset|fileName|hash|generateBundle' |
head -n 120Repository: AURORALAOrg/aurora-frontend Length of output: 50383 🏁 Script executed: #!/usr/bin/env bash
set -u
show_matches() {
path="$1"
printf '%s\n' "--- $path ---"
curl -fsSLk --max-time 20 \
"https://raw.githubusercontent.com/rollup/rollup/v4.46.2/$path" 2>/dev/null |
rg -n -C 8 'finaliseAssets|hashPlaceholders|placeholder|assetFileNames|emitFile|source|generateBundle|renderChunks' |
head -n 260 || true
}
show_matches src/utils/outputBundle.ts
show_matches src/utils/PluginDriver.ts
show_matches src/utils/FileEmitter.ts
show_matches src/utils/hashPlaceholders.ts
show_matches src/utils/renderChunks.tsRepository: AURORALAOrg/aurora-frontend Length of output: 22238 🏁 Script executed: #!/usr/bin/env bash
set -u
printf '%s\n' '--- Rollup FileEmitter asset finalization ---'
curl -fsSLk --max-time 20 \
'https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/utils/FileEmitter.ts' 2>/dev/null |
sed -n '285,570p'
printf '%s\n' '--- Rollup renderChunks asset-related calls ---'
curl -fsSLk --max-time 20 \
'https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/utils/renderChunks.ts' 2>/dev/null |
rg -n -C 12 'finalizeAssets|setAssetSource|emitFile|asset|bundle\[|sourceHash' |
head -n 320Repository: AURORALAOrg/aurora-frontend Length of output: 12922 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
import pathlib
import subprocess
def fetch(url):
return subprocess.check_output(
["curl", "-fsSLk", "--max-time", "20", url],
text=True,
)
vite = pathlib.Path("vite.config.js").read_text()
assert "assetFileNames: 'assets/[name].[hash].[ext]'" in vite
assert "ViteImageOptimizer({" in vite
plugin = fetch(
"https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/src/index.ts"
)
assert "generateBundle: async (_, bundler)" in plugin
assert "const source = (bundler[filePath] as any).source;" in plugin
assert "(bundler[filePath] as any).source = content;" in plugin
bundle = fetch(
"https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/Bundle.ts"
)
assert bundle.index("hookSeq('generateBundle'") < bundle.index("this.finaliseAssets(outputBundle)")
emitter = fetch(
"https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/utils/FileEmitter.ts"
)
assert "const sourceHash = getHash(consumedFile.source);" in emitter
assert "generateAssetFileName(" in emitter
assert emitter.index("sourceHash = getHash(consumedFile.source)") < emitter.index(
"generateAssetFileName("
)
print("config uses a content hash in assetFileNames")
print("plugin v1.1.7 mutates emitted asset source in generateBundle")
print("Rollup hashes source and assigns the asset filename before generateBundle")
print("Rollup finalises assets after generateBundle")
PYRepository: AURORALAOrg/aurora-frontend Length of output: 254 🏁 Script executed: #!/usr/bin/env bash
set -u
python3 - <<'PY'
import pathlib
import subprocess
def fetch(url):
return subprocess.check_output(
["curl", "-fsSLk", "--max-time", "20", url],
text=True,
)
def check(label, condition):
print(f"{label}: {'PASS' if condition else 'FAIL'}")
return condition
vite = pathlib.Path("vite.config.js").read_text()
plugin = fetch("https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/src/index.ts")
bundle = fetch("https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/Bundle.ts")
emitter = fetch("https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/utils/FileEmitter.ts")
checks = [
("config hash pattern", "assetFileNames: 'assets/[name].[hash].[ext]'" in vite),
("optimizer configured", "ViteImageOptimizer({" in vite),
("plugin generateBundle hook", "generateBundle: async (_, bundler)" in plugin),
("plugin reads emitted source", "const source = (bundler[filePath] as any).source;" in plugin),
("plugin mutates emitted source", "(bundler[filePath] as any).source = content;" in plugin),
("generateBundle precedes finaliseAssets",
bundle.index("hookSeq('generateBundle'") < bundle.index("this.finaliseAssets(outputBundle)")),
("asset hash is computed in setOutputBundle",
emitter.index("const sourceHash = getHash(consumedFile.source);",
emitter.index("public setOutputBundle")) != -1),
("asset filename uses sourceHash",
emitter.index("sourceHash, outputOptions", emitter.index("function generateAssetFileName")) != -1),
]
for label, passed in checks:
check(label, passed)
if not all(passed for _, passed in checks):
raise SystemExit(1)
PYRepository: AURORALAOrg/aurora-frontend Length of output: 271 🏁 Script executed: #!/usr/bin/env bash
set -u
python3 - <<'PY'
import pathlib
import re
import subprocess
def fetch(url):
return subprocess.check_output(
["curl", "-fsSLk", "--max-time", "20", url],
text=True,
)
def check(label, condition):
print(f"{label}: {'PASS' if condition else 'FAIL'}")
return condition
vite = pathlib.Path("vite.config.js").read_text()
plugin = fetch("https://raw.githubusercontent.com/FatehAK/vite-plugin-image-optimizer/v1.1.7/src/index.ts")
bundle = fetch("https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/Bundle.ts")
emitter = fetch("https://raw.githubusercontent.com/rollup/rollup/v4.46.2/src/utils/FileEmitter.ts")
set_output_bundle = emitter[
emitter.index("public setOutputBundle"):
emitter.index("private addOutputFileEmitter")
]
asset_name_function = emitter[
emitter.index("function generateAssetFileName"):
emitter.index("function getAssetFileName")
]
checks = [
("config hash pattern", "assetFileNames: 'assets/[name].[hash].[ext]'" in vite),
("optimizer configured", "ViteImageOptimizer({" in vite),
("plugin generateBundle hook", "generateBundle: async (_, bundler)" in plugin),
("plugin reads emitted source", "const source = (bundler[filePath] as any).source;" in plugin),
("plugin mutates emitted source", "(bundler[filePath] as any).source = content;" in plugin),
("generateBundle precedes finaliseAssets",
bundle.index("hookSeq('generateBundle'") < bundle.index("this.finaliseAssets(outputBundle)")),
("asset hash is computed before asset naming",
set_output_bundle.index("const sourceHash = getHash(consumedFile.source);") <
set_output_bundle.index("this.finalizeAssetsWithSameSource")),
("asset filename hash uses sourceHash",
bool(re.search(r"hash: size\s*=>\s*sourceHash\.slice", asset_name_function))),
]
passed = [check(label, condition) for label, condition in checks]
if not all(passed):
print("--- relevant Rollup asset naming excerpt ---")
print("\n".join(asset_name_function.splitlines()[35:55]))
raise SystemExit(1)
PYRepository: AURORALAOrg/aurora-frontend Length of output: 457 Recompute asset hashes after image optimization.
Use an optimizer that runs before asset naming, or add a post-build hash and reference-rewrite step. Test that changing only optimizer quality changes both the optimized bytes and the asset URL hash. 🤖 Prompt for AI AgentsSource: MCP tools |
||
| chunkFileNames: 'assets/[name].[hash].js', | ||
| entryFileNames: 'assets/[name].[hash].js', | ||
| manualChunks(id) { | ||
| if (id.includes('node_modules')) { | ||
| return 'vendor'; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: AURORALAOrg/aurora-frontend
Length of output: 165
🏁 Script executed:
Repository: AURORALAOrg/aurora-frontend
Length of output: 5079
🌐 Web query:
vite-plugin-image-optimizer 1.1.7 sharp svgo peerDependencies dynamic import README💡 Result:
In version 1.1.7 of vite-plugin-image-optimizer, released on August 12, 2023, the plugin introduced a significant architectural change regarding its dependencies, sharp and svgo [1][2][3]. Key details include: Dynamic Imports: To support both CommonJS and ES module environments (such as vite.config.mjs), version 1.1.7 implemented dynamic imports for sharp and svgo [2][4]. This allows these heavy dependencies to be loaded on-demand rather than synchronously at startup [2]. Peer Dependencies: Because sharp and svgo are handled via dynamic imports, they are marked as optional peer dependencies [5][2]. This design decision enables users to install only the libraries they need—for example, skipping sharp if they only require SVGO, or vice versa [6]. Documentation and Requirements: The README emphasizes that sharp and svgo are not bundled with the plugin [6][7]. Users must install them manually as dev dependencies in their own projects [6][7]. For version 1.1.7, while explicit peer dependency ranges were defined in the package metadata, the core requirement is that these packages must be present in the user's environment for the corresponding features to function [2][6]. By treating these libraries as optional peer dependencies, the plugin avoids forcing unnecessary heavy dependencies on users who may not need the full suite of optimization features [6].
Citations:
🏁 Script executed:
Repository: AURORALAOrg/aurora-frontend
Length of output: 1343
🏁 Script executed:
Repository: AURORALAOrg/aurora-frontend
Length of output: 12839
🏁 Script executed:
Repository: AURORALAOrg/aurora-frontend
Length of output: 5255
Declare the image optimizer engines.
Add compatible
sharpandsvgodevelopment dependencies and updateyarn.lock. The default matcher processes the repository’s raster assets and SVG files, but neither engine is declared.🤖 Prompt for AI Agents
Source: MCP tools