@powerlines/unplugin 0.0.75 → 0.0.76

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 (147) hide show
  1. package/dist/astro.cjs +11 -0
  2. package/dist/astro.mjs +6 -1
  3. package/dist/astro.mjs.map +1 -1
  4. package/dist/astro.test.cjs +23 -0
  5. package/dist/astro.test.d.cts +1 -0
  6. package/dist/astro.test.d.mts +2 -0
  7. package/dist/astro.test.mjs +25 -0
  8. package/dist/astro.test.mjs.map +1 -0
  9. package/dist/esbuild.d.cts.map +1 -1
  10. package/dist/esbuild.d.mts.map +1 -1
  11. package/dist/esbuild.test.cjs +32 -0
  12. package/dist/esbuild.test.d.cts +1 -0
  13. package/dist/esbuild.test.d.mts +2 -0
  14. package/dist/esbuild.test.mjs +34 -0
  15. package/dist/esbuild.test.mjs.map +1 -0
  16. package/dist/farm.cjs +12 -1
  17. package/dist/farm.d.cts.map +1 -1
  18. package/dist/farm.d.mts.map +1 -1
  19. package/dist/farm.mjs +6 -1
  20. package/dist/farm.mjs.map +1 -1
  21. package/dist/farm.test.cjs +23 -0
  22. package/dist/farm.test.d.cts +1 -0
  23. package/dist/farm.test.d.mts +2 -0
  24. package/dist/farm.test.mjs +25 -0
  25. package/dist/farm.test.mjs.map +1 -0
  26. package/dist/index.cjs +2 -1
  27. package/dist/index.mjs +2 -1
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/index.test.cjs +35 -0
  30. package/dist/index.test.d.cts +1 -0
  31. package/dist/index.test.d.mts +2 -0
  32. package/dist/index.test.mjs +37 -0
  33. package/dist/index.test.mjs.map +1 -0
  34. package/dist/next.cjs +12 -1
  35. package/dist/next.mjs +6 -1
  36. package/dist/next.mjs.map +1 -1
  37. package/dist/next.test.cjs +23 -0
  38. package/dist/next.test.d.cts +1 -0
  39. package/dist/next.test.d.mts +2 -0
  40. package/dist/next.test.mjs +25 -0
  41. package/dist/next.test.mjs.map +1 -0
  42. package/dist/nuxt.cjs +10 -1
  43. package/dist/nuxt.mjs +3 -1
  44. package/dist/nuxt.mjs.map +1 -1
  45. package/dist/nuxt.test.cjs +23 -0
  46. package/dist/nuxt.test.d.cts +1 -0
  47. package/dist/nuxt.test.d.mts +2 -0
  48. package/dist/nuxt.test.mjs +25 -0
  49. package/dist/nuxt.test.mjs.map +1 -0
  50. package/dist/package.cjs +1 -1
  51. package/dist/package.mjs +1 -1
  52. package/dist/rolldown.cjs +13 -1
  53. package/dist/rolldown.d.cts.map +1 -1
  54. package/dist/rolldown.d.mts.map +1 -1
  55. package/dist/rolldown.mjs +8 -1
  56. package/dist/rolldown.mjs.map +1 -1
  57. package/dist/rolldown.test.cjs +23 -0
  58. package/dist/rolldown.test.d.cts +1 -0
  59. package/dist/rolldown.test.d.mts +2 -0
  60. package/dist/rolldown.test.mjs +25 -0
  61. package/dist/rolldown.test.mjs.map +1 -0
  62. package/dist/rollup.cjs +14 -1
  63. package/dist/rollup.d.cts.map +1 -1
  64. package/dist/rollup.d.mts.map +1 -1
  65. package/dist/rollup.mjs +9 -1
  66. package/dist/rollup.mjs.map +1 -1
  67. package/dist/rollup.test.cjs +23 -0
  68. package/dist/rollup.test.d.cts +1 -0
  69. package/dist/rollup.test.d.mts +2 -0
  70. package/dist/rollup.test.mjs +25 -0
  71. package/dist/rollup.test.mjs.map +1 -0
  72. package/dist/rspack.cjs +13 -1
  73. package/dist/rspack.d.cts.map +1 -1
  74. package/dist/rspack.d.mts.map +1 -1
  75. package/dist/rspack.mjs +8 -1
  76. package/dist/rspack.mjs.map +1 -1
  77. package/dist/rspack.test.cjs +23 -0
  78. package/dist/rspack.test.d.cts +1 -0
  79. package/dist/rspack.test.d.mts +2 -0
  80. package/dist/rspack.test.mjs +25 -0
  81. package/dist/rspack.test.mjs.map +1 -0
  82. package/dist/tsdown.cjs +16 -1
  83. package/dist/tsdown.d.cts.map +1 -1
  84. package/dist/tsdown.d.mts.map +1 -1
  85. package/dist/tsdown.mjs +11 -1
  86. package/dist/tsdown.mjs.map +1 -1
  87. package/dist/tsdown.test.cjs +23 -0
  88. package/dist/tsdown.test.d.cts +1 -0
  89. package/dist/tsdown.test.d.mts +2 -0
  90. package/dist/tsdown.test.mjs +25 -0
  91. package/dist/tsdown.test.mjs.map +1 -0
  92. package/dist/tsup.cjs +14 -1
  93. package/dist/tsup.d.cts.map +1 -1
  94. package/dist/tsup.d.mts.map +1 -1
  95. package/dist/tsup.mjs +9 -1
  96. package/dist/tsup.mjs.map +1 -1
  97. package/dist/tsup.test.cjs +23 -0
  98. package/dist/tsup.test.d.cts +1 -0
  99. package/dist/tsup.test.d.mts +2 -0
  100. package/dist/tsup.test.mjs +25 -0
  101. package/dist/tsup.test.mjs.map +1 -0
  102. package/dist/types.cjs +13 -0
  103. package/dist/types.mjs +8 -1
  104. package/dist/types.mjs.map +1 -0
  105. package/dist/types.test.cjs +23 -0
  106. package/dist/types.test.d.cts +1 -0
  107. package/dist/types.test.d.mts +2 -0
  108. package/dist/types.test.mjs +25 -0
  109. package/dist/types.test.mjs.map +1 -0
  110. package/dist/unloader.cjs +13 -1
  111. package/dist/unloader.d.cts.map +1 -1
  112. package/dist/unloader.d.mts.map +1 -1
  113. package/dist/unloader.mjs +7 -1
  114. package/dist/unloader.mjs.map +1 -1
  115. package/dist/unloader.test.cjs +23 -0
  116. package/dist/unloader.test.d.cts +1 -0
  117. package/dist/unloader.test.d.mts +2 -0
  118. package/dist/unloader.test.mjs +25 -0
  119. package/dist/unloader.test.mjs.map +1 -0
  120. package/dist/unplugin.cjs +8 -0
  121. package/dist/unplugin.d.cts.map +1 -1
  122. package/dist/unplugin.d.mts.map +1 -1
  123. package/dist/unplugin.mjs +4 -1
  124. package/dist/unplugin.mjs.map +1 -1
  125. package/dist/unplugin.test.cjs +23 -0
  126. package/dist/unplugin.test.d.cts +1 -0
  127. package/dist/unplugin.test.d.mts +2 -0
  128. package/dist/unplugin.test.mjs +25 -0
  129. package/dist/unplugin.test.mjs.map +1 -0
  130. package/dist/vite.d.cts.map +1 -1
  131. package/dist/vite.d.mts.map +1 -1
  132. package/dist/vite.test.cjs +26 -0
  133. package/dist/vite.test.d.cts +1 -0
  134. package/dist/vite.test.d.mts +2 -0
  135. package/dist/vite.test.mjs +28 -0
  136. package/dist/vite.test.mjs.map +1 -0
  137. package/dist/webpack.cjs +13 -1
  138. package/dist/webpack.d.cts.map +1 -1
  139. package/dist/webpack.d.mts.map +1 -1
  140. package/dist/webpack.mjs +8 -1
  141. package/dist/webpack.mjs.map +1 -1
  142. package/dist/webpack.test.cjs +23 -0
  143. package/dist/webpack.test.d.cts +1 -0
  144. package/dist/webpack.test.d.mts +2 -0
  145. package/dist/webpack.test.mjs +25 -0
  146. package/dist/webpack.test.mjs.map +1 -0
  147. package/package.json +77 -13
@@ -1 +1 @@
1
- {"version":3,"file":"rspack.mjs","names":[],"sources":["../src/rspack.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 { RspackOptionsNormalized } from \"@rspack/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createRspackPlugin, RspackCompiler } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [rspack](https://rspack.rs/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Partial<RspackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n external: context.config.resolve.external,\n noExternal: [\n ...(context.config.resolve.noExternal ?? []),\n ...(context.builtins ?? [])\n ],\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle,\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 recordsInputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n cache: context.config.mode === \"development\",\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n } as Partial<RspackOptionsNormalized>;\n}\n\n/**\n * Creates a Rspack plugin factory that generates a plugin instance.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n * import { createRspackFactory } from \"@powerlines/unplugin/rspack\";\n *\n * const powerlinesPlugin = createRspackFactory({ 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 Rspack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rspack build.\n */\nexport function createRspackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rspack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rspack(compiler: RspackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesRspackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as RspackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Rspack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rspack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createRspackPlugin(createRspackFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eACd,SACkC;CAClC,OAAO;EACL,QAAQ,EACN,MAAM,QAAQ,OAAO,OAAO,KAC9B;EACA,MAAM,QAAQ,OAAO;EACrB,SAAS,EACP,OAAO,QAAQ,MACjB;EACA,UAAU,QAAQ,OAAO,QAAQ;EACjC,YAAY,CACV,GAAI,QAAQ,OAAO,QAAQ,cAAc,CAAC,GAC1C,GAAI,QAAQ,YAAY,CAAC,CAC3B;EACA,uBAAuB,QAAQ,OAAO,QAAQ;EAC9C,MACE,QAAQ,OAAO,aAAa,SACxB;GACE,WAAW;GACX,YAAY;GACZ,QAAQ;EACV,IACA;EACN,MACE,QAAQ,OAAO,SAAS,gBACnB,gBACA;EACP,kBAAkB,UAChB,QAAQ,WACR,UACA,sBACF;EACA,mBAAmB,UACjB,QAAQ,WACR,UACA,sBACF;EACA,SAAS,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI;EAC1D,OAAO,QAAQ,OAAO,SAAS;EAC/B,SAAS,QAAQ,OAAO,OAAO,YAAY,eAAe;EAC1D,cAAc,EACZ,UAAU,QAAQ,OAAO,OAAO,OAClC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,oBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAS,IAAG,aAC9D,SAAS;EACP,GAAI;EACJ,OAAO,UAA0B;GAC/B,SAAS,MAAM,UAAU,IAAI,2BAA0B,aAAY;IACjE,SAAS,UAAU,KACjB,eAAe,SAAS,OAAO,GAC/B,SAAS,OACX;GACF,CAAC;EACH;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"rspack.mjs","names":[],"sources":["../src/rspack.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 { RspackOptionsNormalized } from \"@rspack/core\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { createRspackPlugin, RspackCompiler } from \"unplugin\";\nimport {\n createUnpluginFactory,\n UnpluginFactoryDecorator,\n UnpluginFactoryOptions\n} from \"./unplugin\";\n\n/**\n * Resolves the options for [rspack](https://rspack.rs/).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Partial<RspackOptionsNormalized> {\n return {\n output: {\n path: context.config.output.path\n },\n name: context.config.name,\n resolve: {\n alias: context.alias\n },\n external: context.config.resolve.external,\n noExternal: [\n ...(context.config.resolve.noExternal ?? []),\n ...(context.builtins ?? [])\n ],\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle,\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 recordsInputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n recordsOutputPath: joinPaths(\n context.cachePath,\n \"rspack\",\n \".rspack-records.json\"\n ),\n context: joinPaths(context.config.cwd, context.config.root),\n cache: context.config.mode === \"development\",\n devtool: context.config.output.sourceMap ? \"source-map\" : false,\n optimization: {\n minimize: context.config.output.minify\n }\n } as Partial<RspackOptionsNormalized>;\n}\n\n/**\n * Creates a Rspack plugin factory that generates a plugin instance.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n * import { createRspackFactory } from \"@powerlines/unplugin/rspack\";\n *\n * const powerlinesPlugin = createRspackFactory({ 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 Rspack plugin instance when called. The generated plugin will invoke the Powerlines API hooks during the build process, allowing you to integrate Powerlines into your Rspack build.\n */\nexport function createRspackFactory<TContext extends ExecutionContext>(\n options: Omit<UnpluginFactoryOptions, \"variant\"> = {},\n decorate: UnpluginFactoryDecorator<TContext> = options => options\n) {\n return createUnpluginFactory({ ...options, variant: \"rspack\" }, unplugin =>\n decorate({\n ...(unplugin as UnpluginOptions<TContext>),\n rspack(compiler: RspackCompiler) {\n compiler.hooks.beforeRun.tap(\"PowerlinesRspackPlugin\", compiler => {\n compiler.options = defu(\n resolveOptions(unplugin.context),\n compiler.options\n ) as RspackOptionsNormalized;\n });\n }\n })\n );\n}\n\n/**\n * An Rspack plugin that will invoke the Powerlines API hooks during the build process.\n *\n * @see https://rspack.dev/concepts/plugins\n *\n * @example\n * ```ts\n * // rspack.config.ts\n *\n * import powerlines from \"@powerlines/unplugin/rspack\";\n *\n * export default {\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * }\n * ```\n */\nexport const plugin = createRspackPlugin(createRspackFactory());\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,eACd,SACkC;CAClC,OAAO;EACL,QAAQ,EACN,MAAM,QAAQ,OAAO,OAAO,KAC9B;EACA,MAAM,QAAQ,OAAO;EACrB,SAAS,EACP,OAAO,QAAQ,MACjB;EACA,UAAU,QAAQ,OAAO,QAAQ;EACjC,YAAY,CACV,GAAI,QAAQ,OAAO,QAAQ,cAAc,CAAC,GAC1C,GAAI,QAAQ,YAAY,CAAC,CAC3B;EACA,uBAAuB,QAAQ,OAAO,QAAQ;EAC9C,MACE,QAAQ,OAAO,aAAa,SACxB;GACE,WAAW;GACX,YAAY;GACZ,QAAQ;EACV,IACA;EACN,MACE,QAAQ,OAAO,SAAS,gBACnB,gBACA;EACP,kBAAkB,UAChB,QAAQ,WACR,UACA,sBACF;EACA,mBAAmB,UACjB,QAAQ,WACR,UACA,sBACF;EACA,SAAS,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI;EAC1D,OAAO,QAAQ,OAAO,SAAS;EAC/B,SAAS,QAAQ,OAAO,OAAO,YAAY,eAAe;EAC1D,cAAc,EACZ,UAAU,QAAQ,OAAO,OAAO,OAClC;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,oBACd,UAAmD,CAAC,GACpD,YAA+C,YAAW,SAC1D;CACA,OAAO,sBAAsB;EAAE,GAAG;EAAS,SAAS;CAAS,IAAG,aAC9D,SAAS;EACP,GAAI;EACJ,OAAO,UAA0B;GAC/B,SAAS,MAAM,UAAU,IAAI,2BAA0B,aAAY;IACjE,SAAS,UAAU,KACjB,eAAe,SAAS,OAAO,GAC/B,SAAS,OACX;GACF,CAAC;EACH;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,SAAS,mBAAmB,oBAAoB,CAAC"}
@@ -0,0 +1,23 @@
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
+
9
+ const require_rspack = require('./rspack.cjs');
10
+ let vitest = require("vitest");
11
+
12
+ //#region src/rspack.test.ts
13
+ (0, vitest.describe)("devkit/unplugin/src/rspack.ts", () => {
14
+ (0, vitest.it)("loads module exports", () => {
15
+ (0, vitest.expect)(require_rspack.rspack_exports).toBeDefined();
16
+ (0, vitest.expect)(typeof require_rspack.rspack_exports).toBe("object");
17
+ });
18
+ (0, vitest.it)("has at least one runtime export", () => {
19
+ (0, vitest.expect)(Object.keys(require_rspack.rspack_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
@@ -0,0 +1,25 @@
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
+
9
+ import { rspack_exports } from "./rspack.mjs";
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ //#region src/rspack.test.ts
13
+ describe("devkit/unplugin/src/rspack.ts", () => {
14
+ it("loads module exports", () => {
15
+ expect(rspack_exports).toBeDefined();
16
+ expect(typeof rspack_exports).toBe("object");
17
+ });
18
+ it("has at least one runtime export", () => {
19
+ expect(Object.keys(rspack_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
24
+ export { };
25
+ //# sourceMappingURL=rspack.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rspack.test.mjs","names":["moduleExports"],"sources":["../src/rspack.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./rspack\";\n\ndescribe(\"devkit/unplugin/src/rspack.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,uCAAuC;CAC9C,GAAG,8BAA8B;EAC/B,OAAOA,cAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,cAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,cAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
package/dist/tsdown.cjs CHANGED
@@ -23,6 +23,15 @@ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-stri
23
23
  let _stryke_path_glob_to_regex = require("@stryke/path/glob-to-regex");
24
24
 
25
25
  //#region src/tsdown.ts
26
+ var tsdown_exports = /* @__PURE__ */ require_runtime.__exportAll({
27
+ DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
28
+ default: () => plugin,
29
+ getDependencyConfig: () => getDependencyConfig,
30
+ plugin: () => plugin,
31
+ resolveFormat: () => resolveFormat,
32
+ resolveFromFormat: () => resolveFromFormat,
33
+ resolveOptions: () => resolveOptions
34
+ });
26
35
  /**
27
36
  * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
28
37
  *
@@ -222,4 +231,10 @@ exports.plugin = plugin;
222
231
  exports.getDependencyConfig = getDependencyConfig;
223
232
  exports.resolveFormat = resolveFormat;
224
233
  exports.resolveFromFormat = resolveFromFormat;
225
- exports.resolveOptions = resolveOptions;
234
+ exports.resolveOptions = resolveOptions;
235
+ Object.defineProperty(exports, 'tsdown_exports', {
236
+ enumerable: true,
237
+ get: function () {
238
+ return tsdown_exports;
239
+ }
240
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"tsdown.d.cts","names":[],"sources":["../src/tsdown.ts"],"mappings":";;;;;;;;;AAgDA;;;;iBAAgB,mBAAA,kBAAqC,iBAAA,CAAA,CACnD,OAAA,EAAS,QAAA,GACR,yBAAA;AAAA,cAqBU,eAAA,EAAiB,OAAO,CAAC,YAAA;;;;;;;iBAatB,aAAA,CAAc,OAAA,GAAU,MAAA,GAAS,MAAA,KAAW,QAAA;;AAlChC;AAqB5B;;;;iBAiCgB,iBAAA,CACd,OAAA,GAAU,QAAA,GAAe,QAAA,KACxB,MAAA;AAtBH;;;;;;AAAA,iBA2DgB,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,YAAA;;;;;;;AA7DqE;AAoBxE;;;;;;;;;;;;;AAES;AAqCT;;iBAuLgB,MAAA,CAAO,OAAA,GAAS,YAAA,GAAkB,YAAU"}
1
+ {"version":3,"file":"tsdown.d.cts","names":[],"sources":["../src/tsdown.ts"],"mappings":";;;;;;;;;AAgDA;;;;iBAAgB,mBAAA,kBAAqC,iBAAA,EACnD,OAAA,EAAS,QAAA,GACR,yBAAA;AAAA,cAqBU,eAAA,EAAiB,OAAO,CAAC,YAAA;;;;;;;iBAatB,aAAA,CAAc,OAAA,GAAU,MAAA,GAAS,MAAA,KAAW,QAAA;;AAlChC;AAqB5B;;;;iBAiCgB,iBAAA,CACd,OAAA,GAAU,QAA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alD;;;;;;;;;;;;;AAAwE;AAoBxE;;;;;;;;AAjCkD,iBA+PlC,MAAA,CAAO,OAAA,GAAS,YAAA,GAAkB,YAAU"}
package/dist/tsdown.mjs CHANGED
@@ -6,6 +6,7 @@ import __tsdown_shims_url from 'node:url'
6
6
  const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
7
  const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
8
 
9
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
9
10
  import plugin$1 from "./rolldown.mjs";
10
11
  import { appendPath } from "@stryke/path/append";
11
12
  import { relativePath } from "@stryke/path/file-path-fns";
@@ -20,6 +21,15 @@ import { isSetString } from "@stryke/type-checks/is-set-string";
20
21
  import { globToRegex } from "@stryke/path/glob-to-regex";
21
22
 
22
23
  //#region src/tsdown.ts
24
+ var tsdown_exports = /* @__PURE__ */ __exportAll({
25
+ DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
26
+ default: () => plugin,
27
+ getDependencyConfig: () => getDependencyConfig,
28
+ plugin: () => plugin,
29
+ resolveFormat: () => resolveFormat,
30
+ resolveFromFormat: () => resolveFromFormat,
31
+ resolveOptions: () => resolveOptions
32
+ });
23
33
  /**
24
34
  * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.
25
35
  *
@@ -213,5 +223,5 @@ function plugin(options = {}) {
213
223
  }
214
224
 
215
225
  //#endregion
216
- export { DEFAULT_OPTIONS, plugin as default, plugin, getDependencyConfig, resolveFormat, resolveFromFormat, resolveOptions };
226
+ export { DEFAULT_OPTIONS, plugin as default, plugin, getDependencyConfig, resolveFormat, resolveFromFormat, resolveOptions, tsdown_exports };
217
227
  //# sourceMappingURL=tsdown.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsdown.mjs","names":["_getDependencyConfig","rolldown"],"sources":["../src/tsdown.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 CopyConfig,\n ResolveConfig,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport type { GetDependencyConfigResult } from \"@powerlines/core/plugin-utils\";\nimport { getDependencyConfig as _getDependencyConfig } from \"@powerlines/core/plugin-utils\";\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { ModuleFormat } from \"rolldown\";\nimport { UserConfig as BuildOptions, Format as TsdownFormat } from \"tsdown\";\nimport type { UserConfig } from \"tsdown/config\";\nimport rolldown from \"./rolldown\";\nimport { UnpluginExecutionOptions } from \"./types\";\n\n/**\n * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.\n *\n * @param context - The build context.\n * @returns The dependency configuration.\n */\nexport function getDependencyConfig<TContext extends UnresolvedContext>(\n context: TContext\n): GetDependencyConfigResult {\n const { external, noExternal } = _getDependencyConfig(context);\n\n return {\n external:\n !external || external.length === 0\n ? undefined\n : external.map(ext =>\n isSetString(ext) && ext.includes(\"*\") ? globToRegex(ext) : ext\n ),\n noExternal:\n !noExternal || noExternal.length === 0\n ? undefined\n : noExternal.map(noExt =>\n isSetString(noExt) && noExt.includes(\"*\")\n ? globToRegex(noExt)\n : noExt\n )\n };\n}\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n platform: \"neutral\",\n target: \"esnext\",\n fixedExtension: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFormat(formats?: Format | Format[]): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = <TContext extends UnresolvedContext>(\n context: TContext,\n ...msgs: any[]\n) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .trim()\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .replaceAll(/^\\s+/g, \"\")\n .replaceAll(/\\s+$/g, \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): BuildOptions {\n const { external, noExternal } = getDependencyConfig(context);\n\n return defu(\n {\n name: context.config.name,\n cwd: appendPath(context.config.root, context.config.cwd),\n entry:\n context.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n context.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(context.config.root, \"src\")\n ),\n context.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.ts\"\n ),\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.tsx\"\n )\n ],\n exports: {\n customExports: (exports: Record<string, any>) => {\n const result = Object.fromEntries(\n Object.entries(exports).map(([key, value]) => {\n if (isSetString(value)) {\n return [key, value];\n }\n\n const currentExport = {} as Record<string, any>;\n if (isSetString(value.require)) {\n currentExport.require = {\n types: replaceExtension(value.require, \".d.cts\", {\n fullExtension: true\n }),\n default: value.require\n };\n }\n\n if (isSetString(value.import)) {\n currentExport.import = {\n types: replaceExtension(value.import, \".d.mts\", {\n fullExtension: true\n }),\n default: value.import\n };\n }\n\n if (!isSetObject(value.default)) {\n if (isSetObject(currentExport.import)) {\n currentExport.default = currentExport.import;\n } else if (isSetObject(currentExport.require)) {\n currentExport.default = currentExport.require;\n }\n }\n\n return [key, currentExport];\n })\n );\n\n return Object.keys(result)\n .sort()\n .reduce(\n (ret, key) => {\n ret[key] = result[key];\n return ret;\n },\n {} as Record<string, any>\n );\n }\n },\n define: context.config.define,\n inputOptions: {\n transform: {\n define: context.config.define,\n inject: context.config.inject,\n typescript: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target\n }\n }\n },\n deps: {\n neverBundle: external,\n alwaysBundle: context.config.resolve.skipNodeModulesBundle\n ? undefined\n : noExternal,\n onlyBundle: context.config.resolve.skipNodeModulesBundle\n ? noExternal\n : undefined,\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle\n },\n alias: context.alias,\n resolve: {\n alias: context.alias\n },\n platform: context.config.platform,\n dts: context.config.output.dts,\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 format: resolveFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n nodeProtocol: context.config.output.nodeProtocol,\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n logLevel: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n customLogger: {\n level: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs))\n }\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * A Tsdown configuration function that integrates Powerlines into the build process.\n *\n * @see https://github.com/rolldown/tsdown\n *\n * @example\n * ```ts\n * // tsdown.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsdown\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsdown options to merge with the Powerlines configuration.\n * @returns The merged Tsdown configuration options.\n */\nexport function plugin(options: UserConfig = {}): UserConfig {\n return {\n ...options,\n entry: options.entry,\n plugins: [\n rolldown({\n ...options,\n output: {\n path: options.outDir,\n format: resolveFromFormat(\n options.format as ModuleFormat | ModuleFormat[]\n ),\n copy: {\n path: options.outDir!,\n assets: toArray(options.copy)\n .map(copy => {\n if (!copy) {\n return undefined;\n }\n if (isSetString(copy)) {\n return copy;\n }\n if (isFunction(copy)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based copy options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return {\n input: copy.from,\n output: copy.to\n };\n })\n .filter(Boolean) as CopyConfig[\"assets\"]\n }\n },\n resolve: {\n external: options.deps?.neverBundle\n ? (toArray(options.deps?.neverBundle)\n .map(external => {\n if (isFunction(external)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based external options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return external;\n })\n .filter(Boolean) as ResolveConfig[\"external\"])\n : undefined,\n noExternal:\n (options.deps?.skipNodeModulesBundle && options.deps?.onlyBundle) ||\n (!options.deps?.skipNodeModulesBundle && options.deps?.alwaysBundle)\n ? (toArray(\n options.deps?.skipNodeModulesBundle\n ? options.deps?.onlyBundle\n : options.deps?.alwaysBundle\n )\n .map(noExternal => {\n if (isFunction(noExternal)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based noExternal options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return noExternal;\n })\n .filter(Boolean) as ResolveConfig[\"noExternal\"])\n : undefined\n },\n tsconfig: isSetString(options.tsconfig) ? options.tsconfig : undefined\n } as UnpluginExecutionOptions)\n ]\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,EAAE,UAAU,eAAeA,sBAAqB,OAAO;CAE7D,OAAO;EACL,UACE,CAAC,YAAY,SAAS,WAAW,IAC7B,SACA,SAAS,KAAI,QACX,YAAY,G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,IAAI,QAAQ,WAAW;EAC/D,CAA6B,CAC/B;CACF;AACF"}
1
+ {"version":3,"file":"tsdown.mjs","names":["_getDependencyConfig","rolldown"],"sources":["../src/tsdown.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 CopyConfig,\n ResolveConfig,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport type { GetDependencyConfigResult } from \"@powerlines/core/plugin-utils\";\nimport { getDependencyConfig as _getDependencyConfig } from \"@powerlines/core/plugin-utils\";\nimport type { Format } from \"@storm-software/build-tools/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { globToRegex } from \"@stryke/path/glob-to-regex\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport { ModuleFormat } from \"rolldown\";\nimport { UserConfig as BuildOptions, Format as TsdownFormat } from \"tsdown\";\nimport type { UserConfig } from \"tsdown/config\";\nimport rolldown from \"./rolldown\";\nimport { UnpluginExecutionOptions } from \"./types\";\n\n/**\n * Get the {@link ResolveConfig.external | external} and {@link ResolveConfig.noExternal | noExternal} dependencies for the build configuration.\n *\n * @param context - The build context.\n * @returns The dependency configuration.\n */\nexport function getDependencyConfig<TContext extends UnresolvedContext>(\n context: TContext\n): GetDependencyConfigResult {\n const { external, noExternal } = _getDependencyConfig(context);\n\n return {\n external:\n !external || external.length === 0\n ? undefined\n : external.map(ext =>\n isSetString(ext) && ext.includes(\"*\") ? globToRegex(ext) : ext\n ),\n noExternal:\n !noExternal || noExternal.length === 0\n ? undefined\n : noExternal.map(noExt =>\n isSetString(noExt) && noExt.includes(\"*\")\n ? globToRegex(noExt)\n : noExt\n )\n };\n}\n\nexport const DEFAULT_OPTIONS: Partial<BuildOptions> = {\n platform: \"neutral\",\n target: \"esnext\",\n fixedExtension: true,\n clean: false\n} as const;\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFormat(formats?: Format | Format[]): TsdownFormat[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n default:\n return \"esm\";\n }\n });\n}\n\n/**\n * Resolves the entry options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param formats - The formats to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveFromFormat(\n formats?: TsdownFormat | TsdownFormat[]\n): Format[] {\n return toArray(formats).map(format => {\n switch (format) {\n case \"cjs\":\n case \"commonjs\":\n return \"cjs\";\n case \"iife\":\n return \"iife\";\n case \"esm\":\n case \"es\":\n case \"module\":\n case \"umd\":\n default:\n return \"esm\";\n }\n });\n}\n\nconst formatMessage = <TContext extends UnresolvedContext>(\n context: TContext,\n ...msgs: any[]\n) =>\n msgs\n .filter(Boolean)\n .join(\" \")\n .trim()\n .replace(new RegExp(`\\\\[${context.config.name}\\\\]`, \"g\"), \"\")\n .replaceAll(/^\\s+/g, \"\")\n .replaceAll(/\\s+$/g, \"\")\n .trim();\n\n/**\n * Resolves the options for [tsdown](https://github.com/rolldown/tsdown).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): BuildOptions {\n const { external, noExternal } = getDependencyConfig(context);\n\n return defu(\n {\n name: context.config.name,\n cwd: appendPath(context.config.root, context.config.cwd),\n entry:\n context.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n context.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(context.config.root, \"src\")\n ),\n context.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.ts\"\n ),\n joinPaths(\n context.config.cwd,\n context.config.root,\n \"src\",\n \"**/*.tsx\"\n )\n ],\n exports: {\n customExports: (exports: Record<string, any>) => {\n const result = Object.fromEntries(\n Object.entries(exports).map(([key, value]) => {\n if (isSetString(value)) {\n return [key, value];\n }\n\n const currentExport = {} as Record<string, any>;\n if (isSetString(value.require)) {\n currentExport.require = {\n types: replaceExtension(value.require, \".d.cts\", {\n fullExtension: true\n }),\n default: value.require\n };\n }\n\n if (isSetString(value.import)) {\n currentExport.import = {\n types: replaceExtension(value.import, \".d.mts\", {\n fullExtension: true\n }),\n default: value.import\n };\n }\n\n if (!isSetObject(value.default)) {\n if (isSetObject(currentExport.import)) {\n currentExport.default = currentExport.import;\n } else if (isSetObject(currentExport.require)) {\n currentExport.default = currentExport.require;\n }\n }\n\n return [key, currentExport];\n })\n );\n\n return Object.keys(result)\n .sort()\n .reduce(\n (ret, key) => {\n ret[key] = result[key];\n return ret;\n },\n {} as Record<string, any>\n );\n }\n },\n define: context.config.define,\n inputOptions: {\n transform: {\n define: context.config.define,\n inject: context.config.inject,\n typescript: {\n target: context.tsconfig.tsconfigJson?.compilerOptions?.target\n }\n }\n },\n deps: {\n neverBundle: external,\n alwaysBundle: context.config.resolve.skipNodeModulesBundle\n ? undefined\n : noExternal,\n onlyBundle: context.config.resolve.skipNodeModulesBundle\n ? noExternal\n : undefined,\n skipNodeModulesBundle: context.config.resolve.skipNodeModulesBundle\n },\n alias: context.alias,\n resolve: {\n alias: context.alias\n },\n platform: context.config.platform,\n dts: context.config.output.dts,\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 format: resolveFormat(context.config.output.format).filter(Boolean),\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n nodeProtocol: context.config.output.nodeProtocol,\n debug: context.config.mode === \"development\",\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n logLevel: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n customLogger: {\n level: context.config.logLevel.general === \"trace\" ? \"debug\" : \"error\",\n info: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs)),\n warn: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n warnOnce: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.warn(formatMessage(context, ...msgs)),\n error: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.error(formatMessage(context, ...msgs)),\n success: (...msgs: any[]) =>\n isSetString(formatMessage(context, ...msgs).replace(/\\s+/g, \"\")) &&\n context.trace(formatMessage(context, ...msgs))\n }\n },\n DEFAULT_OPTIONS\n ) as BuildOptions;\n}\n\n/**\n * A Tsdown configuration function that integrates Powerlines into the build process.\n *\n * @see https://github.com/rolldown/tsdown\n *\n * @example\n * ```ts\n * // tsdown.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsdown\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsdown options to merge with the Powerlines configuration.\n * @returns The merged Tsdown configuration options.\n */\nexport function plugin(options: UserConfig = {}): UserConfig {\n return {\n ...options,\n entry: options.entry,\n plugins: [\n rolldown({\n ...options,\n output: {\n path: options.outDir,\n format: resolveFromFormat(\n options.format as ModuleFormat | ModuleFormat[]\n ),\n copy: {\n path: options.outDir!,\n assets: toArray(options.copy)\n .map(copy => {\n if (!copy) {\n return undefined;\n }\n if (isSetString(copy)) {\n return copy;\n }\n if (isFunction(copy)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based copy options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return {\n input: copy.from,\n output: copy.to\n };\n })\n .filter(Boolean) as CopyConfig[\"assets\"]\n }\n },\n resolve: {\n external: options.deps?.neverBundle\n ? (toArray(options.deps?.neverBundle)\n .map(external => {\n if (isFunction(external)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based external options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return external;\n })\n .filter(Boolean) as ResolveConfig[\"external\"])\n : undefined,\n noExternal:\n (options.deps?.skipNodeModulesBundle && options.deps?.onlyBundle) ||\n (!options.deps?.skipNodeModulesBundle && options.deps?.alwaysBundle)\n ? (toArray(\n options.deps?.skipNodeModulesBundle\n ? options.deps?.onlyBundle\n : options.deps?.alwaysBundle\n )\n .map(noExternal => {\n if (isFunction(noExternal)) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Function-based noExternal options are not supported in Powerlines.\"\n );\n return undefined;\n }\n return noExternal;\n })\n .filter(Boolean) as ResolveConfig[\"noExternal\"])\n : undefined\n },\n tsconfig: isSetString(options.tsconfig) ? options.tsconfig : undefined\n } as UnpluginExecutionOptions)\n ]\n };\n}\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,EA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;MAE1B,QAAQ,KACN,oEACF;MACA;KACF;KACA,OAAO;IACT,CAAC,EACA,OAAO,OAAO,IACjB;GACR;GACA,UAAU,YAAY,QAAQ,QAAQ,IAAI,QAAQ,WAAW;EAC/D,CAA6B,CAC/B;CACF;AACF"}
@@ -0,0 +1,23 @@
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
+
9
+ const require_tsdown = require('./tsdown.cjs');
10
+ let vitest = require("vitest");
11
+
12
+ //#region src/tsdown.test.ts
13
+ (0, vitest.describe)("devkit/unplugin/src/tsdown.ts", () => {
14
+ (0, vitest.it)("loads module exports", () => {
15
+ (0, vitest.expect)(require_tsdown.tsdown_exports).toBeDefined();
16
+ (0, vitest.expect)(typeof require_tsdown.tsdown_exports).toBe("object");
17
+ });
18
+ (0, vitest.it)("has at least one runtime export", () => {
19
+ (0, vitest.expect)(Object.keys(require_tsdown.tsdown_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
@@ -0,0 +1,25 @@
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
+
9
+ import { tsdown_exports } from "./tsdown.mjs";
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ //#region src/tsdown.test.ts
13
+ describe("devkit/unplugin/src/tsdown.ts", () => {
14
+ it("loads module exports", () => {
15
+ expect(tsdown_exports).toBeDefined();
16
+ expect(typeof tsdown_exports).toBe("object");
17
+ });
18
+ it("has at least one runtime export", () => {
19
+ expect(Object.keys(tsdown_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
24
+ export { };
25
+ //# sourceMappingURL=tsdown.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsdown.test.mjs","names":["moduleExports"],"sources":["../src/tsdown.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./tsdown\";\n\ndescribe(\"devkit/unplugin/src/tsdown.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,uCAAuC;CAC9C,GAAG,8BAA8B;EAC/B,OAAOA,cAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,cAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,cAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
package/dist/tsup.cjs CHANGED
@@ -18,6 +18,13 @@ let _storm_software_tsup_constants = require("@storm-software/tsup/constants");
18
18
  let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
19
19
 
20
20
  //#region src/tsup.ts
21
+ var tsup_exports = /* @__PURE__ */ require_runtime.__exportAll({
22
+ DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
23
+ default: () => withPlugin,
24
+ resolveEntry: () => resolveEntry,
25
+ resolveOptions: () => resolveOptions,
26
+ withPlugin: () => withPlugin
27
+ });
21
28
  const DEFAULT_OPTIONS = {
22
29
  ..._storm_software_tsup_constants.DEFAULT_BUILD_OPTIONS,
23
30
  target: "esnext",
@@ -121,4 +128,10 @@ exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
121
128
  exports.default = withPlugin;
122
129
  exports.withPlugin = withPlugin;
123
130
  exports.resolveEntry = resolveEntry;
124
- exports.resolveOptions = resolveOptions;
131
+ exports.resolveOptions = resolveOptions;
132
+ Object.defineProperty(exports, 'tsup_exports', {
133
+ enumerable: true,
134
+ get: function () {
135
+ return tsup_exports;
136
+ }
137
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"tsup.d.cts","names":[],"sources":["../src/tsup.ts"],"mappings":";;;;;;cAiCa,eAAA,EAAiB,OAAO,CAAC,SAAA;;AAAtC;;;;AAA6C;AAwB7C;iBAAgB,YAAA,kBAA8B,iBAAA,CAAA,CAC5C,OAAA,EAAS,QAAA,EACT,WAAA,EAAa,0BAAA,gBACZ,KAAA;;;;;;;iBAca,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,UAAA,QAAkB,gBAAA;;;;;;;;;AAhBb;AAcR;;;;;;;;;;;;;;iBAwFgB,UAAA,CAAW,OAAA,EAAS,SAAA,GAAU,SAAO"}
1
+ {"version":3,"file":"tsup.d.cts","names":[],"sources":["../src/tsup.ts"],"mappings":";;;;;;cAiCa,eAAA,EAAiB,OAAO,CAAC,SAAA;;AAAtC;;;;AAA6C;AAwB7C;iBAAgB,YAAA,kBAA8B,iBAAA,EAC5C,OAAA,EAAS,QAAA,EACT,WAAA,EAAa,0BAAA,gBACZ,KAAA;;;;;;;iBAca,cAAA,kBAAgC,iBAAA,EAC9C,OAAA,EAAS,QAAA,GACR,UAAA,QAAkB,gBAAA;;;;;;;;;AAhBb;AAcR;;;;;;;;;;;;;;iBAwFgB,UAAA,CAAW,OAAA,EAAS,SAAA,GAAU,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"tsup.d.mts","names":[],"sources":["../src/tsup.ts"],"mappings":";;;;;;;;cAiCa,eAAA,EAAiB,OAAO,CAAC,SAAA;;;;;;;;iBAwBtB,YAAA,kBAA8B,iBAAA,CAAA,CAC5C,OAAA,EAAS,QAAA,EACT,WAAA,EAAa,0BAAA,gBACZ,KAAA;;AA3BH;;;;AAA6C;iBAyC7B,cAAA,kBAAgC,iBAAA,CAAA,CAC9C,OAAA,EAAS,QAAA,GACR,UAAA,QAAkB,gBAAA;;;;;;;;;;;;;;;;;AAhBb;AAcR;;;;;;iBAwFgB,UAAA,CAAW,OAAA,EAAS,SAAA,GAAU,SAAO"}
1
+ {"version":3,"file":"tsup.d.mts","names":[],"sources":["../src/tsup.ts"],"mappings":";;;;;;;;cAiCa,eAAA,EAAiB,OAAO,CAAC,SAAA;;;;;;;;iBAwBtB,YAAA,kBAA8B,iBAAA,EAC5C,OAAA,EAAS,QAAA,EACT,WAAA,EAAa,0BAAA,gBACZ,KAAA;;AA3BH;;;;AAA6C;iBAyC7B,cAAA,kBAAgC,iBAAA,EAC9C,OAAA,EAAS,QAAA,GACR,UAAA,QAAkB,gBAAA;;;;;;;;;;;;;;;;;AAhBb;AAcR;;;;;;iBAwFgB,UAAA,CAAW,OAAA,EAAS,SAAA,GAAU,SAAO"}
package/dist/tsup.mjs CHANGED
@@ -6,6 +6,7 @@ import __tsdown_shims_url from 'node:url'
6
6
  const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
7
  const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
8
 
9
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
9
10
  import plugin, { resolveEntry as resolveEntry$1 } from "./esbuild.mjs";
10
11
  import { appendPath } from "@stryke/path/append";
11
12
  import { relativePath } from "@stryke/path/file-path-fns";
@@ -15,6 +16,13 @@ import { DEFAULT_BUILD_OPTIONS } from "@storm-software/tsup/constants";
15
16
  import { getUnique } from "@stryke/helpers/get-unique";
16
17
 
17
18
  //#region src/tsup.ts
19
+ var tsup_exports = /* @__PURE__ */ __exportAll({
20
+ DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
21
+ default: () => withPlugin,
22
+ resolveEntry: () => resolveEntry,
23
+ resolveOptions: () => resolveOptions,
24
+ withPlugin: () => withPlugin
25
+ });
18
26
  const DEFAULT_OPTIONS = {
19
27
  ...DEFAULT_BUILD_OPTIONS,
20
28
  target: "esnext",
@@ -114,5 +122,5 @@ function withPlugin(options) {
114
122
  }
115
123
 
116
124
  //#endregion
117
- export { DEFAULT_OPTIONS, withPlugin as default, withPlugin, resolveEntry, resolveOptions };
125
+ export { DEFAULT_OPTIONS, withPlugin as default, withPlugin, resolveEntry, resolveOptions, tsup_exports };
118
126
  //# sourceMappingURL=tsup.mjs.map
package/dist/tsup.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tsup.mjs","names":["resolveEsbuildEntry","esbuild"],"sources":["../src/tsup.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 ResolvedEntryFileReference,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { AssetGlob, Entry } from \"@storm-software/build-tools/types\";\nimport { resolveOptions as resolveOptionsBase } from \"@storm-software/tsup\";\nimport { DEFAULT_BUILD_OPTIONS } from \"@storm-software/tsup/constants\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport type { Options } from \"tsup\";\nimport esbuild, { resolveEntry as resolveEsbuildEntry } from \"./esbuild\";\n\nexport const DEFAULT_OPTIONS: Partial<Options> = {\n ...DEFAULT_BUILD_OPTIONS,\n target: \"esnext\",\n config: false,\n minify: true,\n sourcemap: false,\n cjsInterop: true,\n bundle: true,\n dts: true,\n shims: true,\n silent: true,\n treeshake: true,\n keepNames: true,\n splitting: true,\n banner: {}\n};\n\n/**\n * Resolves the entry options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveEntry<TContext extends UnresolvedContext>(\n context: TContext,\n entryPoints: ResolvedEntryFileReference[] | string[]\n): Entry {\n return resolveEsbuildEntry(context, entryPoints) as Entry;\n}\n\ntype TsupEsbuildOptionsHandler = NonNullable<Options[\"esbuildOptions\"]>;\ntype TsupEsbuildOptionsArgs = Parameters<TsupEsbuildOptionsHandler>;\ntype TsupEsbuildOptions = TsupEsbuildOptionsArgs[0];\n\n/**\n * Resolves the options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Parameters<typeof resolveOptionsBase>[0] {\n const result = defu(\n {\n entry: Object.fromEntries(\n Object.entries(resolveEntry(context, context.entry)).map(\n ([key, value]) => [key, appendPath(value, context.config.root)]\n )\n ),\n esbuildOptions: (options: TsupEsbuildOptions) => {\n options.alias = {\n ...context.alias,\n ...context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.paths[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n ...options.alias\n };\n },\n noExternal: context.builtins\n },\n {\n name: context.config.name,\n root: context.config.root,\n projectRoot: context.config.root,\n assets: context.config.output.copy\n ? (context.config.output.copy.assets as (string | AssetGlob)[])\n : undefined,\n resolveExtensions: context.config.resolve.extensions,\n outputPath: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: context.tsconfig.tsconfigFilePath,\n dts: {\n compilerOptions: context.tsconfig.tsconfigJson.compilerOptions\n },\n format: context.config.output.format,\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n verbose:\n context.config.logLevel.general === \"trace\" ||\n context.config.mode === \"development\",\n workspaceConfig: { workspaceRoot: context.config.cwd }\n },\n DEFAULT_OPTIONS\n );\n\n result.format = getUnique(toArray(result.format));\n return result as Parameters<typeof resolveOptionsBase>[0];\n}\n\n/**\n * A Tsup configuration function that integrates Powerlines into the build process.\n *\n * @see https://tsup.egoist.dev/#/config\n *\n * @example\n * ```ts\n * // tsup.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsup\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsup options to merge with the Powerlines configuration.\n * @returns The merged Tsup configuration options.\n */\nexport function withPlugin(options: Options): Options {\n return {\n ...options,\n esbuildPlugins: [...(options.esbuildPlugins ?? []), esbuild()]\n };\n}\n\nexport default withPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,MAAa,kBAAoC;CAC/C,GAAG;CACH,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,KAAK;CACL,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,QAAQ,CAAC;AACX;;;;;;;;AASA,SAAgB,aACd,SACA,aACO;CACP,OAAOA,eAAoB,SAAS,WAAW;AACjD;;;;;;;AAYA,SAAgB,eACd,SAC0C;CAC1C,MAAM,SAAS,KACb;EACE,OAAO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;EACL,GAAG;EACH,gBAAgB,CAAC,GAAI,QAAQ,kBAAkB,CAAC,GAAIC,OAAQ,CAAC;CAC/D;AACF"}
1
+ {"version":3,"file":"tsup.mjs","names":["resolveEsbuildEntry","esbuild"],"sources":["../src/tsup.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 ResolvedEntryFileReference,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { AssetGlob, Entry } from \"@storm-software/build-tools/types\";\nimport { resolveOptions as resolveOptionsBase } from \"@storm-software/tsup\";\nimport { DEFAULT_BUILD_OPTIONS } from \"@storm-software/tsup/constants\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport type { Options } from \"tsup\";\nimport esbuild, { resolveEntry as resolveEsbuildEntry } from \"./esbuild\";\n\nexport const DEFAULT_OPTIONS: Partial<Options> = {\n ...DEFAULT_BUILD_OPTIONS,\n target: \"esnext\",\n config: false,\n minify: true,\n sourcemap: false,\n cjsInterop: true,\n bundle: true,\n dts: true,\n shims: true,\n silent: true,\n treeshake: true,\n keepNames: true,\n splitting: true,\n banner: {}\n};\n\n/**\n * Resolves the entry options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveEntry<TContext extends UnresolvedContext>(\n context: TContext,\n entryPoints: ResolvedEntryFileReference[] | string[]\n): Entry {\n return resolveEsbuildEntry(context, entryPoints) as Entry;\n}\n\ntype TsupEsbuildOptionsHandler = NonNullable<Options[\"esbuildOptions\"]>;\ntype TsupEsbuildOptionsArgs = Parameters<TsupEsbuildOptionsHandler>;\ntype TsupEsbuildOptions = TsupEsbuildOptionsArgs[0];\n\n/**\n * Resolves the options for [tsup](https://github.com/egoist/tsup).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions<TContext extends UnresolvedContext>(\n context: TContext\n): Parameters<typeof resolveOptionsBase>[0] {\n const result = defu(\n {\n entry: Object.fromEntries(\n Object.entries(resolveEntry(context, context.entry)).map(\n ([key, value]) => [key, appendPath(value, context.config.root)]\n )\n ),\n esbuildOptions: (options: TsupEsbuildOptions) => {\n options.alias = {\n ...context.alias,\n ...context.builtins.reduce(\n (ret, id) => {\n const path = context.fs.paths[id];\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n ),\n ...options.alias\n };\n },\n noExternal: context.builtins\n },\n {\n name: context.config.name,\n root: context.config.root,\n projectRoot: context.config.root,\n assets: context.config.output.copy\n ? (context.config.output.copy.assets as (string | AssetGlob)[])\n : undefined,\n resolveExtensions: context.config.resolve.extensions,\n outputPath: relativePath(\n appendPath(context.config.root, context.config.cwd),\n context.config.output.path\n ),\n tsconfig: context.tsconfig.tsconfigFilePath,\n dts: {\n compilerOptions: context.tsconfig.tsconfigJson.compilerOptions\n },\n format: context.config.output.format,\n mode: context.config.mode,\n minify: context.config.output.minify,\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.output.sourceMap,\n silent:\n context.config.logLevel.general === \"silent\" ||\n context.config.mode === \"production\",\n verbose:\n context.config.logLevel.general === \"trace\" ||\n context.config.mode === \"development\",\n workspaceConfig: { workspaceRoot: context.config.cwd }\n },\n DEFAULT_OPTIONS\n );\n\n result.format = getUnique(toArray(result.format));\n return result as Parameters<typeof resolveOptionsBase>[0];\n}\n\n/**\n * A Tsup configuration function that integrates Powerlines into the build process.\n *\n * @see https://tsup.egoist.dev/#/config\n *\n * @example\n * ```ts\n * // tsup.config.ts\n * import withPowerlines from \"@powerlines/unplugin/tsup\";\n *\n * export default withPowerlines({\n * entry: [\"src/index.ts\"],\n * format: [\"cjs\", \"esm\"],\n * dts: true,\n * sourcemap: true,\n * clean: true,\n * });\n *\n * ```\n *\n * @param options - The Tsup options to merge with the Powerlines configuration.\n * @returns The merged Tsup configuration options.\n */\nexport function withPlugin(options: Options): Options {\n return {\n ...options,\n esbuildPlugins: [...(options.esbuildPlugins ?? []), esbuild()]\n };\n}\n\nexport default withPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,kBAAoC;CAC/C,GAAG;CACH,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,KAAK;CACL,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,QAAQ,CAAC;AACX;;;;;;;;AASA,SAAgB,aACd,SACA,aACO;CACP,OAAOA,eAAoB,SAAS,WAAW;AACjD;;;;;;;AAYA,SAAgB,eACd,SAC0C;CAC1C,MAAM,SAAS,KACb;EACE,OAAO,OAAO,YACZ,OAAO,QAAQ,aAAa,SAAS,QAAQ,KAAK,CAAC,EAAE,KAClD,CAAC,KAAK,WAAW,CAAC,KAAK,WAAW,OAAO,QAAQ,OAAO,IAAI,CAAC,CAChE,CACF;EACA,iBAAiB,YAAgC;GAC/C,QAAQ,QAAQ;IACd,GAAG,QAAQ;IACX,GAAG,QAAQ,SAAS,QACjB,KAAK,OAAO;KACX,MAAM,OAAO,QAAQ,GAAG,MAAM;KAC9B,IAAI,MACF,IAAI,MAAM;KAGZ,OAAO;IACT,GACA,CAAC,CACH;IACA,GAAG,QAAQ;GACb;EACF;EACA,YAAY,QAAQ;CACtB,GACA;EACE,MAAM,QAAQ,OAAO;EACrB,MAAM,QAAQ,OAAO;EACrB,aAAa,QAAQ,OAAO;EAC5B,QAAQ,QAAQ,OAAO,OAAO,OACzB,QAAQ,OAAO,OAAO,KAAK,SAC5B;EACJ,mBAAmB,QAAQ,OAAO,QAAQ;EAC1C,YAAY,aACV,WAAW,QAAQ,OAAO,MAAM,QAAQ,OAAO,GAAG,GAClD,QAAQ,OAAO,OAAO,IACxB;EACA,UAAU,QAAQ,SAAS;EAC3B,KAAK,EACH,iBAAiB,QAAQ,SAAS,aAAa,gBACjD;EACA,QAAQ,QAAQ,OAAO,OAAO;EAC9B,MAAM,QAAQ,OAAO;EACrB,QAAQ,QAAQ,OAAO,OAAO;EAC9B,UAAU,QAAQ,OAAO,SAAS;EAClC,WAAW,QAAQ,OAAO,OAAO;EACjC,QACE,QAAQ,OAAO,SAAS,YAAY,YACpC,QAAQ,OAAO,SAAS;EAC1B,SACE,QAAQ,OAAO,SAAS,YAAY,WACpC,QAAQ,OAAO,SAAS;EAC1B,iBAAiB,EAAE,eAAe,QAAQ,OAAO,IAAI;CACvD,GACA,eACF;CAEA,OAAO,SAAS,UAAU,QAAQ,OAAO,MAAM,CAAC;CAChD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,WAAW,SAA2B;CACpD,OAAO;EACL,GAAG;EACH,gBAAgB,CAAC,GAAI,QAAQ,kBAAkB,CAAC,GAAIC,OAAQ,CAAC;CAC/D;AACF"}
@@ -0,0 +1,23 @@
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
+
9
+ const require_tsup = require('./tsup.cjs');
10
+ let vitest = require("vitest");
11
+
12
+ //#region src/tsup.test.ts
13
+ (0, vitest.describe)("devkit/unplugin/src/tsup.ts", () => {
14
+ (0, vitest.it)("loads module exports", () => {
15
+ (0, vitest.expect)(require_tsup.tsup_exports).toBeDefined();
16
+ (0, vitest.expect)(typeof require_tsup.tsup_exports).toBe("object");
17
+ });
18
+ (0, vitest.it)("has at least one runtime export", () => {
19
+ (0, vitest.expect)(Object.keys(require_tsup.tsup_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
@@ -0,0 +1,25 @@
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
+
9
+ import { tsup_exports } from "./tsup.mjs";
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ //#region src/tsup.test.ts
13
+ describe("devkit/unplugin/src/tsup.ts", () => {
14
+ it("loads module exports", () => {
15
+ expect(tsup_exports).toBeDefined();
16
+ expect(typeof tsup_exports).toBe("object");
17
+ });
18
+ it("has at least one runtime export", () => {
19
+ expect(Object.keys(tsup_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
24
+ export { };
25
+ //# sourceMappingURL=tsup.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsup.test.mjs","names":["moduleExports"],"sources":["../src/tsup.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./tsup\";\n\ndescribe(\"devkit/unplugin/src/tsup.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,qCAAqC;CAC5C,GAAG,8BAA8B;EAC/B,OAAOA,YAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,YAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,YAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
package/dist/types.cjs CHANGED
@@ -6,3 +6,16 @@ import __tsdown_shims_url from 'node:url'
6
6
  const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
7
  const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
8
 
9
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
10
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
11
+
12
+ //#region src/types.ts
13
+ var types_exports = /* @__PURE__ */ require_runtime.__exportAll({});
14
+
15
+ //#endregion
16
+ Object.defineProperty(exports, 'types_exports', {
17
+ enumerable: true,
18
+ get: function () {
19
+ return types_exports;
20
+ }
21
+ });
package/dist/types.mjs CHANGED
@@ -6,4 +6,11 @@ import __tsdown_shims_url from 'node:url'
6
6
  const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
7
7
  const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
8
8
 
9
- export { };
9
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
10
+
11
+ //#region src/types.ts
12
+ var types_exports = /* @__PURE__ */ __exportAll({});
13
+
14
+ //#endregion
15
+ export { types_exports };
16
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/types.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 BuildInlineConfig,\n ExecutionContext,\n ExecutionOptions,\n UnpluginOptions\n} from \"@powerlines/core\";\nimport { PartialKeys } from \"@stryke/types/base\";\nimport type { UnpluginContextMeta } from \"unplugin\";\n\nexport type * from \"@powerlines/core/types/unplugin\";\n\nexport type UnpluginExecutionOptionsBase = Omit<\n PartialKeys<\n ExecutionOptions,\n \"cwd\" | \"configFile\" | \"framework\" | \"root\" | \"configIndex\"\n >,\n \"executionId\"\n>;\n\nexport type UnpluginExecutionOptions = Omit<BuildInlineConfig, \"command\"> &\n UnpluginExecutionOptionsBase;\n\nexport type UnpluginFactory<TContext extends ExecutionContext> = (\n options: UnpluginExecutionOptions | undefined,\n meta: UnpluginContextMeta\n) => UnpluginOptions<TContext>;\n"],"mappings":""}
@@ -0,0 +1,23 @@
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
+
9
+ const require_types = require('./types.cjs');
10
+ let vitest = require("vitest");
11
+
12
+ //#region src/types.test.ts
13
+ (0, vitest.describe)("devkit/unplugin/src/types.ts", () => {
14
+ (0, vitest.it)("loads module exports", () => {
15
+ (0, vitest.expect)(require_types.types_exports).toBeDefined();
16
+ (0, vitest.expect)(typeof require_types.types_exports).toBe("object");
17
+ });
18
+ (0, vitest.it)("has at least one runtime export", () => {
19
+ (0, vitest.expect)(Object.keys(require_types.types_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,2 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
@@ -0,0 +1,25 @@
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
+
9
+ import { types_exports } from "./types.mjs";
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ //#region src/types.test.ts
13
+ describe("devkit/unplugin/src/types.ts", () => {
14
+ it("loads module exports", () => {
15
+ expect(types_exports).toBeDefined();
16
+ expect(typeof types_exports).toBe("object");
17
+ });
18
+ it("has at least one runtime export", () => {
19
+ expect(Object.keys(types_exports).length).toBeGreaterThan(0);
20
+ });
21
+ });
22
+
23
+ //#endregion
24
+ export { };
25
+ //# sourceMappingURL=types.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.test.mjs","names":["moduleExports"],"sources":["../src/types.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./types\";\n\ndescribe(\"devkit/unplugin/src/types.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,sCAAsC;CAC7C,GAAG,8BAA8B;EAC/B,OAAOA,aAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,aAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}