{"version":3,"file":"index.mjs","names":["resolveOptionsBase"],"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/lib/unplugin\";\nimport { resolveOptions } from \"@powerlines/unplugin/tsup\";\nimport type { BuildOptions } from \"@storm-software/tsup\";\nimport {\n  build,\n  resolveOptions as resolveOptionsBase\n} from \"@storm-software/tsup\";\nimport defu from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { formatConfig } from \"powerlines/plugin-utils\";\nimport type { Options } from \"tsup\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport type { TsupPluginContext, TsupPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n  interface Config {\n    tsup?: TsupPluginOptions;\n  }\n}\n\n/**\n * A Powerlines plugin to use Tsup to build the project.\n */\nexport const plugin = <TContext extends TsupPluginContext = TsupPluginContext>(\n  options: TsupPluginOptions = {}\n): Plugin<TContext> => {\n  return {\n    name: \"tsup\",\n    config() {\n      this.debug(\n        \"Providing default configuration for the Powerlines `tsup` build plugin.\"\n      );\n\n      return {\n        output: {\n          format: [\"cjs\", \"esm\"]\n        },\n        tsup: {\n          ...options\n        }\n      };\n    },\n    async build() {\n      this.debug(\"Starting Tsup build process...\");\n\n      const resolved = resolveOptions(this);\n      const options = resolveOptionsBase(\n        defu(this.config.tsup, {\n          ...resolved,\n          config: false,\n          esbuildPlugins: [\n            createEsbuildPlugin(\n              createUnplugin(this, {\n                silenceHookLogging: true,\n                name: \"tsup\"\n              })\n            )()\n          ]\n        }) as BuildOptions\n      ) as Options;\n\n      this.debug({\n        meta: {\n          category: \"config\"\n        },\n        message: `Resolved Tsup configuration: \\n${formatConfig(options)}`\n      });\n\n      return build(options);\n    }\n  };\n};\n\n"],"mappings":";;;;;;;;;;;AA2CA,MAAa,UACX,UAA6B,CAAC,MACT;CACrB,OAAO;EACL,MAAM;EACN,SAAS;GACP,KAAK,MACH,yEACF;GAEA,OAAO;IACL,QAAQ,EACN,QAAQ,CAAC,OAAO,KAAK,EACvB;IACA,MAAM,EACJ,GAAG,QACL;GACF;EACF;EACA,MAAM,QAAQ;GACZ,KAAK,MAAM,gCAAgC;GAE3C,MAAM,WAAW,eAAe,IAAI;GACpC,MAAM,UAAUA,iBACd,KAAK,KAAK,OAAO,MAAM;IACrB,GAAG;IACH,QAAQ;IACR,gBAAgB,CACd,oBACE,eAAe,MAAM;KACnB,oBAAoB;KACpB,MAAM;IACR,CAAC,CACH,CAAC,CAAC,CACJ;GACF,CAAC,CACH;GAEA,KAAK,MAAM;IACT,MAAM,EACJ,UAAU,SACZ;IACA,SAAS,kCAAkC,aAAa,OAAO;GACjE,CAAC;GAED,OAAO,MAAM,OAAO;EACtB;CACF;AACF"}