scripts/build/esbuild-plugins/umd.mjs/getUmdWrapper
function getUmdWrapper(name, build) {
  const path = name.split(".");
  const { minify } = build.initialOptions;
  const temporaryName = minify ? "m" : camelCase(name);
  const placeholder = "/*! bundled code !*/";

  let globalObjectText = [];
  for (let index = 0; index < path.length; index++) {
    const object = ["root", ...path.slice(0, index + 1)].join(".");
    if (index === path.length - 1) {
      globalObjectText.push(`${object} = factory();`);
    } else {
      globalObjectText.push(`${object} = ${object} || {};`);
    }
  }
  globalObjectText = globalObjectText
    .map((text) => `${" ".repeat(4)}${text}`)
    .join("\n");

  let wrapper = outdent`
    (function (factory) {
      if (typeof exports === "object" && typeof module === "object") {
        module.exports = factory();
      } else if (typeof define === "function" && define.amd) {
        define(factory);
      } else {
        var root =
          typeof globalThis !== "undefined"
            ? globalThis
            : typeof global !== "undefined"
            ? global
            : typeof self !== "undefined"
            ? self
            : this || {};
        ${globalObjectText.trimStart()}
      }
    })(function() {
      "use strict";${placeholder}
    });
  `;

  if (minify) {
    wrapper = build.esbuild
      .transformSync(wrapper, { loader: "js", minify })
      .code.trim();
  }

  const [intro, outro] = wrapper.split(placeholder);

  return {
    name: temporaryName,
    intro,
    outro,
    expectedOutput: {
      start: minify
        ? `"use strict";var ${temporaryName}=(()=>{`
        : `"use strict";\nvar ${temporaryName} = (() => {`,
      end: "})();",
    },
  };
}