DEV: Add support for `api-initializers` to reduce boilerplate. (PR #10670)

You can now create a file in your plugin/theme in the api-initializers directory which has a simpler template than previous initializers. Example:

// api-initializers/my-plugin.js
import { apiInitializer } from "discourse/lib/plugin-api";

export default apiInitializer("0.8", api => {
  console.log("hello world from api initializer!");


Since there is no meaningful name used in an apiInitializer, will debugging errors in the console be more painful for customers when themes break?

Iā€™m pretty sure that name is never displayed anywhere. The stack trace will be to the actual module where the code lives.

1 Like