mirror of
https://github.com/discourse/discourse.git
synced 2026-03-04 01:15:08 +08:00
This commit introduces a new build system for plugins, which shares a large amount of code with the recently-modernized theme compiler. Plugins are compiled to native ES Modules, and loaded using native `import()` in the browser, just like themes. To achieve inter-plugin imports, each bundled plugin entrypoint implements a custom 'module federation' interface. Each export from internal plugin modules is made available as a specially-named export on the entrypoint. When modules in another plugin's namespace are imported, they are automatically rewritten to use these federated entrypoints. This change should be almost 100% backwards-compatible. There are some edge cases which will behave differently, since modules are now eagerly evaluated according to the ESM spec, instead of being lazily required via asynchronous-module-definitions (AMD). The native ESM format should also provide a performance improvement. The old AMD system involved lots of nested function calls when booting the app. Now, all the source modules are bundled up into a single ESM bundle with minimal stack depth. The build system implements a filesystem-based cache. That means that if the plugin javascript files are unchanged, they will not need to be recompiled, even after restarting the Rails server. This mimics the behaviour of the theme system. Similarly, in production builds, existing files will be automatically reused if they exist. In future, we plan to include pre-built copies of common plugins in our prebuild-asset bundles. Initially, this new compiler is disabled by default. To test it, we can set the `ROLLUP_PLUGIN_COMPILER=1` environment variable. We'll continue to test, improve and document the system before enabling it by default. --------- Co-authored-by: Jarek Radosz <jradosz@gmail.com> Co-authored-by: Chris Manson <chris@manson.ie> |
||
|---|---|---|
| .. | ||
| colocated-template-compiler.js | ||
| index.js | ||
| package.json | ||
| transform-action-syntax.js | ||