Ana içeriğe geç

Updating For 1.x

tip

If you need help applying these changes or using new features, please start a discussion on the community forum or Discord chat.

1.2 Changes

Flarum v1.2 included quite a few bugfixes, internal refactors, and new features. The following recaps the most important changes for extension developers:

Frontend

  • Flarum core now passes TypeScript type checking (on the portion written in TypeScript). Additionally, major portions of the frontend (models, the application instance, and others) are now written in TypeScript. These changes should make it much easier and more fruitful to write extensions in TypeScript.
  • Instead of directly using Less variables in CSS code, core now uses CSS variables. For the most part, we've just created CSS variables and set their values to the Less variables. This should make theming and customizing CSS a lot easier. https://github.com/flarum/core/pull/3146.
  • Dropdowns can now be lazy-drawn to improve performance. You can do this by setting the lazy draw attr to "true". https://github.com/flarum/core/pull/2925.
  • Textarea-type settings are now supported through the app.extensionData.registerSetting util.
  • You can now use Webpack 5 to bundle your extension's code. This will offer minor bundle size improvements.
  • A new flarum/common/components/ColorPreviewInput component has been added. It can be used directly, or through the color-preview type when registered via app.extensionData.registerSetting.
  • Extensions can now modify the minimum search length of the Search component.
  • The following components are now extensible:
  • Extensions now have finer control over positioning when adding elements to the DiscussionPage sidebar items: https://github.com/flarum/core/pull/3165

Backend

Misc

Tooling

  • The flarum-cli infra command can now be used to update or enable various infrastructure features. You can now add the following to your extension in just one command:
    • TypeScript
    • Prettier for JS/TS formatting
    • Backend testing with PHPUnit
    • Code formatting with StyleCI
    • EditorConfig support
    • GitHub actions for automating testing, linting, type checking, and building.
  • You can also exclude any files from these updates by adding their relative path to the "extra.flarum-cli" key's array in your extension's composer.json file. For example, if you wanted to exclude your tsconfig file from any updates by the infra system, the "extra.flarum-cli" key's value should be ["js/tsconfig.json"].
  • The flarum-cli audit infra can be used to check that all infra modules your extension uses are up to date. The --fix flag can be used to automatically fix any issues, which has essentially the same effect as running flarum-cli infra for each outdated module.
  • All flarum-cli commands can now be run with a --no-interaction flag to prevent prompts. Defaults will be used when possible, and errors will be thrown if a prompt is needed and there is no default.
  • Frontend GH actions now support type-checking, as well as type coverage reports.

1.1 Changes

Flarum version 1.1 mostly focuses on bugfixes and quality-of-life improvements following our stable release earlier this year. These are mainly user-facing and internal infrastructure changes, so extensions are not significantly affected.

Frontend

Backend

  • Flarum now comes with a Preload extender for preloading any custom frontend assets.
  • A new Theme extender now allows overriding Less files and internal imports. This allows themes to more easily completely replace Less modules.