mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
Previously, lib/pretty_text.rb assembled the mini_racer context by transpiling and loading ~50 JS modules one-by-one at boot, with hand-written shims for their dependencies. This replaces that with a single Rolldown-built IIFE bundle, precompiled during assets:precompile and cached on disk under a digest of its inputs (via the new PrecompiledBundle, which AssetProcessor now shares). The set of discourse-core modules allowed into the server bundle is defined once, as PrettyText::BUNDLED_DISCOURSE_MODULES. It is passed to build.mjs (where a resolver plugin fails the build for anything outside the list, since the discourse package's exports map would otherwise silently resolve it) and also derives the cache-digest globs, so list changes force a rebuild and upstream renames fail the precompile loudly. The require() surface available to plugins' server-side markdown modules is preserved: the bundle re-registers the same loader modules the old context provided, including the vendored-dependency shims (markdown-it, xss, @embroider/macros, discourse/lib/loader-shim, etc.). The whole Ruby -> JS interface now goes through mini_racer's `call` on a single `__PrettyText` object, passing options as structured arguments, rather than building JS source strings for `eval` on every invocation. |
||
|---|---|---|
| .. | ||
| helpers.rb | ||