0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-08 17:53:55 +08:00
discourse/app
David Taylor de4c1da901 DEV: Let cross-plugin imports opt into being required via with { discoursePlugin: "required" }
Cross-plugin imports (`discourse/plugins/<name>/...`) resolve to `null` when the target plugin isn't installed. That's the right default for soft dependencies, but it silently hides genuine hard dependencies. This adds a `discoursePlugin` import attribute so a bundle can opt a specific import into being required: `import X from "discourse/plugins/<name>/..." with { discoursePlugin: "required" }`. Omitting the attribute (or passing `discoursePlugin: "optional"`) keeps the existing optional behaviour.

`discourse-external-loader` inspects the attribute in `resolveId` and, for everything except `discoursePlugin: "required"`, tags the external id with an `?optional` marker, so the optionality travels through rollup's module graph (and therefore `chunk.imports`) without a side channel. `babel-resolve-plugin-imports` reads the marker back off the import source and consolidates each plugin import to `discourse/plugins/<name>?` (optional) or `discourse/plugins/<name>` (required), keeping the existing live-binding use-site rewrite that the cross-plugin import loops rely on.

The import map then resolves both specifiers. For a loaded plugin, `discourse/plugins/<name>?` is aliased to the plugin's real module (the required `discourse/plugins/<name>` already maps to it). For a missing plugin, `discourse/plugins/<name>?` points at a null-returning stub, and `discourse/plugins/<name>` points at a module that declares a default export (so the importer still links) and then throws on evaluation with a helpful message, surfacing the missing hard dependency at boot instead of a cryptic module-resolution error. Generation is pinned to `importAttributesKey: "with"` so rollup emits modern import-attribute syntax.

Spike scope: because optional is the default, the cross-plugin call sites the parent commit converted keep working unchanged, and only genuine hard dependencies need the new attribute. Ruby specs for the import-map behaviour and a full mini_racer build verification are still outstanding.
2026-06-23 10:44:16 +00:00
..
assets UX: add cancel + footernote (#40940) 2026-06-16 15:35:07 +02:00
controllers PERF: Cache user directory responses for anon users (#40946) 2026-06-16 18:16:11 +01:00
helpers DEV: Let cross-plugin imports opt into being required via with { discoursePlugin: "required" } 2026-06-23 10:44:16 +00:00
jobs FIX: Gate MessageBus groups when closing topic (#40913) 2026-06-15 15:27:07 -05:00
mailers FIX: allow custom email sender name via translation overrides (#40674) 2026-06-09 14:03:03 +04:00
models DEV: Improve cross-plugin/theme import handling 2026-06-16 23:51:05 +01:00
queries/reports FIX: Enforce can_see_ip checks across admin IP features (#40019) 2026-05-19 11:37:20 +08:00
serializers SECURITY: Hidden post link URLs leak through per-post link_counts (#40903) 2026-06-15 14:44:02 -05:00
services FIX: Properly scope admin-only browser pageview reports (#40942) 2026-06-16 09:44:53 -05:00
views DEV: Improve cross-plugin/theme import handling 2026-06-16 23:51:05 +01:00