0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/app/helpers
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
..
application_helper.rb DEV: Let cross-plugin imports opt into being required via with { discoursePlugin: "required" } 2026-06-23 10:44:16 +00:00
common_helper.rb FIX: Skip third-party analytics tags in full app embed iframes (#39534) 2026-04-24 14:58:45 -03:00
email_helper.rb UX: add preview to email templates (#36657) 2026-01-08 11:33:53 +04:00
embed_helper.rb DEV: Enable Style/RedundantParentheses rubocop rule (#40095) 2026-05-19 15:48:09 +02:00
emoji_helper.rb
list_helper.rb
posts_helper.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
qunit_helper.rb DEV: Ensure activatedThemes key is always available in tests (#40675) 2026-06-09 10:56:51 +01:00
topic_post_bookmarkable_helper.rb DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
topics_helper.rb FEATURE: A dedicated 'show original' user preferences saved to user options (#39128) 2026-04-07 21:37:20 +08:00
user_notifications_helper.rb DEV: Refactors digest/summary email into partials (#33451) 2025-07-07 09:57:15 -05:00