{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["// @ts-nocheck\n/* -------------------------------------------------------------------\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/rspack\";\nimport { rspack as build, MultiRspackOptions } from \"@rspack/core\";\nimport defu from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { formatConfig } from \"powerlines/plugin-utils\";\nimport { createRspackPlugin } from \"unplugin\";\nimport type { RspackPluginContext, RspackPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n  interface Config {\n    rspack?: RspackPluginOptions;\n  }\n}\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n  TContext extends RspackPluginContext = RspackPluginContext\n>(\n  options: RspackPluginOptions = {}\n): Plugin<TContext> => {\n  return {\n    name: \"rspack\",\n    config() {\n      this.debug(\n        \"Providing default configuration for the Powerlines `rspack` build plugin.\"\n      );\n\n      return {\n        build: {\n          ...options,\n          variant: \"rspack\"\n        }\n      };\n    },\n    async build() {\n      this.debug(\"Starting Rspack build process...\");\n\n      const options = defu(\n        {\n          entry: this.entry.reduce(\n            (ret, entry) => {\n              ret[entry.output || entry.name || entry.file] = entry.file;\n\n              return ret;\n            },\n            {} as Record<string, string>\n          )\n        },\n        resolveOptions(this),\n        {\n          plugins: [\n            createRspackPlugin(\n              createUnplugin(this, {\n                silenceHookLogging: true,\n                name: \"rspack\"\n              })\n            )()\n          ]\n        }\n      );\n\n      this.debug({\n        meta: {\n          category: \"config\"\n        },\n        message: `Resolved Rspack configuration: \\n${formatConfig(options)}`\n      });\n\n      build([options] as MultiRspackOptions);\n    }\n  };\n};\n\n"],"mappings":";;;;;;;;;;;AAuCA,MAAa,UAGX,UAA+B,CAAC,MACX;CACrB,OAAO;EACL,MAAM;EACN,SAAS;GACP,KAAK,MACH,2EACF;GAEA,OAAO,EACL,OAAO;IACL,GAAG;IACH,SAAS;GACX,EACF;EACF;EACA,MAAM,QAAQ;GACZ,KAAK,MAAM,kCAAkC;GAE7C,MAAM,UAAU,KACd,EACE,OAAO,KAAK,MAAM,QACf,KAAK,UAAU;IACd,IAAI,MAAM,UAAU,MAAM,QAAQ,MAAM,QAAQ,MAAM;IAEtD,OAAO;GACT,GACA,CAAC,CACH,EACF,GACA,eAAe,IAAI,GACnB,EACE,SAAS,CACP,mBACE,eAAe,MAAM;IACnB,oBAAoB;IACpB,MAAM;GACR,CAAC,CACH,CAAC,CAAC,CACJ,EACF,CACF;GAEA,KAAK,MAAM;IACT,MAAM,EACJ,UAAU,SACZ;IACA,SAAS,oCAAoC,aAAa,OAAO;GACnE,CAAC;GAED,OAAM,CAAC,OAAO,CAAuB;EACvC;CACF;AACF"}