{"version":3,"file":"index.mjs","names":[],"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 { resolveEntry, resolveOptions } from \"@powerlines/unplugin/esbuild\";\nimport defu from \"defu\";\nimport { build, BuildOptions, SameShape } from \"esbuild\";\nimport type { Plugin } from \"powerlines\";\nimport { formatConfig } from \"powerlines/plugin-utils\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { EsbuildPluginContext, EsbuildPluginOptions } from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n  interface Config {\n    esbuild?: EsbuildPluginOptions;\n  }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n  TContext extends EsbuildPluginContext = EsbuildPluginContext\n>(\n  options: EsbuildPluginOptions = {}\n): Plugin<TContext> => {\n  return {\n    name: \"esbuild\",\n    config() {\n      return {\n        output: {\n          format: [\"esm\"]\n        },\n        esbuild: {\n          ...options\n        }\n      };\n    },\n    async build() {\n      this.debug(\"Starting Esbuild build process...\");\n\n      const resolved = resolveOptions(this);\n      const options = defu(this.config.esbuild, {\n        ...resolved,\n        entryPoints: resolveEntry(this, this.entry),\n        config: false,\n        plugins: [\n          createEsbuildPlugin(\n            createUnplugin(this, {\n              silenceHookLogging: true,\n              name: \"esbuild\"\n            })\n          )()\n        ]\n      }) as SameShape<BuildOptions, BuildOptions>;\n\n      this.debug({\n        meta: {\n          category: \"config\"\n        },\n        message: `Resolved Esbuild configuration: \\n${formatConfig(options)}`\n      });\n\n      await build(options);\n    }\n  };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;AAsCA,MAAa,UAGX,UAAgC,CAAC,MACZ;CACrB,OAAO;EACL,MAAM;EACN,SAAS;GACP,OAAO;IACL,QAAQ,EACN,QAAQ,CAAC,KAAK,EAChB;IACA,SAAS,EACP,GAAG,QACL;GACF;EACF;EACA,MAAM,QAAQ;GACZ,KAAK,MAAM,mCAAmC;GAE9C,MAAM,WAAW,eAAe,IAAI;GACpC,MAAM,UAAU,KAAK,KAAK,OAAO,SAAS;IACxC,GAAG;IACH,aAAa,aAAa,MAAM,KAAK,KAAK;IAC1C,QAAQ;IACR,SAAS,CACP,oBACE,eAAe,MAAM;KACnB,oBAAoB;KACpB,MAAM;IACR,CAAC,CACH,CAAC,CAAC,CACJ;GACF,CAAC;GAED,KAAK,MAAM;IACT,MAAM,EACJ,UAAU,SACZ;IACA,SAAS,qCAAqC,aAAa,OAAO;GACpE,CAAC;GAED,MAAM,MAAM,OAAO;EACrB;CACF;AACF"}