Skip to content

Bundle audit: remove dead WASM deps, add analyzer, document composition#129

Merged
YurMil merged 2 commits into
mainfrom
perf/bundle-audit
Jul 20, 2026
Merged

Bundle audit: remove dead WASM deps, add analyzer, document composition#129
YurMil merged 2 commits into
mainfrom
perf/bundle-audit

Conversation

@YurMil

@YurMil YurMil commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Closes #99

Audit verdict

The micro-app migrations already did the heavy lifting: every page's critical path is 642 KB total (main 633 KB + runtime 9 KB), containing only framework pieces — react-dom, Docusaurus theme, prism highlighting, lunr offline search, and the en dictionary. No WASM, 3D, PDF, or editor library ships on the landing/docs render path.

All heavy libraries verified lazy, loading only where used:

Chunk Size Used by
rapier + three.js + r3f 3.0 MB Eco Sort game page
@mdx-js/mdx compiler 743 KB MDX post editor
jspdf 391 KB PDF-export tools
emoji-picker-react 262 KB comment editor
ru/ua/de/es/et dictionaries ~15 KB each language switch (only en is eager)

Supabase stays out of main thanks to the existing lazy client facade.

Changes

  • Removed replicad + replicad-opencascadejs — zero imports left in src/ (verified); ~15 MB lighter installs/CI (the OpenCascade WASM alone is ~11 MB in node_modules)
  • Removed the replicad-era webpack config (asyncWebAssembly, __filename mocks, fs/path/crypto fallbacks) — clean production build confirms nothing needed it
  • ANALYZE=1 npm run build now emits build/bundle-report.html for one-liner future audits
  • dev-plans/bundle-audit-2026-07.md — full findings and the 642 KB baseline to hold against regressions

Verification

  • pnpm typecheck, pnpm lint, full pnpm build — all green without the removed deps/config

🤖 Generated with Claude Code

… tooling

- replicad + replicad-opencascadejs had zero imports left after the
  micro-app migrations; removing them slims installs/CI by ~15 MB
- The asyncWebAssembly/node-mock webpack config existed only for them
- ANALYZE=1 npm run build now writes build/bundle-report.html
- dev-plans/bundle-audit-2026-07.md documents the full audit: 642 KB
  first-load on every page (framework only), all heavy libraries
  (rapier+three 3 MB, mdx 743 KB, jspdf 391 KB, emoji picker 262 KB,
  locale dictionaries) verified lazy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cadautoscript-com Ready Ready Preview, Comment Jul 20, 2026 7:58pm

@supabase

supabase Bot commented Jul 20, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project bkcimygtsnckzexbfqxh because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the dead dependencies replicad and replicad-opencascadejs along with their WebAssembly webpack configuration, and integrates webpack-bundle-analyzer to measure bundle sizes. Feedback on the changes suggests refining the ANALYZE environment variable check to prevent false positives and correcting the analyzer's output path to prevent the generated report from polluting the project root.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread docusaurus.config.ts
Comment on lines +60 to +69
// every WASM consumer now runs as a standalone utility app.
const analyzerPlugins =
process.env.ANALYZE && !isServer
? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: '../bundle-report.html',
openAnalyzer: false,
}),
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are two issues with the current webpack bundle analyzer configuration:

  1. Environment Variable Check: process.env.ANALYZE is a string. If a user runs the build with ANALYZE=false or ANALYZE=0, it will still evaluate to truthy in JavaScript, causing the analyzer to run unexpectedly. It is safer to explicitly check for 'true' or '1'.
  2. Report Filename Path: Docusaurus sets the webpack output.path to the build directory. Using ../bundle-report.html will write the report to the project root (one level above build), polluting the repository. Changing it to 'bundle-report.html' ensures it is written inside the build directory as documented in dev-plans/bundle-audit-2026-07.md.
Suggested change
// every WASM consumer now runs as a standalone utility app.
const analyzerPlugins =
process.env.ANALYZE && !isServer
? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: '../bundle-report.html',
openAnalyzer: false,
}),
]
const analyzerPlugins =
(process.env.ANALYZE === 'true' || process.env.ANALYZE === '1') && !isServer
? [
new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)({
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
openAnalyzer: false,
}),
]
: [];

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ce94f9018

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docusaurus.config.ts Outdated
const analyzerPlugins =
process.env.ANALYZE && !isServer
? [
new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace analyzer require to keep lint passing

When the root config is linted, this new require() makes the project's lint gate fail: pnpm exec eslint docusaurus.config.ts reports @typescript-eslint/no-require-imports here, and package.json's lint script includes *.ts. Any CI or pre-commit step running pnpm lint will now fail until this is changed to an import or the config is explicitly exempted.

Useful? React with 👍 / 👎.

@YurMil
YurMil merged commit afe1cf7 into main Jul 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit and reduce main bundle size; lazy-load heavy WASM/3D dependencies

1 participant