import { defineConfig } from "@rslib/core";
import builtins from "builtin-modules";

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

export default defineConfig({
  source: {
    entry: {
      main: "./src/main.ts",
    },
  },
  lib: [
    {
      format: "cjs",
      bundle: true,
      syntax: "es2018",
      autoExternal: false,
      banner: {
        js: banner,
      },
      output: {
        externals: [
          "obsidian",
          "electron",
          "@codemirror/autocomplete",
          "@codemirror/collab",
          "@codemirror/commands",
          "@codemirror/language",
          "@codemirror/lint",
          "@codemirror/search",
          "@codemirror/state",
          "@codemirror/view",
          "@lezer/common",
          "@lezer/highlight",
          "@lezer/lr",
          ...builtins,
        ],
        distPath: {
          root: ".",
        },
        cleanDistPath: false,
        minify: {
          js: true,
        },
      },
    },
  ],
});
