Register custom module in bokehjs 2x

In earlier versions of bokeh i could do something like this:

(function (root, factory) {
  factory(root["Bokeh"]);
})(this, function (Bokeh) {
  var define;
  return (function outer(modules, entry) {
    if (Bokeh != null) {
      return Bokeh.register_plugin(modules, entry);
    } else {
      throw new Error(
        "Cannot find Bokeh. You have to load it prior to loading plugins."
      );
    }
  })(
    {
      "custom/main": function (require, module, exports) {
        var models = {
          LineDrawTool: require("custom/line_draw_tool").LineDrawTool,
          DepthStepTickFormatter: require("custom/myproj.dashboard.tileprovider_minimal.depth_step_tick_formatter")
            .DepthStepTickFormatter,
          DepthStepTicker: require("custom/myproj.dashboard.tileprovider_minimal.depth_step_ticker")
            .DepthStepTicker,
          TimeStepTickFormatter: require("custom/myproj.dashboard.tileprovider_minimal.time_step_tick_formatter")
            .TimeStepTickFormatter,
          TimeStepTicker: require("custom/myproj.dashboard.tileprovider_minimal.time_step_ticker")
            .TimeStepTicker,
          MyTileRenderer: require("custom/myproj.dashboard.tileprovider_minimal.my_tile_renderer")
            .MyTileRenderer,
          MyTileSource: require("custom/myproj.dashboard.tileprovider_minimal.my_tile_source")
            .MyTileSource,
        };
        require("base").register_models(models);
        module.exports = models;
      },

How do i do that when i have done import * as Bokeh from "@bokeh/bokehjs";?
I mean, what is the more modern way of doing something like this?

cc @mateusz

You can use static import/export statements only in ES modules (ESM) (at the top-level) and dynamic imports anywhere within ESM. Bokeh’s bundles are composed of commonjs modules, which were compiled from ES modules. You can’t use ES imports/exports in this scenario. You can, however, transpile your ESM into ES+commonjs, which is done by bokeh’s extensions compiler. If you do things differently, e.g. use webpack, then you may need a babel plugin of some sort. If this explanation is not sufficient, then please submit a complete example of what you’re doing, because this is a broad and complicated subject, and a lot may depend on the specifics of your case.