Skip to content

Cleanup unused dependencies and src files - #1986

Closed
marcleblanc2 wants to merge 2 commits into
mainfrom
marc/cleanup/dead-src-code
Closed

marcleblanc2 wants to merge 2 commits into
mainfrom
marc/cleanup/dead-src-code

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Two independent cleanups, each its own commit.

Delete src/ files with no importers

Found by grepping for import specifiers of every file under src/:

  • src/components/PreCode.tsx: empty file; the real PreCode is exported from PreCodeBlock.tsx
  • src/components/ResourceEstimator.tsx: older duplicate; MdxComponents.tsx imports resource-estimator/ResourceEstimator.tsx
  • src/components/DemoLayout.tsx: template leftover (YouTube tabs for "Text-to-Image", "Text-to-Speech", ...)
  • src/components/TopBanner.tsx, src/components/icons/Globe.tsx, src/components/icons/BugIcon.tsx

allCoreContent in src/utils/contentlayer.ts filtered on a draft frontmatter field that contentlayer.config.ts does not declare and that no .mdx file sets, so its production and development branches were equivalent. Collapsed to one.

Remove dependencies nothing imports and stale RSS .gitignore entries

pnpm remove of every package in package.json with no import in src/, dev/, or any config file:

@docsearch/react (only its CSS is vendored in src/components/search/docsearch/), @mdx-js/mdx, date-fns, fast-glob, feed, prism-react-renderer, react-highlight-words + @types/react-highlight-words, react-syntax-highlighter, rehype-toc, simple-functional-loader, dotenv.

Kept on purpose: shiki (peer dependency of rehype-pretty-code) and sharp (Next.js image optimization).

Also drops the .gitignore entries for public/changelog.rss and public/technical-changelog.rss. Nothing generates them any more: the feed comes from sourcegraph.com (src/data/constants.ts) and src/proxy.ts redirects the old paths to it.

Verification

  • pnpm install --frozen-lockfile, npx tsc --noEmit, pnpm run lint (0 errors) on the combined branch
  • pnpm run build exit 0 and pnpm start serving /, /cody/quickstart, /api/versions with 200, on each change separately before they were combined
  • Vercel preview deployment on this PR

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 17, 2026 5:28pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

@marcleblanc2 marcleblanc2 mentioned this pull request Sep 17, 2026
@marcleblanc2 marcleblanc2 changed the title Remove components nothing imports and the unused draft filter Remove unused imports Sep 17, 2026
@marcleblanc2
marcleblanc2 marked this pull request as ready for review September 17, 2026 03:37
@marcleblanc2
marcleblanc2 enabled auto-merge (squash) September 17, 2026 03:37
@marcleblanc2 marcleblanc2 changed the title Remove unused imports build: Remove unused imports Sep 17, 2026
@marcleblanc2 marcleblanc2 changed the title build: Remove unused imports Remove unused src files, dependencies, and stale .gitignore entries Sep 17, 2026
@github-actions

This comment has been minimized.

@marcleblanc2 marcleblanc2 changed the title Remove unused src files, dependencies, and stale .gitignore entries Cleanup unused dependencies and src files Sep 17, 2026
@marcleblanc2
marcleblanc2 force-pushed the marc/cleanup/dead-src-code branch 2 times, most recently from cd1dfe4 to ee82523 Compare September 17, 2026 10:10
marcleblanc2 and others added 2 commits September 17, 2026 11:25
PreCode.tsx was empty; ResourceEstimator.tsx was an older copy of
resource-estimator/ResourceEstimator.tsx, which MdxComponents imports;
DemoLayout, TopBanner, Globe and BugIcon have no importers.

allCoreContent filtered on a `draft` frontmatter field that
contentlayer.config.ts does not declare and no page sets, so the
production and development branches did the same thing.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad56-bd79-73ce-bc8e-a5405d0c11f2
Co-authored-by: Amp <amp@ampcode.com>
None of these packages are imported by src/, dev/, or any config file:
@docsearch/react (only its CSS is vendored), @mdx-js/mdx, date-fns,
fast-glob, feed, prism-react-renderer, react-highlight-words and its
@types, react-syntax-highlighter, rehype-toc, simple-functional-loader,
dotenv.

public/changelog.rss and public/technical-changelog.rss are no longer
generated here: the feed is served from sourcegraph.com (see
src/data/constants.ts) and src/proxy.ts redirects to it.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad56-bd79-73ce-bc8e-a5405d0c11f2
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2

Copy link
Copy Markdown
Contributor Author

Folded into #1997: the two collided on package.json, pnpm-lock.yaml, .gitignore, and src/utils/contentlayer.ts (which #1997 deletes), so one PR is easier to review and merge.

auto-merge was automatically disabled September 18, 2026 05:10

Pull request was closed

@marcleblanc2
marcleblanc2 deleted the marc/cleanup/dead-src-code branch September 18, 2026 05:10
marcleblanc2 added a commit that referenced this pull request Sep 23, 2026
## Problem

- kbar (a ⌘K palette) was removed in #110, but its config in
`src/data/search.ts` and the contentlayer `onSuccess` hook stayed
behind, writing a 725 KB `public/search.json` on every build that
nothing fetches
- `src/utils/contentlayer.ts` only existed to build that index
- The `video` entry in `MdxComponents.tsx` never runs: MDX compiles an
explicit `<video>` to a literal element, so `components.video` is never
consulted (the `rounded-xl` class it set has never been applied)
- A knip scan turned up more dead code nothing imports:
- `docsearch/icons/index.ts` barrel and the `AlgoliaLogo`,
`NoResultsIcon`, `ControlKeyIcon`, `GoToExternalIcon` icons only it
re-exported (plus two commented-out usages and the `searchByText`
translation that only fed `AlgoliaLogo`)
- `docsearch/types/useDocSearchKeyboardEvents.ts`, a drifted copy of the
sibling hook `DocSearch.tsx` actually imports
- `src/images/logos/aws/index.ts`, generator output from before
`dev/generate-mermaid-icons.mjs` switched to `icons.generated.ts`
- `latestVersion` in `src/data/versions.ts`, exported since #48 with no
reader
- Dependencies `@iconify-json/logos`, `@iconify/types`, and `mdx` (not
MDX: a 2013 "generic documentation extractor", likely a typo-install of
`@mdx-js/mdx`)
- Absorbed from #1986 (closed in favour of this PR; the two collided on
`package.json`, the lockfile, `.gitignore`, and
`src/utils/contentlayer.ts`):
- `src/components/PreCode.tsx` (empty; the real `PreCode` lives in
`PreCodeBlock.tsx`), `src/components/ResourceEstimator.tsx` (older
duplicate of `resource-estimator/ResourceEstimator.tsx`),
`src/components/DemoLayout.tsx` (template leftover),
`src/components/TopBanner.tsx`, `src/components/icons/Globe.tsx`,
`src/components/icons/BugIcon.tsx`
- Dependencies with no import in `src/`, `dev/`, or any config:
`@docsearch/react` (only its CSS is vendored under
`src/components/search/docsearch/`), `@mdx-js/mdx` (contentlayer2 pulls
the same 3.1.1 transitively), `date-fns`, `fast-glob`, `feed`,
`prism-react-renderer`, `react-highlight-words` +
`@types/react-highlight-words`, `react-syntax-highlighter`,
`rehype-toc`, `simple-functional-loader`, `dotenv`. Kept on purpose:
`shiki` (peer of `rehype-pretty-code`) and `sharp`
- `.gitignore` entries for `public/changelog.rss` and
`public/technical-changelog.rss`: nothing generates them; the feed comes
from sourcegraph.com and `src/proxy.ts` redirects the old paths

## Change

Five commits, one per group above. 15 files deleted, 15 dependencies
removed, +1 −1585 (880 of that lockfile).

Independent of #1977 (only shared line was the `searchDocumentsPath`
comment in `src/data/search.ts`, gone here); whichever merges second
gets a one-line rebase.

## Verification

- `pnpm install --frozen-lockfile`, `npx tsc --noEmit` clean, `pnpm run
lint` at the 8-warning baseline, `pnpm run build` passes and no longer
produces `public/search.json`
- `rg -i 'kbar|search\.json'` finds nothing; `rg` finds no imports of
any deleted file, export, or dependency
- Rendered `<video>` markup on `/docs/code-monitoring` is byte-identical
before and after (it never had the class)
- Nobody fetches `search.json`: the new Algolia indexer (#2009) reads
`.contentlayer/generated/Post`, the old DocSearch crawler scraped HTML,
and Cloudflare analytics for `sourcegraph.com` show ~150 sampled
requests to `/docs/search.json` in the last 30 days, all with an empty
referer, random geos and browser UAs, and no daily cadence: scanner
noise, not a consumer

---------

Co-authored-by: Amp <amp@ampcode.com>

This branch was successfully deployed

1 active deployment
Preview 9d2f1472 Deployed Sep 17, 2026 by vercel[bot]
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.

1 participant