@powerlines/unplugin 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +8 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  3. package/dist/astro.cjs +8 -0
  4. package/dist/astro.d.mts +2 -0
  5. package/dist/astro.d.mts.map +1 -1
  6. package/dist/astro.mjs +8 -0
  7. package/dist/astro.mjs.map +1 -1
  8. package/dist/esbuild.cjs +8 -0
  9. package/dist/esbuild.d.mts +2 -0
  10. package/dist/esbuild.d.mts.map +1 -1
  11. package/dist/esbuild.mjs +8 -0
  12. package/dist/esbuild.mjs.map +1 -1
  13. package/dist/farm.cjs +8 -0
  14. package/dist/farm.d.mts +2 -0
  15. package/dist/farm.d.mts.map +1 -1
  16. package/dist/farm.mjs +8 -0
  17. package/dist/farm.mjs.map +1 -1
  18. package/dist/index.cjs +8 -0
  19. package/dist/index.d.mts +2 -0
  20. package/dist/index.d.mts.map +1 -1
  21. package/dist/index.mjs +8 -0
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/next.cjs +8 -0
  24. package/dist/next.d.mts +2 -0
  25. package/dist/next.d.mts.map +1 -1
  26. package/dist/next.mjs +8 -0
  27. package/dist/next.mjs.map +1 -1
  28. package/dist/nuxt.cjs +8 -0
  29. package/dist/nuxt.d.mts +2 -0
  30. package/dist/nuxt.d.mts.map +1 -1
  31. package/dist/nuxt.mjs +8 -0
  32. package/dist/nuxt.mjs.map +1 -1
  33. package/dist/package.cjs +9 -1
  34. package/dist/package.mjs +9 -1
  35. package/dist/rolldown.cjs +8 -0
  36. package/dist/rolldown.d.mts +2 -0
  37. package/dist/rolldown.d.mts.map +1 -1
  38. package/dist/rolldown.mjs +8 -0
  39. package/dist/rolldown.mjs.map +1 -1
  40. package/dist/rollup.cjs +8 -0
  41. package/dist/rollup.d.mts +2 -0
  42. package/dist/rollup.d.mts.map +1 -1
  43. package/dist/rollup.mjs +8 -0
  44. package/dist/rollup.mjs.map +1 -1
  45. package/dist/rspack.cjs +8 -0
  46. package/dist/rspack.d.mts +2 -0
  47. package/dist/rspack.d.mts.map +1 -1
  48. package/dist/rspack.mjs +8 -0
  49. package/dist/rspack.mjs.map +1 -1
  50. package/dist/tsdown.cjs +8 -0
  51. package/dist/tsdown.d.mts +2 -0
  52. package/dist/tsdown.d.mts.map +1 -1
  53. package/dist/tsdown.mjs +8 -0
  54. package/dist/tsdown.mjs.map +1 -1
  55. package/dist/tsup.cjs +8 -0
  56. package/dist/tsup.d.mts +2 -0
  57. package/dist/tsup.d.mts.map +1 -1
  58. package/dist/tsup.mjs +8 -0
  59. package/dist/tsup.mjs.map +1 -1
  60. package/dist/types.cjs +8 -0
  61. package/dist/types.d.mts +2 -0
  62. package/dist/types.d.mts.map +1 -1
  63. package/dist/types.mjs +8 -0
  64. package/dist/unloader.cjs +8 -0
  65. package/dist/unloader.d.mts +2 -0
  66. package/dist/unloader.d.mts.map +1 -1
  67. package/dist/unloader.mjs +8 -0
  68. package/dist/unloader.mjs.map +1 -1
  69. package/dist/unplugin.cjs +9 -2
  70. package/dist/unplugin.d.mts +2 -0
  71. package/dist/unplugin.d.mts.map +1 -1
  72. package/dist/unplugin.mjs +10 -3
  73. package/dist/unplugin.mjs.map +1 -1
  74. package/dist/vite.cjs +8 -0
  75. package/dist/vite.d.mts +2 -0
  76. package/dist/vite.d.mts.map +1 -1
  77. package/dist/vite.mjs +8 -0
  78. package/dist/vite.mjs.map +1 -1
  79. package/dist/webpack.cjs +8 -0
  80. package/dist/webpack.d.mts +2 -0
  81. package/dist/webpack.d.mts.map +1 -1
  82. package/dist/webpack.mjs +8 -0
  83. package/dist/webpack.mjs.map +1 -1
  84. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"unplugin.mjs","names":[],"sources":["../src/unplugin.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 type {\n CustomLogger,\n ExecutionContext,\n Options,\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"@powerlines/core\";\nimport {\n formatFolder,\n handleTypes,\n initializeTsconfig,\n installDependencies,\n isUnpluginBuilderVariant,\n loadParsedConfig,\n resolveRoot,\n resolveTsconfig,\n writeMetaFile\n} from \"@powerlines/core\";\nimport { UNPLUGIN_BUILDER_VARIANTS } from \"@powerlines/core/constants\";\nimport { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { executeEnvironments } from \"@powerlines/core/lib/environment\";\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport {\n addVirtualPrefix,\n formatConfig,\n removeVirtualPrefix,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"@powerlines/core/plugin-utils\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getWorkspaceRoot } from \"@stryke/fs/get-workspace-root\";\nimport { createDirectory } from \"@stryke/fs/helpers\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { LoadResult } from \"rolldown\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { UnpluginFactory } from \"./types\";\n\nexport * from \"@powerlines/core/lib/unplugin\";\n\n/**\n * The options required to create a Powerlines unplugin factory, which generates a plugin instance for a specific build variant and allows for optional customization of logging and framework identification.\n */\nexport interface UnpluginFactoryOptions extends Options {\n /**\n * The build variant for which to create the unplugin.\n *\n * @remarks\n * This option is required to ensure that the unplugin is built with the correct configuration and behavior for the intended build tool or framework. The variant will determine how the unplugin integrates with the build process and which hooks it will call during execution.\n */\n variant: UnpluginBuilderVariant;\n\n /**\n * An optional string prefix to use for virtual module IDs. This can be useful for ensuring that virtual modules are only processed by the plugin and not by other plugins or the bundler itself. If not provided, the default prefix `__powerlines-virtual:` will be used.\n *\n * @defaultValue \"\\\\0\"\n */\n virtualModulePrefix?: string | false;\n\n /**\n * A custom logger instance that implements the {@link CustomLogger} interface, which can be used for logging messages during the build process instead of the default Powerlines logger.\n *\n * @remarks\n * Providing a custom logger allows you to integrate Powerlines logging with your own logging system or to customize the logging behavior, such as formatting log messages differently or sending logs to an external service. If a custom logger is not provided, Powerlines will use its default logger implementation.\n */\n customLogger?: CustomLogger;\n}\n\nexport type UnpluginFactoryDecorator<TContext extends ExecutionContext> = (\n options: UnpluginOptions<TContext>\n) => Partial<UnpluginOptions<TContext>>;\n\n/**\n * Creates a Powerlines unplugin factory that generates a plugin instance.\n *\n * @remarks\n * The factory will handle loading the Powerlines configuration, resolving the plugin configuration, and executing the appropriate hooks during the build process. It also allows for optional customization of logging and framework identification through the provided options.\n *\n * @example\n * ```ts\n * import { createUnpluginFactory } from \"@powerlines/unplugin\";\n *\n * const factory = createUnpluginFactory({\n * variant: \"vite\",\n * framework: \"my-framework\",\n * orgId: \"my-org\",\n * customLogger: myCustomLogger\n * });\n *\n * const plugin = createVitePlugin(factory);\n * export default plugin;\n * ```\n *\n * @param options - The options for the unplugin factory, including the build variant and an optional custom logger.\n * @param decorate - An optional function to decorate the unplugin options.\n * @returns The unplugin factory that generates a plugin instance.\n */\nexport function createUnpluginFactory<\n TContext extends ExecutionContext = ExecutionContext\n>(\n options: UnpluginFactoryOptions,\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n): UnpluginFactory<TContext> {\n if (!isUnpluginBuilderVariant(options.variant)) {\n throw new Error(\n `Invalid unplugin builder variant: ${String(options.variant)}. Expected one of: ${UNPLUGIN_BUILDER_VARIANTS.join(\n \", \"\n )}.`\n );\n }\n\n const cwd = getWorkspaceRoot(process.cwd());\n const virtualModulePrefix = options.virtualModulePrefix ?? \"\\\\0\";\n\n return (params = {}): UnpluginOptions<TContext> => {\n let context!: PowerlinesExecutionContext<\n TContext[\"config\"],\n TContext[\"system\"]\n >;\n try {\n const framework =\n (params.framework?.name ?? options.framework?.name) || \"powerlines\";\n const orgId =\n (params.framework?.orgId ?? options.framework?.orgId) ||\n \"storm-software\";\n\n const root = resolveRoot(cwd, params.root, params.configFile);\n\n async function buildStart(this: UnpluginBuildContext): Promise<void> {\n const config = await loadParsedConfig(cwd, root, framework, orgId, {\n ...params,\n command: \"build\"\n });\n if (!config) {\n throw new Error(\"Failed to load configuration\");\n }\n\n const configs = toArray(config.config);\n if (\n params.configIndex !== undefined &&\n params.configIndex >= configs.length\n ) {\n throw new Error(\n `Invalid execution index: ${params.configIndex}. The configuration file contains ${configs.length} execution(s).`\n );\n }\n\n const _options = {\n cwd,\n root,\n ...params,\n command: \"build\",\n configFile: config.configFile!,\n executionId: uuid(),\n configIndex: 0\n };\n\n context = await PowerlinesExecutionContext.from(\n {\n ...options,\n ..._options,\n configFile: config.configFile!\n },\n _options\n );\n context.logger.info(\n `Starting ${titleCase(framework)} ${titleCase(options.variant)} plugin execution`\n );\n\n context.logger.debug({\n meta: { category: \"config\" },\n message: `Invoking ${titleCase(framework)} ${titleCase(\n options.variant\n )} plugin with the following execution parameters: \\n --- Execution Options --- \\n${formatConfig(\n params\n )}`\n });\n\n await resolvePluginConfig(context);\n\n const timer = context.timer(\"Preparation\");\n\n await executeEnvironments(context, async env => {\n env.debug(\n `Initializing the processing options for the Powerlines project.`\n );\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"pre\"\n });\n\n await initializeTsconfig(env);\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"normal\"\n });\n\n if (env.entry.length > 0) {\n const entriesLength = isObject(env.config.input)\n ? Object.keys(env.config.input).length\n : toArray(env.config.input).length;\n env.debug(\n `The configuration provided ${entriesLength} entry point${\n entriesLength !== 1 ? \"s\" : \"\"\n }, Powerlines has found ${env.entry.length} entry file${\n env.entry.length !== 1 ? \"s\" : \"\"\n } for the ${env.config.title} project${\n env.entry.length > 0 && env.entry.length < 10\n ? `: \\n${env.entry\n .map(\n entry =>\n `- ${replacePath(entry.file, context.config.root)}${\n entry.output\n ? ` -> ${replacePath(\n entry.output,\n context.config.root\n )}`\n : \"\"\n }`\n )\n .join(\" \\n\")}`\n : \"\"\n }`\n );\n } else {\n env.warn(\n `No entry files were found for the ${\n env.config.title\n } project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`\n );\n }\n\n await resolveTsconfig(env);\n await installDependencies(env);\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"post\"\n });\n\n env.trace({\n meta: {\n category: \"config\"\n },\n message: `Powerlines configuration after configResolved hook: \\n${formatConfig(\n env.config\n )}`\n });\n\n if (!env.fs.existsSync(env.cachePath)) {\n await createDirectory(env.cachePath);\n }\n\n if (!env.fs.existsSync(env.dataPath)) {\n await createDirectory(env.dataPath);\n }\n\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"pre\"\n });\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"normal\"\n });\n\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"post\"\n });\n\n if (env.config.output.types !== false) {\n await handleTypes(context, env);\n }\n\n context.debug(\"Formatting files generated during the prepare step.\");\n\n await Promise.all([\n formatFolder(env, env.builtinsPath),\n formatFolder(env, env.entryPath)\n ]);\n\n await writeMetaFile(env);\n env.persistedMeta = env.meta;\n });\n\n timer();\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ) {\n const normalizedId = removeVirtualPrefix(id);\n const normalizedImporter = importer\n ? removeVirtualPrefix(importer)\n : undefined;\n\n let result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.resolve(normalizedId, normalizedImporter, {\n isFile: true,\n ...opts\n });\n if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n return null;\n }\n\n const load = {\n filter:\n virtualModulePrefix !== false\n ? {\n id: VIRTUAL_MODULE_PREFIX_REGEX\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n\n let result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.load(normalizedId);\n if (result) {\n return result;\n }\n\n return context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId\n );\n }\n } as UnpluginOptions<TContext>[\"load\"];\n\n async function transform(\n code: string,\n id: string\n ): Promise<TransformResult> {\n return context.callHook(\n \"transform\",\n {\n environment: await context.getEnvironment(),\n result: \"merge\",\n asNextParam: previousResult => getString(previousResult)\n },\n getString(code),\n id\n );\n }\n\n async function writeBundle(): Promise<void> {\n context.logger.debug(\"Finalizing Powerlines project output...\");\n\n await context.callHook(\"writeBundle\", {\n environment: await context.getEnvironment()\n });\n }\n\n context.logger.debug(\"Unplugin initialized successfully.\");\n\n const result = {\n name: `${kebabCase(framework)}:${kebabCase(options.variant)}-plugin`,\n context,\n resolveId,\n load,\n transform,\n buildStart,\n writeBundle\n } as unknown as UnpluginOptions<TContext>;\n\n return {\n ...result,\n ...decorate(result)\n };\n } catch (error) {\n if (isFunction(context?.logger?.error)) {\n context.logger.error((error as Error)?.message);\n }\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,SAAgB,sBAGd,SACA,YAA+C,YAAW,SAC/B;CAC3B,IAAI,CAAC,yBAAyB,QAAQ,OAAO,GAC3C,MAAM,IAAI,MACR,qCAAqC,OAAO,QAAQ,OAAO,EAAE,qBAAqB,0BAA0B,KAC1G,IACF,EAAE,EACJ;CAGF,MAAM,MAAM,iBAAiB,QAAQ,IAAI,CAAC;CAC1C,MAAM,sBAAsB,QAAQ,uBAAuB;CAE3D,QAAQ,SAAS,CAAC,MAAiC;EACjD,IAAI;EAIJ,IAAI;GACF,MAAM,aACH,OAAO,WAAW,QAAQ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C1B,OAAO;IACf;IAGF,OAAO;GACT;GAEA,MAAM,OAAO;IACX,QACE,wBAAwB,QACpB,EACE,IAAI,4BACN,IACA;IACN,MAAM,QAEJ,IACwC;KACxC,MAAM,eAAe,oBAAoB,EAAE;KAE3C,IAAI,SAAS,MAAM,QAAQ,SACzB,QACA;MACE,YAAY;MACZ,QAAQ;MACR,OAAO;KACT,GACA,YACF;KACA,IAAI,QACF,OAAO;KAGT,SAAS,MAAM,QAAQ,SACrB,QACA;MACE,YAAY;MACZ,QAAQ;MACR,OAAO;KACT,GACA,YACF;KACA,IAAI,QACF,OAAO;KAGT,SAAS,MAAM,QAAQ,KAAK,YAAY;KACxC,IAAI,QACF,OAAO;KAGT,OAAO,QAAQ,SACb,QACA;MACE,YAAY;MACZ,QAAQ;MACR,OAAO;KACT,GACA,YACF;IACF;GACF;GAEA,eAAe,UACb,MACA,IAC0B;IAC1B,OAAO,QAAQ,SACb,aACA;KACE,aAAa,MAAM,QAAQ,eAAe;KAC1C,QAAQ;KACR,cAAa,mBAAkB,UAAU,cAAc;IACzD,GACA,UAAU,IAAI,GACd,EACF;GACF;GAEA,eAAe,cAA6B;IAC1C,QAAQ,OAAO,MAAM,yCAAyC;IAE9D,MAAM,QAAQ,SAAS,eAAe,EACpC,aAAa,MAAM,QAAQ,eAAe,EAC5C,CAAC;GACH;GAEA,QAAQ,OAAO,MAAM,oCAAoC;GAEzD,MAAM,SAAS;IACb,MAAM,GAAG,UAAU,SAAS,EAAE,GAAG,UAAU,QAAQ,OAAO,EAAE;IAC5D;IACA;IACA;IACA;IACA;IACA;GACF;GAEA,OAAO;IACL,GAAG;IACH,GAAG,SAAS,MAAM;GACpB;EACF,SAAS,OAAO;GACd,IAAI,WAAW,SAAS,QAAQ,KAAK,GACnC,QAAQ,OAAO,MAAO,OAAiB,OAAO;GAGhD,MAAM;EACR;CACF;AACF"}
1
+ {"version":3,"file":"unplugin.mjs","names":[],"sources":["../src/unplugin.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 type {\n CustomLogger,\n ExecutionContext,\n Options,\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"@powerlines/core\";\nimport {\n formatFolder,\n handleTypes,\n initializeTsconfig,\n installDependencies,\n isUnpluginBuilderVariant,\n loadParsedConfig,\n resolveRoot,\n resolveTsconfig,\n writeMetaFile\n} from \"@powerlines/core\";\nimport { UNPLUGIN_BUILDER_VARIANTS } from \"@powerlines/core/constants\";\nimport { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { executeEnvironments } from \"@powerlines/core/lib/environment\";\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport {\n addVirtualPrefix,\n formatConfig,\n formatExecutionId,\n removeVirtualPrefix,\n VIRTUAL_MODULE_PREFIX_REGEX\n} from \"@powerlines/core/plugin-utils\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getWorkspaceRoot } from \"@stryke/fs/get-workspace-root\";\nimport { createDirectory } from \"@stryke/fs/helpers\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { LoadResult } from \"rolldown\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { UnpluginFactory } from \"./types\";\n\nexport * from \"@powerlines/core/lib/unplugin\";\n\n/**\n * The options required to create a Powerlines unplugin factory, which generates a plugin instance for a specific build variant and allows for optional customization of logging and framework identification.\n */\nexport interface UnpluginFactoryOptions extends Options {\n /**\n * The build variant for which to create the unplugin.\n *\n * @remarks\n * This option is required to ensure that the unplugin is built with the correct configuration and behavior for the intended build tool or framework. The variant will determine how the unplugin integrates with the build process and which hooks it will call during execution.\n */\n variant: UnpluginBuilderVariant;\n\n /**\n * An optional string prefix to use for virtual module IDs. This can be useful for ensuring that virtual modules are only processed by the plugin and not by other plugins or the bundler itself. If not provided, the default prefix `__powerlines-virtual:` will be used.\n *\n * @defaultValue \"\\\\0\"\n */\n virtualModulePrefix?: string | false;\n\n /**\n * A custom logger instance that implements the {@link CustomLogger} interface, which can be used for logging messages during the build process instead of the default Powerlines logger.\n *\n * @remarks\n * Providing a custom logger allows you to integrate Powerlines logging with your own logging system or to customize the logging behavior, such as formatting log messages differently or sending logs to an external service. If a custom logger is not provided, Powerlines will use its default logger implementation.\n */\n customLogger?: CustomLogger;\n}\n\nexport type UnpluginFactoryDecorator<TContext extends ExecutionContext> = (\n options: UnpluginOptions<TContext>\n) => Partial<UnpluginOptions<TContext>>;\n\n/**\n * Creates a Powerlines unplugin factory that generates a plugin instance.\n *\n * @remarks\n * The factory will handle loading the Powerlines configuration, resolving the plugin configuration, and executing the appropriate hooks during the build process. It also allows for optional customization of logging and framework identification through the provided options.\n *\n * @example\n * ```ts\n * import { createUnpluginFactory } from \"@powerlines/unplugin\";\n *\n * const factory = createUnpluginFactory({\n * variant: \"vite\",\n * framework: \"my-framework\",\n * orgId: \"my-org\",\n * customLogger: myCustomLogger\n * });\n *\n * const plugin = createVitePlugin(factory);\n * export default plugin;\n * ```\n *\n * @param options - The options for the unplugin factory, including the build variant and an optional custom logger.\n * @param decorate - An optional function to decorate the unplugin options.\n * @returns The unplugin factory that generates a plugin instance.\n */\nexport function createUnpluginFactory<\n TContext extends ExecutionContext = ExecutionContext\n>(\n options: UnpluginFactoryOptions,\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n): UnpluginFactory<TContext> {\n if (!isUnpluginBuilderVariant(options.variant)) {\n throw new Error(\n `Invalid unplugin builder variant: ${String(options.variant)}. Expected one of: ${UNPLUGIN_BUILDER_VARIANTS.join(\n \", \"\n )}.`\n );\n }\n\n const cwd = getWorkspaceRoot(process.cwd());\n const virtualModulePrefix = options.virtualModulePrefix ?? \"\\\\0\";\n\n return (params = {}): UnpluginOptions<TContext> => {\n let context!: ExecutionContext<TContext[\"config\"], TContext[\"system\"]>;\n try {\n const framework =\n (params.framework?.name ?? options.framework?.name) || \"powerlines\";\n const orgId =\n (params.framework?.orgId ?? options.framework?.orgId) ||\n \"storm-software\";\n\n const root = resolveRoot(cwd, params.root, params.configFile);\n\n async function buildStart(this: UnpluginBuildContext): Promise<void> {\n const config = await loadParsedConfig(cwd, root, framework, orgId, {\n ...params,\n command: \"build\"\n });\n if (!config) {\n throw new Error(\"Failed to load configuration\");\n }\n\n const configs = toArray(config.config);\n if (\n params.configIndex !== undefined &&\n params.configIndex >= configs.length\n ) {\n throw new Error(\n `Invalid execution index: ${params.configIndex}. The configuration file contains ${configs.length} execution(s).`\n );\n }\n\n const _options = {\n cwd,\n root,\n ...params,\n command: \"build\",\n configFile: config.configFile!,\n executionId: formatExecutionId(\n config.config.name || root,\n \"build\",\n 0\n ),\n configIndex: 0\n };\n\n context = await PowerlinesExecutionContext.from(\n {\n ...options,\n ..._options,\n configFile: config.configFile!\n },\n _options\n );\n context.logger.info(\n `Starting ${titleCase(framework)} ${titleCase(options.variant)} plugin execution`\n );\n\n context.logger.debug({\n meta: { category: \"config\" },\n message: `Invoking ${titleCase(framework)} ${titleCase(\n options.variant\n )} plugin with the following execution parameters: \\n --- Execution Options --- \\n${formatConfig(\n params\n )}`\n });\n\n await resolvePluginConfig(context);\n\n const timer = context.timer(\"Preparation\");\n\n await executeEnvironments(context, async env => {\n env.debug(\n `Initializing the processing options for the Powerlines project.`\n );\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"pre\"\n });\n\n await initializeTsconfig(env);\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"normal\"\n });\n\n if (env.entry.length > 0) {\n const entriesLength = isObject(env.config.input)\n ? Object.keys(env.config.input).length\n : toArray(env.config.input).length;\n env.debug(\n `The configuration provided ${entriesLength} entry point${\n entriesLength !== 1 ? \"s\" : \"\"\n }, Powerlines has found ${env.entry.length} entry file${\n env.entry.length !== 1 ? \"s\" : \"\"\n } for the ${env.config.title} project${\n env.entry.length > 0 && env.entry.length < 10\n ? `: \\n${env.entry\n .map(\n entry =>\n `- ${replacePath(entry.file, context.config.root)}${\n entry.output\n ? ` -> ${replacePath(\n entry.output,\n context.config.root\n )}`\n : \"\"\n }`\n )\n .join(\" \\n\")}`\n : \"\"\n }`\n );\n } else {\n env.warn(\n `No entry files were found for the ${\n env.config.title\n } project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`\n );\n }\n\n await resolveTsconfig(env);\n await installDependencies(env);\n\n await context.callHook(\"configResolved\", {\n environment: env,\n order: \"post\"\n });\n\n env.trace({\n meta: {\n category: \"config\"\n },\n message: `Powerlines configuration after configResolved hook: \\n${formatConfig(\n env.config\n )}`\n });\n\n if (!env.fs.existsSync(env.cachePath)) {\n await createDirectory(env.cachePath);\n }\n\n if (!env.fs.existsSync(env.dataPath)) {\n await createDirectory(env.dataPath);\n }\n\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"pre\"\n });\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"normal\"\n });\n\n await context.callHook(\"prepare\", {\n environment: env,\n order: \"post\"\n });\n\n if (env.config.output.types !== false) {\n await handleTypes(context, env);\n }\n\n context.debug(\"Formatting files generated during the prepare step.\");\n\n await Promise.all([\n formatFolder(env, env.builtinsPath),\n formatFolder(env, env.entryPath)\n ]);\n\n await writeMetaFile(env);\n env.persistedMeta = env.meta;\n });\n\n timer();\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n opts: {\n isEntry: boolean;\n } = { isEntry: false }\n ) {\n const normalizedId = removeVirtualPrefix(id);\n const normalizedImporter = importer\n ? removeVirtualPrefix(importer)\n : undefined;\n\n let result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.resolve(normalizedId, normalizedImporter, {\n isFile: true,\n ...opts\n });\n if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n result = await context.callHook(\n \"resolveId\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId,\n normalizedImporter,\n opts\n );\n if (isSetString(result)) {\n return result;\n } else if (isSetObject(result)) {\n return {\n ...result,\n id:\n result.virtual && virtualModulePrefix !== false\n ? addVirtualPrefix(result.id)\n : result.id\n };\n }\n\n return null;\n }\n\n const load = {\n filter:\n virtualModulePrefix !== false\n ? {\n id: VIRTUAL_MODULE_PREFIX_REGEX\n }\n : undefined,\n async handler(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult | null | undefined> {\n const normalizedId = removeVirtualPrefix(id);\n\n let result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"pre\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"normal\"\n },\n normalizedId\n );\n if (result) {\n return result;\n }\n\n result = await context.load(normalizedId);\n if (result) {\n return result;\n }\n\n return context.callHook(\n \"load\",\n {\n sequential: true,\n result: \"first\",\n order: \"post\"\n },\n normalizedId\n );\n }\n } as UnpluginOptions<TContext>[\"load\"];\n\n async function transform(\n code: string,\n id: string\n ): Promise<TransformResult> {\n return context.callHook(\n \"transform\",\n {\n environment: await context.getEnvironment(),\n result: \"merge\",\n asNextParam: previousResult => getString(previousResult)\n },\n getString(code),\n id\n );\n }\n\n async function writeBundle(): Promise<void> {\n context.logger.debug(\"Finalizing Powerlines project output...\");\n\n await context.callHook(\"writeBundle\", {\n environment: await context.getEnvironment()\n });\n }\n\n context.logger.debug(\"Unplugin initialized successfully.\");\n\n const result = {\n name: `${kebabCase(framework)}:${kebabCase(options.variant)}-plugin`,\n context,\n resolveId,\n load,\n transform,\n buildStart,\n writeBundle\n } as unknown as UnpluginOptions<TContext>;\n\n return {\n ...result,\n ...decorate(result)\n };\n } catch (error) {\n if (isFunction(context?.logger?.error)) {\n context.logger.error((error as Error)?.message);\n }\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,SAAgB,sBAGd,SACA,YAA+C,YAAW,SAC/B;CAC3B,IAAI,CAAC,yBAAyB,QAAQ,OAAO,GAC3C,MAAM,IAAI,MACR,qCAAqC,OAAO,QAAQ,OAAO,EAAE,qBAAqB,0BAA0B,KAC1G,IACF,EAAE,EACJ;CAGF,MAAM,MAAM,iBAAiB,QAAQ,IAAI,CAAC;CAC1C,MAAM,sBAAsB,QAAQ,uBAAuB;CAE3D,QAAQ,SAAS,CAAC,MAAiC;EACjD,IAAI;EACJ,IAAI;GAC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.cjs CHANGED
@@ -1,3 +1,11 @@
1
+
2
+
3
+ import __tsdown_shims_path from 'node:path'
4
+ import __tsdown_shims_url from 'node:url'
5
+
6
+ const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
+ const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
+
1
9
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
10
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
11
  const require_unplugin = require('./unplugin.cjs');
package/dist/vite.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
1
3
  import { UnpluginExecutionOptions, UnpluginFactory } from "./types.mjs";
2
4
  import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.mjs";
3
5
  import { ExecutionContext, UnresolvedContext } from "@powerlines/core";
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite.ts"],"mappings":";;;;;;cAsCa,eAAA,EAAiB,OAAO,CAAC,YAAA;;;AAAtC;;;;iBAiBgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,YAAA;AAFH;;;;;;;;;;;;;;AAEa;AAuFb;;;;;;;AAzFA,iBAyFgB,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;;;cAqGtD,MAAA,GAAM,OAAA,GAAwC,wBAAxC,gCAAA,MAAA,uBAAA,MAAA"}
1
+ {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite.ts"],"mappings":";;;;;;;;cAsCa,eAAA,EAAiB,OAAO,CAAC,YAAA;;;;;;;iBAiBtB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,YAAA;;;;AAnBH;;;;AAAgD;AAiBhD;;;;;;;;;;;;;;iBAyFgB,iBAAA,kBAAmC,gBAAA,CAAA,CACjD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;AAFnE;;;;;;;;;;;;;;;;AAAA,cAuGa,MAAA,GAAM,OAAA,GAAwC,wBAAxC,gCAAA,MAAA,uBAAA,MAAA"}
package/dist/vite.mjs CHANGED
@@ -1,3 +1,11 @@
1
+
2
+
3
+ import __tsdown_shims_path from 'node:path'
4
+ import __tsdown_shims_url from 'node:url'
5
+
6
+ const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
+ const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
+
1
9
  import { createUnpluginFactory } from "./unplugin.mjs";
2
10
  import { resolveOptions as resolveOptions$1 } from "./esbuild.mjs";
3
11
  import { resolveOptions as resolveOptions$2 } from "./rolldown.mjs";
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["resolveEsbuildOptions","resolveRolldownOptions"],"sources":["../src/vite.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 {\n ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { isDevelopmentMode, isTestMode } from \"@stryke/env/environment-checks\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createVitePlugin } from \"unplugin\";\nimport { ESBuildOptions, UserConfig } from \"vite\";\nimport { resolveOptions as resolveEsbuildOptions } from \"./esbuild\";\nimport { resolveOptions as resolveRolldownOptions } from \"./rolldown\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\nexport const DEFAULT_OPTIONS: Partial<UserConfig> = {\n resolve: {\n extensions: [\".mjs\", \".js\", \".mts\", \".ts\", \".jsx\", \".tsx\", \".json\"]\n },\n json: {\n stringify: true\n },\n logLevel: \"silent\",\n clearScreen: true\n};\n\n/**\n * Resolves the options for [vite](https://vitejs.dev/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): UserConfig {\n return defu(\n {\n define: context.config.define,\n root: appendPath(context.config.root, context.config.cwd),\n platform: context.config.platform,\n mode:\n context.config.mode === \"development\" ? \"development\" : \"production\",\n cacheDir: joinPaths(context.cachePath, \"vite\"),\n build: {\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n outDir: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n resolve: {\n alias: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n ),\n dedupe: context.config.resolve.dedupe,\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n extensions: context.config.resolve.extensions\n },\n esbuild: resolveEsbuildOptions(context) as ESBuildOptions,\n optimizeDeps: {\n extensions: context.config.resolve.extensions,\n rolldownOptions: resolveRolldownOptions(context),\n esbuildOptions: resolveEsbuildOptions(context)\n },\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"info\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"error\",\n clearScreen: true,\n envDir: context.config.root\n } as UserConfig,\n DEFAULT_OPTIONS\n );\n}\n\n/**\n * Creates a Vite plugin factory that generates a plugin instance.\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-api\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { createViteFactory } from \"@powerlines/unplugin/vite\";\n *\n * const powerlinesPlugin = createViteFactory({ name: \"example-app\", ... });\n *\n * export default defineConfig({\n * plugins: [powerlinesPlugin()],\n * });\n *\n * ```\n *\n * @param options - The options to create the plugin factory with.\n * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.\n * @returns A function that generates a Vite plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Vite build.\n */\nexport function createViteFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"vite\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n vite: {\n sharedDuringBuild: true,\n\n async hotUpdate(opts) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:hotUpdate\",\n { environment },\n opts\n );\n },\n async config(config, env) {\n unplugin.context.config.mode = isDevelopmentMode(env.mode)\n ? \"development\"\n : isTestMode(env.mode)\n ? \"test\"\n : \"production\";\n\n const environment = await unplugin.context.getEnvironment();\n const result = await unplugin.context.callHook(\n \"vite:config\",\n { environment },\n config,\n env\n );\n\n return defu(\n resolveOptions(unplugin.context),\n result?.build ?? {},\n config\n ) as Omit<UserConfig, \"plugins\">;\n },\n async configResolved(_config) {\n const environment = await unplugin.context.getEnvironment();\n\n await unplugin.context.callHook(\"configResolved\", { environment });\n },\n async configureServer(server) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:configureServer\",\n { environment },\n server\n );\n },\n async configurePreviewServer(server) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:configurePreviewServer\",\n { environment },\n server\n );\n },\n async transformIndexHtml(html, ctx) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:transformIndexHtml\",\n { environment },\n html,\n ctx\n );\n },\n async handleHotUpdate(ctx) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:handleHotUpdate\",\n { environment },\n ctx\n );\n }\n }\n })\n );\n}\n\n/**\n * A Vite plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-api\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import powerlines from \"@powerlines/unplugin/vite\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const plugin = createVitePlugin(createViteFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;AAsCA,MAAa,kBAAuC;CAClD,SAAS,EACP,YAAY;EAAC;EAAQ;EAAO;EAAQ;EAAO;EAAQ;EAAQ;CAAO,EACpE;CACA,MAAM,EACJ,WAAW,KACb;CACA,UAAU;CACV,aAAa;AACf;;;;;;;AAQA,SAAgB,eACd,SACY;CACZ,OAAO,KACL;EACE,QAAQ,QAAQ,OAAO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F,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,iBAAiB,kBAAkB,CAAC"}
1
+ {"version":3,"file":"vite.mjs","names":["resolveEsbuildOptions","resolveRolldownOptions"],"sources":["../src/vite.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 {\n ExecutionContext,\n UnpluginOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { isDevelopmentMode, isTestMode } from \"@stryke/env/environment-checks\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createVitePlugin } from \"unplugin\";\nimport { ESBuildOptions, UserConfig } from \"vite\";\nimport { resolveOptions as resolveEsbuildOptions } from \"./esbuild\";\nimport { resolveOptions as resolveRolldownOptions } from \"./rolldown\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\nexport const DEFAULT_OPTIONS: Partial<UserConfig> = {\n resolve: {\n extensions: [\".mjs\", \".js\", \".mts\", \".ts\", \".jsx\", \".tsx\", \".json\"]\n },\n json: {\n stringify: true\n },\n logLevel: \"silent\",\n clearScreen: true\n};\n\n/**\n * Resolves the options for [vite](https://vitejs.dev/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): UserConfig {\n return defu(\n {\n define: context.config.define,\n root: appendPath(context.config.root, context.config.cwd),\n platform: context.config.platform,\n mode:\n context.config.mode === \"development\" ? \"development\" : \"production\",\n cacheDir: joinPaths(context.cachePath, \"vite\"),\n build: {\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n outDir: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.config.cwd\n ),\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n resolve: {\n alias: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n ),\n dedupe: context.config.resolve.dedupe,\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n extensions: context.config.resolve.extensions\n },\n esbuild: resolveEsbuildOptions(context) as ESBuildOptions,\n optimizeDeps: {\n extensions: context.config.resolve.extensions,\n rolldownOptions: resolveRolldownOptions(context),\n esbuildOptions: resolveEsbuildOptions(context)\n },\n logLevel:\n context.config.logLevel.general === \"trace\"\n ? \"info\"\n : context.config.logLevel.general === \"debug\"\n ? \"warn\"\n : \"error\",\n clearScreen: true,\n envDir: context.config.root\n } as UserConfig,\n DEFAULT_OPTIONS\n );\n}\n\n/**\n * Creates a Vite plugin factory that generates a plugin instance.\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-api\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { createViteFactory } from \"@powerlines/unplugin/vite\";\n *\n * const powerlinesPlugin = createViteFactory({ name: \"example-app\", ... });\n *\n * export default defineConfig({\n * plugins: [powerlinesPlugin()],\n * });\n *\n * ```\n *\n * @param options - The options to create the plugin factory with.\n * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.\n * @returns A function that generates a Vite plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Vite build.\n */\nexport function createViteFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"vite\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n vite: {\n sharedDuringBuild: true,\n\n async hotUpdate(opts) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:hotUpdate\",\n { environment },\n opts\n );\n },\n async config(config, env) {\n unplugin.context.config.mode = isDevelopmentMode(env.mode)\n ? \"development\"\n : isTestMode(env.mode)\n ? \"test\"\n : \"production\";\n\n const environment = await unplugin.context.getEnvironment();\n const result = await unplugin.context.callHook(\n \"vite:config\",\n { environment },\n config,\n env\n );\n\n return defu(\n resolveOptions(unplugin.context),\n result?.build ?? {},\n config\n ) as Omit<UserConfig, \"plugins\">;\n },\n async configResolved(_config) {\n const environment = await unplugin.context.getEnvironment();\n\n await unplugin.context.callHook(\"configResolved\", { environment });\n },\n async configureServer(server) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:configureServer\",\n { environment },\n server\n );\n },\n async configurePreviewServer(server) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:configurePreviewServer\",\n { environment },\n server\n );\n },\n async transformIndexHtml(html, ctx) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:transformIndexHtml\",\n { environment },\n html,\n ctx\n );\n },\n async handleHotUpdate(ctx) {\n const environment = await unplugin.context.getEnvironment();\n\n return unplugin.context.callHook(\n \"vite:handleHotUpdate\",\n { environment },\n ctx\n );\n }\n }\n })\n );\n}\n\n/**\n * A Vite plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://vitejs.dev/guide/api-plugin.html#plugin-api\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import powerlines from \"@powerlines/unplugin/vite\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const plugin = createVitePlugin(createViteFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,MAAa,kBAAuC;CAClD,SAAS,EACP,YAAY;EAAC;EAAQ;EAAO;EAAQ;EAAO;EAAQ;EAAQ;CAAO,EACpE;CACA,MAAM,EACJ,WAAW,KACb;CACA,UAAU;CACV,aAAa;AACf;;;;;;;AAQA,SAAgB,eACd,SACY;CACZ,OAAO,KACL;EACE,QAAQ,QAAQ,OAAO;EACvB,MAAM,WAAW,QAAQ,OAAO,MAAM,QAAQ,OAAO,GAAG;EACxD,UAAU,QAAQ,OAAO;EACzB,MACE,QAAQ,OAAO,SAAS,gBAAgB,gBAAgB;EAC1D,UAAU,UAAU,QAAQ,WAAW,MAAM;EAC7C,OAAO;GACL,QAAQ,QAAQ,OAAO,OAAO;GAC9B,UAAU,QAAQ,OAAO,SAAS;GAClC,WAAW,QAAQ,OAAO,OAAO;GACjC,QAAQ,aACN,WAAW,QAAQ,OAAO,MAAM,QAAQ,OAAO,GAAG,GAClD,QAAQ,OAAO,OAAO,IACxB;GACA,UAAU,WACR,QAAQ,SAAS,kBACjB,QAAQ,OAAO,GACjB;GACA,aAAa,QAAQ,SAAS;EAChC;EACA,SAAS;GACP,OAAO,OAAO,QAAQ,QAAQ,KAAK,EAAE,QAClC,KAAK,CAAC,IAAI,UAAU;IACnB,IAAI,CAAC,IAAI,MAAK,MAAK,EAAE,SAAS,EAAE,GAC9B,IAAI,KAAK;KACP,MAAM;KACN,aAAa;IACf,CAAC;SAED,QAAQ,KACN,8BAA8B,GAAG,0CACnC;IAGF,OAAO;GACT,GACA,CAAC,CACH;GACA,QAAQ,QAAQ,OAAO,QAA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;IAE1D,OAAO,SAAS,QAAQ,SACtB,wBACA,EAAE,YAAY,GACd,MACF;GACF;GACA,MAAM,uBAAuB,QAAQ;IACnC,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;IAE1D,OAAO,SAAS,QAAQ,SACtB,+BACA,EAAE,YAAY,GACd,MACF;GACF;GACA,MAAM,mBAAmB,MAAM,KAAK;IAClC,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;IAE1D,OAAO,SAAS,QAAQ,SACtB,2BACA,EAAE,YAAY,GACd,MACA,GACF;GACF;GACA,MAAM,gBAAgB,KAAK;IACzB,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe;IAE1D,OAAO,SAAS,QAAQ,SACtB,wBACA,EAAE,YAAY,GACd,GACF;GACF;EACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,iBAAiB,kBAAkB,CAAC"}
package/dist/webpack.cjs CHANGED
@@ -1,3 +1,11 @@
1
+
2
+
3
+ import __tsdown_shims_path from 'node:path'
4
+ import __tsdown_shims_url from 'node:url'
5
+
6
+ const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
+ const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
+
1
9
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
10
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
11
  const require_unplugin = require('./unplugin.cjs');
@@ -1,3 +1,5 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
1
3
  import { UnpluginExecutionOptions, UnpluginFactory } from "./types.mjs";
2
4
  import { UnpluginFactoryDecorator, UnpluginFactoryOptions } from "./unplugin.mjs";
3
5
  import { Context, ExecutionContext } from "@powerlines/core";
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.d.mts","names":[],"sources":["../src/webpack.ts"],"mappings":";;;;;;;;;;AAqCA;;;iBAAgB,cAAA,CACd,OAAA,EAAS,OAAA,GACR,WAAA,CAAY,wBAAA;;;;;;;;;;AAAwB;AAiEvC;;;;;;;;;;;;iBAAgB,oBAAA,kBAAsC,gBAAA,CAAA,CACpD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;AAAA;AAgCnE;;;cAAa,MAAA,GAAM,OAAA,GAA8C,wBAA9C,mCAAA,qBAAA"}
1
+ {"version":3,"file":"webpack.d.mts","names":[],"sources":["../src/webpack.ts"],"mappings":";;;;;;;;;;;;;;;iBAqCgB,cAAA,CACd,OAAA,EAAS,OAAA,GACR,WAAA,CAAY,wBAAA;;;;;AAFf;;;;;;;;;;;;;AAEuC;AAiEvC;;;;iBAAgB,oBAAA,kBAAsC,gBAAA,CAAA,CACpD,OAAA,GAAS,IAAA,CAAK,sBAAA,cACd,QAAA,GAAU,wBAAA,CAAyB,QAAA,IAA8B,eAAA,CAAA,gBAAA,4BAAA,cAAA;;;;;;;;;;;;;;;;cAgCtD,MAAA,GAAM,OAAA,GAA8C,wBAA9C,mCAAA,qBAAA"}
package/dist/webpack.mjs CHANGED
@@ -1,3 +1,11 @@
1
+
2
+
3
+ import __tsdown_shims_path from 'node:path'
4
+ import __tsdown_shims_url from 'node:url'
5
+
6
+ const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
+ const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
+
1
9
  import { createUnpluginFactory } from "./unplugin.mjs";
2
10
  import { joinPaths } from "@stryke/path/join-paths";
3
11
  import defu from "defu";
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.mjs","names":[],"sources":["../src/webpack.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 { Context, ExecutionContext } from \"@powerlines/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createWebpackPlugin, WebpackCompiler } from \"unplugin\";\nimport { WebpackOptionsNormalized } from \"webpack\";\nimport { UnpluginOptions } from \"./types\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [webpack](https://webpack.js.org/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(\n context: Context\n): DeepPartial<WebpackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n node:\n context.config.platform === \"node\"\n ? {\n __dirname: true,\n __filename: true,\n global: true\n }\n : false,\n mode:\n context.config.mode === \"development\"\n ? (\"development\" as const)\n : (\"production\" as const),\n cache: {\n type: \"filesystem\" as const,\n cacheDirectory: joinPaths(context.cachePath, \"webpack\", \"cache\")\n },\n recordsInputPath: joinPaths(\n context.cachePath,\n \"webpack\",\n \".webpack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"webpack\",\n \".webpack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n };\n}\n\n/**\n * Creates a Webpack plugin factory that generates a plugin instance.\n *\n * @see https://webpack.js.org/api/plugins/\n *\n * @example\n * ```ts\n * // webpack.config.ts\n * import { createWebpackFactory } from \"@powerlines/unplugin/webpack\";\n *\n * const powerlinesPlugin = createWebpackFactory({ name: \"example-app\", ... });\n *\n * export default defineConfig({\n * plugins: [powerlinesPlugin()],\n * });\n *\n * ```\n *\n * @param options - The options to create the plugin factory with.\n * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.\n * @returns A function that generates a Webpack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Webpack build.\n */\nexport function createWebpackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"webpack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n webpack(compiler: WebpackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesWebpackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as WebpackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Webpack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture\n *\n * @example\n * ```js\n * // webpack.config.js\n * import powerlines from \"@powerlines/unplugin/webpack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createWebpackPlugin(createWebpackFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;AAqCA,SAAgB,eACd,SACuC;CACvC,OAAO;EACL,QAAQ,EACN,MAAM,QAAQ,OAAO,OAAO,KAC9B;EACA,MAAM,QAAQ,OAAO;EACrB,SAAS,EACP,OAAO,QAAQ,MACjB;EACA,MACE,QAAQ,OAAO,aAAa,SACxB;GACE,WAAW;GACX,YAAY;GACZ,QAAQ;EACV,IACA;EACN,MACE,QAAQ,OAAO,SAAS,gBACnB,gBACA;EACP,OAAO;GACL,MAAM;GACN,gBAAgB,UAAU,QAAQ,WAAW,WAAW,OAAO;EACjE;EACA,kBAAkB,UAChB,QAAQ,WACR,WACA,uBACF;EACA,mBAAmB,UACjB,QAAQ,WACR,WACA,uBACF;EACA,SAAS,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI;EAC1D,SAAS,QAAQ,OAAO,OAAO,YAAY,eAAe;EAC1D,cAAc,EACZ,UAAU,QAAQ,OAAO,OAAO,OAClC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,qBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAU,IAAG,aAC/D,SAAS;EACP,GAAI;EACJ,QAAQ,UAA2B;GACjC,SAAS,MAAM,UAAU,IAAI,4BAA2B,aAAY;IAClE,SAAS,UAAU,KACjB,eAAe,SAAS,OAAO,GAC/B,SAAS,OACX;GACF,CAAC;EACH;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;AAiBA,MAAa,SAAS,oBAAoB,qBAAqB,CAAC"}
1
+ {"version":3,"file":"webpack.mjs","names":[],"sources":["../src/webpack.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 { Context, ExecutionContext } from \"@powerlines/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createWebpackPlugin, WebpackCompiler } from \"unplugin\";\nimport { WebpackOptionsNormalized } from \"webpack\";\nimport { UnpluginOptions } from \"./types\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [webpack](https://webpack.js.org/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(\n context: Context\n): DeepPartial<WebpackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n node:\n context.config.platform === \"node\"\n ? {\n __dirname: true,\n __filename: true,\n global: true\n }\n : false,\n mode:\n context.config.mode === \"development\"\n ? (\"development\" as const)\n : (\"production\" as const),\n cache: {\n type: \"filesystem\" as const,\n cacheDirectory: joinPaths(context.cachePath, \"webpack\", \"cache\")\n },\n recordsInputPath: joinPaths(\n context.cachePath,\n \"webpack\",\n \".webpack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"webpack\",\n \".webpack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n };\n}\n\n/**\n * Creates a Webpack plugin factory that generates a plugin instance.\n *\n * @see https://webpack.js.org/api/plugins/\n *\n * @example\n * ```ts\n * // webpack.config.ts\n * import { createWebpackFactory } from \"@powerlines/unplugin/webpack\";\n *\n * const powerlinesPlugin = createWebpackFactory({ name: \"example-app\", ... });\n *\n * export default defineConfig({\n * plugins: [powerlinesPlugin()],\n * });\n *\n * ```\n *\n * @param options - The options to create the plugin factory with.\n * @param decorate - A function to decorate the plugin options with additional properties or hooks. This can be used to add custom behavior to the plugin instance, such as additional hooks or configuration options. The function receives the generated plugin options and should return an object containing any additional properties or hooks to be merged into the final plugin options.\n * @returns A function that generates a Webpack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Webpack build.\n */\nexport function createWebpackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"webpack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n webpack(compiler: WebpackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesWebpackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as WebpackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Webpack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture\n *\n * @example\n * ```js\n * // webpack.config.js\n * import powerlines from \"@powerlines/unplugin/webpack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createWebpackPlugin(createWebpackFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,eACd,SACuC;CACvC,OAAO;EACL,QAAQ,EACN,MAAM,QAAQ,OAAO,OAAO,KAC9B;EACA,MAAM,QAAQ,OAAO;EACrB,SAAS,EACP,OAAO,QAAQ,MACjB;EACA,MACE,QAAQ,OAAO,aAAa,SACxB;GACE,WAAW;GACX,YAAY;GACZ,QAAQ;EACV,IACA;EACN,MACE,QAAQ,OAAO,SAAS,gBACnB,gBACA;EACP,OAAO;GACL,MAAM;GACN,gBAAgB,UAAU,QAAQ,WAAW,WAAW,OAAO;EACjE;EACA,kBAAkB,UAChB,QAAQ,WACR,WACA,uBACF;EACA,mBAAmB,UACjB,QAAQ,WACR,WACA,uBACF;EACA,SAAS,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI;EAC1D,SAAS,QAAQ,OAAO,OAAO,YAAY,eAAe;EAC1D,cAAc,EACZ,UAAU,QAAQ,OAAO,OAAO,OAClC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,qBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAU,IAAG,aAC/D,SAAS;EACP,GAAI;EACJ,QAAQ,UAA2B;GACjC,SAAS,MAAM,UAAU,IAAI,4BAA2B,aAAY;IAClE,SAAS,UAAU,KACjB,eAAe,SAAS,OAAO,GAC/B,SAAS,OACX;GACF,CAAC;EACH;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;AAiBA,MAAa,SAAS,oBAAoB,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/unplugin",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "private": false,
5
5
  "description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
6
6
  "keywords": [
@@ -105,7 +105,7 @@
105
105
  "typings": "dist/index.d.mts",
106
106
  "files": ["dist"],
107
107
  "dependencies": {
108
- "@powerlines/core": "^0.48.24",
108
+ "@powerlines/core": "^0.48.26",
109
109
  "@rollup/plugin-alias": "^6.0.0",
110
110
  "@rollup/plugin-inject": "^5.0.5",
111
111
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -127,8 +127,8 @@
127
127
  },
128
128
  "devDependencies": {
129
129
  "@types/node": "^25.9.1",
130
- "rolldown": "^1.0.2",
131
- "tsdown": "^0.22.0",
130
+ "rolldown": "^1.0.3",
131
+ "tsdown": "^0.22.1",
132
132
  "tsup": "8.4.0",
133
133
  "vite": "^8.0.14",
134
134
  "webpack": "^5.107.2"
@@ -167,5 +167,5 @@
167
167
  "webpack": { "optional": true }
168
168
  },
169
169
  "publishConfig": { "access": "public" },
170
- "gitHead": "ba29330277e0d8be78bdad08d260ddae06a95e81"
170
+ "gitHead": "96a654a26c414db84da2bd824d8f821e6c0fe3ff"
171
171
  }