Skip to content

feat(legacy): inline yari#852

Open
caugner wants to merge 59 commits into
mainfrom
vendor-yari
Open

feat(legacy): inline yari#852
caugner wants to merge 59 commits into
mainfrom
vendor-yari

Conversation

@caugner

@caugner caugner commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

Description

Inlines all parts of yari required for MDN Plus.

Motivation

We want to archive the mdn/yari repository.

Additional details

Preview:

Related issues and pull requests

Part of #848.

@caugner caugner requested a review from mdn-bot as a code owner October 2, 2025 10:16
@caugner caugner requested a review from a team October 2, 2025 10:16
@caugner caugner marked this pull request as draft October 2, 2025 10:16

@github-advanced-security github-advanced-security AI 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.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Comment thread legacy/index.tsx
@github-actions

github-actions Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

6cce294 was deployed to: https://fred-pr852.review.mdn.allizom.net/

caugner added 20 commits April 28, 2026 22:04
…font

Fred already declares @font-face for Inter in components/font/inter.css.
BarlowCondensed-SemiBold.woff2 is only used by fred's scrim-inline (which
ships its own copy).
17 SVGs had no className/import/url() reference anywhere; remove the
files and the corresponding entries from the $icons map.
Plus updates renders one icon per BCD browser via browserToIconName().
Restore chrome, edge, opera, samsunginternet — covers chrome_android,
opera_android, samsunginternet_android via the split("_")[0] fallback.
No references in code or styles after the curriculum subtree was removed.
RenderSideBar (and its SidebarLeaf/SidebarLeaflets internals) had no
caller; only SidebarContainer is imported (by static-page).
Plus's only consumer (StaticPage) never sets sidebarHTML, sidebarMacro,
or related_content. Drop the inert SidebarFilter, data-macro attribute,
and the dangerouslySetInnerHTML-driven scroll-to-current effect. Delete
the now-orphaned filter.tsx, filter.scss, and SidebarFilterer.ts.
After removing the sidebar filter UI, handleSidebarClick only ever fires
with macro=\"?\" and never with a filter value. Drop the hook from
glean-context, delete sidebar-click.ts, and remove the four orphaned
SIDEBAR_* constants.
Convert via synp, which preserves the resolved versions from yarn.lock
exactly. libs/play already used npm.
Drop the yarn-specific install:all script and packageManager pin in
vendor/yari, and switch fred's root prepare hook to \`npm ci\`. The
vendor/yari prepare now chains \`npm ci\` across each nested
package-lock.json.
Declare libs/* and client/pwa as workspaces of vendor/yari and drop the
install:all/prepare scripts — \`npm ci\` now installs everything in one
shot. Nested package-lock.json files collapse into a single root lockfile;
node_modules hoist except where versions conflict (dexie pins 4.0.11 in
client/pwa vs ^4.2.0 at the root).
Matches the root and lets npm hoist a single dexie copy.
The --allow-empty-input and --ignore-path .stylelintignore additions
weren't needed: vendor/yari has no .css files (only .scss), so the
**/*.css glob never picks anything up, and the per-file glob already
filters staged files.
vendor/yari has no .css files, only .scss — stylelint's **/*.css glob
never picks them up, so excluding vendor/ is unnecessary.
downshift had no callers in fred, components, hooks, or vendor/yari —
it was the sole transitive source of React 19 in fred's tree. With it
gone, vendor/yari's React 18 is the only React, so the legacy bundle's
\`react\` resolve alias is no longer needed.
Drop the obsolete \`packageManager: yarn\` quirk; correct the PWA
pre-cache description (path is /static/legacy/asset-manifest.json,
shape is string[]); update the install/usage section to reflect the
single-lockfile workspace setup.
These are the Glean schema source files; the committed generated/*.ts
were produced from them by glean-parser. Even though we don't currently
regenerate, keeping the yaml as the source of truth for what telemetry
we collect.
Comment thread rspack.config.js
Comment on lines -458 to -470
new rspack.HtmlRspackPlugin({
inject: true,
chunks: ["yari"],
filename: "index.[contenthash].html",
template: "node_modules/@mdn/yari/client/public/index.html",
}),
new RspackManifestPlugin({
fileName: "asset-manifest.json",
generate: (_seed, files) =>
files
.map((file) => file.path)
.filter((path) => !path.endsWith(".map")),
}),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@LeoMcA Do you remember what these were for?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are needed for offline mode to work:

const files: string[] =
(await (
await fetch("/static/legacy/asset-manifest.json", {
cache: "no-cache",
})
).json()) || [];

@caugner caugner marked this pull request as ready for review April 30, 2026 14:50
@caugner caugner requested a review from a team as a code owner April 30, 2026 14:50
@caugner caugner requested a review from LeoMcA April 30, 2026 14:50

@LeoMcA LeoMcA left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, should've thought a bit more about this before beginning to review (or even encouraging you to do it!) - we need pretty much all of yari to render offline mode.

We could put everything back, but - even though it's a bit of a silly reason - I'm not sure I want to clutter up the git tree like that, especially with stuff we won't be wanting to edit.

Perhaps we should keep using the npm yari for now to render offline? That has the added advantage that we won't accidentally break something being used for that, and allows us to modify/slim/convert as much of the vendored code as we want.

Longer term it would be fun to get fred's server components running in-browser, and I have some ideas how to achieve that - so it doesn't have to be this way forever.

Comment thread package.json
"@zip.js/zip.js": "^2.8.26",
"css-loader": "^7.1.4",
"css-minimizer-webpack-plugin": "^8.0.0",
"dexie": "^4.4.2",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can also drop dexie

Comment thread package.json
"postcss-preset-env": "^11.2.1",
"prettier": "^3.8.3",
"resolve-url-loader": "^5.0.0",
"rspack-manifest-plugin": "^5.2.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add it back for offline mode

Comment thread package.json
"@wdio/local-runner": "^9.27.0",
"@wdio/mocha-framework": "^9.27.0",
"@wdio/spec-reporter": "^9.27.0",
"@zip.js/zip.js": "^2.8.26",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can drop this too

Comment thread vendor/yari/README.md
- **`client/src/`** — React/Lit source for the legacy bundle. Fred's [`legacy/index.tsx`](../../legacy/index.tsx) renders `<Plus />` from this tree. Subset kept: `plus/`, `ui/`, `document/`, `lit/`, `playground/`, `settings/`, `telemetry/`, `homepage/static-page/` (used by Plus docs), plus shared providers (`user-context.tsx`, `ui-context.tsx`, `placement-context.tsx`) and utilities. Yari's full SPA router and the homepage/blog/community/curriculum/observatory/etc. routes have all been removed.
- **`client/pwa/src/`** — service worker source, used by the rspack `service-worker` entry in [rspack.config.js](../../rspack.config.js). Note: the offline pre-cache install handler currently no-ops because it expects a manifest format and path that fred doesn't emit. Fixing that would require additional work (see "Known limitations" below).
- **`client/public/assets/`** — illustration/icon SVGs and PNGs referenced by Plus React components.
- **`libs/play/`** — playground runner used at runtime by fred's [server.js](../../server.js) (`handleRunner`). Not bundled by rspack.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth pointing out this was pre-existing (and we should come up with a better solution now it's in dex!)

Comment thread rspack.config.js
name: "legacy",
entry: {
index: "./legacy/index.tsx",
yari: "./node_modules/@mdn/yari/client/src/index.tsx",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah yeah, no: this is a problem - we need this file (which has been cleaned up from the vendored code) in order to render the offline JSONs we get from the differy zip.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So if the differy zip would contain HTML files, would that solve our issues?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, though I reckon it would be quite large, and prone to frequent re-downloads (every dependency update would change some aspect of each page). We would perhaps also have to bundle the static assets in (HTML/CSS): we could cache them directly from the site itself, but they could diverge from the ones used in the differy build.

My gut says getting fred server components to run in browser would be easier (and quite interesting!)

Easiest would just be restoring this line and continuing to build the "offline yari" from npm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Easiest would just be restoring this line and continuing to build the "offline yari" from npm.

The benefit is very small if we still keep @mdn/yari as a dependency, unless it moves to devDependencies?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah we could put it in dev or optional

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My gut says getting fred server components to run in browser would be easier (and quite interesting!)

Very unrefined, but here's my <1hr hacked together attempt at rendering fred server components in the browser - it works! #1546

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.

4 participants