{"version":3,"file":"index.mjs","names":["build"],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n                   🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website:                  https://stormsoftware.com\n Repository:               https://github.com/storm-software/powerlines\n Documentation:            https://docs.stormsoftware.com/projects/powerlines\n Contact:                  https://stormsoftware.com/contact\n\n SPDX-License-Identifier:  Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { createUnplugin } from \"@powerlines/core\";\nimport { resolveOptions } from \"@powerlines/unplugin/rolldown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport defu from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { formatConfig } from \"powerlines/plugin-utils\";\nimport { rolldown as build, InputOptions } from \"rolldown\";\nimport { createRolldownPlugin } from \"unplugin\";\nimport type {\n  RolldownPluginContext,\n  RolldownPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n  interface Config {\n    rolldown?: RolldownPluginOptions;\n  }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n  TContext extends RolldownPluginContext = RolldownPluginContext\n>(\n  options: RolldownPluginOptions = {}\n): Plugin<TContext> => {\n  return {\n    name: \"rolldown\",\n    config() {\n      return {\n        output: {\n          format: [\"cjs\", \"esm\"]\n        },\n        rolldown: {\n          ...options\n        }\n      };\n    },\n    async build() {\n      this.debug(\"Starting Rolldown build process...\");\n\n      const resolved = resolveOptions(this);\n      const options = defu(this.config.rolldown, {\n        ...resolved,\n        config: false,\n        plugins: [\n          createRolldownPlugin(\n            createUnplugin(this, {\n              silenceHookLogging: true,\n              name: \"rolldown\"\n            })\n          )()\n        ]\n      }) as InputOptions;\n\n      this.debug({\n        meta: {\n          category: \"config\"\n        },\n        message: `Resolved Rolldown configuration: \\n${formatConfig(options)}`\n      });\n\n      const result = await build(options);\n\n      await Promise.all(\n        toArray(this.config.output.format).map(async format =>\n          result.write({\n            format\n          })\n        )\n      );\n    }\n  };\n};\n\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAa,UAGX,UAAiC,CAAC,MACb;CACrB,OAAO;EACL,MAAM;EACN,SAAS;GACP,OAAO;IACL,QAAQ,EACN,QAAQ,CAAC,OAAO,KAAK,EACvB;IACA,UAAU,EACR,GAAG,QACL;GACF;EACF;EACA,MAAM,QAAQ;GACZ,KAAK,MAAM,oCAAoC;GAE/C,MAAM,WAAW,eAAe,IAAI;GACpC,MAAM,UAAU,KAAK,KAAK,OAAO,UAAU;IACzC,GAAG;IACH,QAAQ;IACR,SAAS,CACP,qBACE,eAAe,MAAM;KACnB,oBAAoB;KACpB,MAAM;IACR,CAAC,CACH,CAAC,CAAC,CACJ;GACF,CAAC;GAED,KAAK,MAAM;IACT,MAAM,EACJ,UAAU,SACZ;IACA,SAAS,sCAAsC,aAAa,OAAO;GACrE,CAAC;GAED,MAAM,SAAS,MAAMA,SAAM,OAAO;GAElC,MAAM,QAAQ,IACZ,QAAQ,KAAK,OAAO,OAAO,MAAM,CAAC,CAAC,IAAI,OAAM,WAC3C,OAAO,MAAM,EACX,OACF,CAAC,CACH,CACF;EACF;CACF;AACF"}