0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/frontend
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
..
asset-processor DEV: Let cross-plugin imports opt into being required via with { discoursePlugin: "required" } 2026-06-23 10:44:16 +00:00
deprecation-silencer DEV: Remove (again) the old non-rollup plugin compiler (#39419) 2026-04-21 21:07:46 +02:00
discourse Revert "DEV: Add after-header outlet to new dashboard (#40956)" (#40957) 2026-06-16 16:41:19 -05:00
discourse-i18n DEPS: Bump the embroider group across 1 directory with 4 updates (#40856) 2026-06-16 14:57:02 +02:00
discourse-markdown-it DEPS: Bump the embroider group across 1 directory with 4 updates (#40856) 2026-06-16 14:57:02 +02:00
discourse-types DEPS: Bump @types/node from 25.0.10 to 25.3.3 in the types group (#38391) 2026-03-10 11:12:22 +01:00
pretty-text DEV: Replace JS build system with Rolldown (#35963) 2026-05-29 11:11:55 +01:00
.npmrc
polyfills.js