@powerlines/plugin-esbuild 0.13.345 → 0.13.347

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 (99) hide show
  1. package/README.md +14 -16
  2. package/dist/{build-Br4iCJ5d.d.cts → build-CAPZuv7c.d.mts} +1 -1
  3. package/dist/build-CAPZuv7c.d.mts.map +1 -0
  4. package/dist/{build-Bw5BbOcS.d.mts → build-D8UULv-V.d.cts} +1 -1
  5. package/dist/build-D8UULv-V.d.cts.map +1 -0
  6. package/dist/{bundle-CC14KyoT.d.mts → bundle-CYWEMAg5.d.mts} +1 -2
  7. package/dist/bundle-CYWEMAg5.d.mts.map +1 -0
  8. package/dist/{bundle-CGOgHuWO.d.cts → bundle-PDlKUkld.d.cts} +1 -2
  9. package/dist/bundle-PDlKUkld.d.cts.map +1 -0
  10. package/dist/helpers/bundle.cjs +44 -3
  11. package/dist/helpers/bundle.d.cts +1 -1
  12. package/dist/helpers/bundle.d.mts +1 -1
  13. package/dist/helpers/bundle.mjs +43 -3
  14. package/dist/helpers/bundle.mjs.map +1 -0
  15. package/dist/helpers/index.cjs +9 -9
  16. package/dist/helpers/index.d.cts +4 -6
  17. package/dist/helpers/index.d.mts +4 -7
  18. package/dist/helpers/index.mjs +4 -5
  19. package/dist/helpers/resolve-options.cjs +2 -1
  20. package/dist/helpers/resolve-options.d.cts +1 -1
  21. package/dist/helpers/resolve-options.d.mts +1 -1
  22. package/dist/helpers/resolve-options.mjs +86 -2
  23. package/dist/helpers/resolve-options.mjs.map +1 -0
  24. package/dist/helpers/resolve.cjs +63 -3
  25. package/dist/helpers/resolve.d.cts +1 -1
  26. package/dist/helpers/resolve.d.mts +1 -1
  27. package/dist/helpers/resolve.mjs +61 -2
  28. package/dist/helpers/resolve.mjs.map +1 -0
  29. package/dist/helpers/unplugin.cjs +11 -2
  30. package/dist/helpers/unplugin.d.cts +1 -2
  31. package/dist/helpers/unplugin.d.mts +1 -3
  32. package/dist/helpers/unplugin.mjs +10 -2
  33. package/dist/helpers/unplugin.mjs.map +1 -0
  34. package/dist/index.cjs +12 -13
  35. package/dist/index.d.cts +6 -8
  36. package/dist/index.d.cts.map +1 -1
  37. package/dist/index.d.mts +6 -8
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +6 -7
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/{plugin-7iQtkKC4.d.cts → plugin-ChsmpXkl.d.mts} +2 -2
  42. package/dist/plugin-ChsmpXkl.d.mts.map +1 -0
  43. package/dist/{plugin-Bg_EXmOz.d.mts → plugin-D9zv9VkU.d.cts} +2 -2
  44. package/dist/plugin-D9zv9VkU.d.cts.map +1 -0
  45. package/dist/{resolve-CaJwH6sa.d.mts → resolve-BIyvH_xj.d.cts} +2 -3
  46. package/dist/resolve-BIyvH_xj.d.cts.map +1 -0
  47. package/dist/{resolve-DaXV27Bb.d.cts → resolve-BcMpWb5V.d.mts} +2 -3
  48. package/dist/resolve-BcMpWb5V.d.mts.map +1 -0
  49. package/dist/{resolve-options-C3WIGKaG.cjs → resolve-options-BYIev5x9.cjs} +18 -18
  50. package/dist/{resolve-options-2OYkM7N0.d.mts → resolve-options-CL9zAGPa.d.mts} +1 -1
  51. package/dist/resolve-options-CL9zAGPa.d.mts.map +1 -0
  52. package/dist/{resolve-options-Dv4d9qj2.d.cts → resolve-options-DGAa2QLt.d.cts} +1 -1
  53. package/dist/resolve-options-DGAa2QLt.d.cts.map +1 -0
  54. package/dist/types/build.d.cts +1 -1
  55. package/dist/types/build.d.mts +1 -1
  56. package/dist/types/index.d.cts +2 -3
  57. package/dist/types/index.d.mts +2 -3
  58. package/dist/types/plugin.d.cts +1 -1
  59. package/dist/types/plugin.d.mts +1 -2
  60. package/dist/unplugin-Cv30XR60.d.mts +8 -0
  61. package/dist/unplugin-Cv30XR60.d.mts.map +1 -0
  62. package/dist/unplugin-DT4SEWTe.d.cts +8 -0
  63. package/dist/unplugin-DT4SEWTe.d.cts.map +1 -0
  64. package/package.json +23 -22
  65. package/dist/build-Br4iCJ5d.d.cts.map +0 -1
  66. package/dist/build-Bw5BbOcS.d.mts.map +0 -1
  67. package/dist/build-CQpSv6Qa.cjs +0 -0
  68. package/dist/build-DfzG3fLI.mjs +0 -1
  69. package/dist/bundle-CC14KyoT.d.mts.map +0 -1
  70. package/dist/bundle-CGOgHuWO.d.cts.map +0 -1
  71. package/dist/bundle-CyAIQjG8.cjs +0 -49
  72. package/dist/bundle-Mt5bozRV.mjs +0 -44
  73. package/dist/bundle-Mt5bozRV.mjs.map +0 -1
  74. package/dist/helpers-BAUlPOQe.mjs +0 -1
  75. package/dist/helpers-CAF8Bmv1.cjs +0 -0
  76. package/dist/index-BXxhKmeA.d.mts +0 -1
  77. package/dist/index-ClXLQ1fw.d.mts +0 -1
  78. package/dist/index-DeEmP3Jc.d.cts +0 -1
  79. package/dist/index-sQecLSpR.d.cts +0 -1
  80. package/dist/plugin-7iQtkKC4.d.cts.map +0 -1
  81. package/dist/plugin-BL8TLixo.mjs +0 -1
  82. package/dist/plugin-Bg_EXmOz.d.mts.map +0 -1
  83. package/dist/plugin-OjUZLLkc.cjs +0 -0
  84. package/dist/resolve-C8OzoP-s.mjs +0 -62
  85. package/dist/resolve-C8OzoP-s.mjs.map +0 -1
  86. package/dist/resolve-CaJwH6sa.d.mts.map +0 -1
  87. package/dist/resolve-CsStIaEj.cjs +0 -73
  88. package/dist/resolve-DaXV27Bb.d.cts.map +0 -1
  89. package/dist/resolve-options-2OYkM7N0.d.mts.map +0 -1
  90. package/dist/resolve-options-C-213jz6.mjs +0 -87
  91. package/dist/resolve-options-C-213jz6.mjs.map +0 -1
  92. package/dist/resolve-options-Dv4d9qj2.d.cts.map +0 -1
  93. package/dist/unplugin-CW_BVHFj.cjs +0 -16
  94. package/dist/unplugin-Cv-iqtwL.d.mts +0 -8
  95. package/dist/unplugin-Cv-iqtwL.d.mts.map +0 -1
  96. package/dist/unplugin-DYA9P9Jn.d.cts +0 -8
  97. package/dist/unplugin-DYA9P9Jn.d.cts.map +0 -1
  98. package/dist/unplugin-_Yvl6iM8.mjs +0 -11
  99. package/dist/unplugin-_Yvl6iM8.mjs.map +0 -1
package/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the <b>🔌 Powerlines</b> monorepo. Powerlines is the "
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.13.339-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/powerlines)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/powerlines/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.13.345-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/powerlines)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/powerlines/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
@@ -58,21 +58,19 @@ A package containing a Powerlines plugin to build projects using ESBuild.
58
58
 
59
59
  ## Table of Contents
60
60
 
61
- - [Powerlines - ESBuild Plugin](#powerlines---esbuild-plugin)
62
- - [Table of Contents](#table-of-contents)
63
- - [Installing](#installing)
64
- - [Reduced Package Size](#reduced-package-size)
65
- - [Development](#development)
66
- - [Building](#building)
67
- - [Running unit tests](#running-unit-tests)
68
- - [Linting](#linting)
69
- - [Storm Workspaces](#storm-workspaces)
70
- - [Roadmap](#roadmap)
71
- - [Support](#support)
72
- - [License](#license)
73
- - [Changelog](#changelog)
74
- - [Contributing](#contributing)
75
- - [Contributors](#contributors)
61
+ - [Installing](#installing)
62
+ - [Reduced Package Size](#reduced-package-size)
63
+ - [Development](#development)
64
+ - [Building](#building)
65
+ - [Running unit tests](#running-unit-tests)
66
+ - [Linting](#linting)
67
+ - [Storm Workspaces](#storm-workspaces)
68
+ - [Roadmap](#roadmap)
69
+ - [Support](#support)
70
+ - [License](#license)
71
+ - [Changelog](#changelog)
72
+ - [Contributing](#contributing)
73
+ - [Contributors](#contributors)
76
74
 
77
75
  <!-- END doctoc -->
78
76
 
@@ -5,4 +5,4 @@ type EsbuildOptions = Omit<BuildOptions, "entryPoints" | "platform" | "outdir" |
5
5
  declare type __ΩEsbuildOptions = any[];
6
6
  //#endregion
7
7
  export { __ΩEsbuildOptions as n, EsbuildOptions as t };
8
- //# sourceMappingURL=build-Br4iCJ5d.d.cts.map
8
+ //# sourceMappingURL=build-CAPZuv7c.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-CAPZuv7c.d.mts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,cAAA,GAAiB,IAAA,CAC3B,YAAA;AAAA"}
@@ -5,4 +5,4 @@ type EsbuildOptions = Omit<BuildOptions, "entryPoints" | "platform" | "outdir" |
5
5
  declare type __ΩEsbuildOptions = any[];
6
6
  //#endregion
7
7
  export { __ΩEsbuildOptions as n, EsbuildOptions as t };
8
- //# sourceMappingURL=build-Bw5BbOcS.d.mts.map
8
+ //# sourceMappingURL=build-D8UULv-V.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-D8UULv-V.d.cts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,cAAA,GAAiB,IAAA,CAC3B,YAAA;AAAA"}
@@ -2,7 +2,6 @@ import { BuildOptions, OutputFile } from "esbuild";
2
2
  import { PluginContext } from "@powerlines/core";
3
3
 
4
4
  //#region src/helpers/bundle.d.ts
5
-
6
5
  /**
7
6
  * Bundle a type definition to a module.
8
7
  *
@@ -14,4 +13,4 @@ import { PluginContext } from "@powerlines/core";
14
13
  declare function bundle(context: PluginContext, file: string, overrides?: Partial<BuildOptions>): Promise<OutputFile>;
15
14
  //#endregion
16
15
  export { bundle as t };
17
- //# sourceMappingURL=bundle-CC14KyoT.d.mts.map
16
+ //# sourceMappingURL=bundle-CYWEMAg5.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-CYWEMAg5.d.mts","names":[],"sources":["../src/helpers/bundle.ts"],"mappings":";;;;;;AAkCA;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,aAAA,EACT,IAAA,UACA,SAAA,GAAW,OAAA,CAAQ,YAAA,IAClB,OAAA,CAAQ,UAAA"}
@@ -2,7 +2,6 @@ import { PluginContext } from "@powerlines/core";
2
2
  import { BuildOptions, OutputFile } from "esbuild";
3
3
 
4
4
  //#region src/helpers/bundle.d.ts
5
-
6
5
  /**
7
6
  * Bundle a type definition to a module.
8
7
  *
@@ -14,4 +13,4 @@ import { BuildOptions, OutputFile } from "esbuild";
14
13
  declare function bundle(context: PluginContext, file: string, overrides?: Partial<BuildOptions>): Promise<OutputFile>;
15
14
  //#endregion
16
15
  export { bundle as t };
17
- //# sourceMappingURL=bundle-CGOgHuWO.d.cts.map
16
+ //# sourceMappingURL=bundle-PDlKUkld.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-PDlKUkld.d.cts","names":[],"sources":["../src/helpers/bundle.ts"],"mappings":";;;;;;AAkCA;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,aAAA,EACT,IAAA,UACA,SAAA,GAAW,OAAA,CAAQ,YAAA,IAClB,OAAA,CAAQ,UAAA"}
@@ -1,4 +1,45 @@
1
- require('../resolve-options-C3WIGKaG.cjs');
2
- const require_bundle = require('../bundle-CyAIQjG8.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BYIev5x9.cjs');
3
+ let defu = require("defu");
4
+ defu = require_resolve_options.__toESM(defu);
5
+ let esbuild = require("esbuild");
6
+ let _powerlines_core_lib_unplugin = require("@powerlines/core/lib/unplugin");
7
+ let unplugin = require("unplugin");
8
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
3
9
 
4
- exports.bundle = require_bundle.bundle;
10
+ //#region src/helpers/bundle.ts
11
+ /**
12
+ * Bundle a type definition to a module.
13
+ *
14
+ * @param context - The context object containing the environment paths.
15
+ * @param file - The file path to bundle.
16
+ * @param overrides - Optional overrides for the ESBuild configuration.
17
+ * @returns A promise that resolves to the bundled module.
18
+ */
19
+ async function bundle(context, file, overrides = {}) {
20
+ const path = await context.fs.resolve(file);
21
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
22
+ const result = await (0, esbuild.build)((0, defu.default)({
23
+ ...require_resolve_options.resolveOptions(context),
24
+ entryPoints: [path],
25
+ write: false,
26
+ sourcemap: false,
27
+ splitting: false,
28
+ treeShaking: true,
29
+ bundle: true,
30
+ packages: "bundle",
31
+ platform: "node",
32
+ logLevel: "silent",
33
+ ...overrides
34
+ }, { plugins: [(0, unplugin.createEsbuildPlugin)((0, _powerlines_core_lib_unplugin.createUnpluginResolver)(context, {
35
+ name: `${(0, _stryke_path_file_path_fns.findFileName)(file)} Bundler`,
36
+ prefix: false
37
+ }))({})] }));
38
+ if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
39
+ if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
40
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
41
+ return result.outputFiles.filter(Boolean)[0];
42
+ }
43
+
44
+ //#endregion
45
+ exports.bundle = bundle;
@@ -1,2 +1,2 @@
1
- import { t as bundle } from "../bundle-CGOgHuWO.cjs";
1
+ import { t as bundle } from "../bundle-PDlKUkld.cjs";
2
2
  export { bundle };
@@ -1,2 +1,2 @@
1
- import { t as bundle } from "../bundle-CC14KyoT.mjs";
1
+ import { t as bundle } from "../bundle-CYWEMAg5.mjs";
2
2
  export { bundle };
@@ -1,4 +1,44 @@
1
- import "../resolve-options-C-213jz6.mjs";
2
- import { t as bundle } from "../bundle-Mt5bozRV.mjs";
1
+ import { resolveOptions } from "./resolve-options.mjs";
2
+ import defu from "defu";
3
+ import { build } from "esbuild";
4
+ import { createUnpluginResolver } from "@powerlines/core/lib/unplugin";
5
+ import { createEsbuildPlugin } from "unplugin";
6
+ import { findFileName } from "@stryke/path/file-path-fns";
3
7
 
4
- export { bundle };
8
+ //#region src/helpers/bundle.ts
9
+ /**
10
+ * Bundle a type definition to a module.
11
+ *
12
+ * @param context - The context object containing the environment paths.
13
+ * @param file - The file path to bundle.
14
+ * @param overrides - Optional overrides for the ESBuild configuration.
15
+ * @returns A promise that resolves to the bundled module.
16
+ */
17
+ async function bundle(context, file, overrides = {}) {
18
+ const path = await context.fs.resolve(file);
19
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
20
+ const result = await build(defu({
21
+ ...resolveOptions(context),
22
+ entryPoints: [path],
23
+ write: false,
24
+ sourcemap: false,
25
+ splitting: false,
26
+ treeShaking: true,
27
+ bundle: true,
28
+ packages: "bundle",
29
+ platform: "node",
30
+ logLevel: "silent",
31
+ ...overrides
32
+ }, { plugins: [createEsbuildPlugin(createUnpluginResolver(context, {
33
+ name: `${findFileName(file)} Bundler`,
34
+ prefix: false
35
+ }))({})] }));
36
+ if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
37
+ if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
38
+ if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
39
+ return result.outputFiles.filter(Boolean)[0];
40
+ }
41
+
42
+ //#endregion
43
+ export { bundle };
44
+ //# sourceMappingURL=bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.mjs","names":[],"sources":["../../src/helpers/bundle.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 { PluginContext } from \"@powerlines/core\";\nimport { createUnpluginResolver } from \"@powerlines/core/lib/unplugin\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport { build, BuildOptions, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { resolveOptions } from \"./resolve-options\";\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle(\n context: PluginContext,\n file: string,\n overrides: Partial<BuildOptions> = {}\n): Promise<OutputFile> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const result = await build(\n defu(\n {\n ...resolveOptions(context),\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: true,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...overrides\n } as BuildOptions,\n {\n plugins: [\n createEsbuildPlugin(\n createUnpluginResolver(context, {\n name: `${findFileName(file)} Bundler`,\n prefix: false\n })\n )({})\n ]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,eAAsB,OACpB,SACA,MACA,YAAmC,EAAE,EAChB;CACrB,MAAM,OAAO,MAAM,QAAQ,GAAG,QAAQ,KAAK;AAC3C,KAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,KAAK,CACvC,OAAM,IAAI,MACR,sBAAsB,KAAK,yCAC5B;CAGH,MAAM,SAAS,MAAM,MACnB,KACE;EACE,GAAG,eAAe,QAAQ;EAC1B,aAAa,CAAC,KAAK;EACnB,OAAO;EACP,WAAW;EACX,WAAW;EACX,aAAa;EACb,QAAQ;EACR,UAAU;EACV,UAAU;EACV,UAAU;EACV,GAAG;EACJ,EACD,EACE,SAAS,CACP,oBACE,uBAAuB,SAAS;EAC9B,MAAM,GAAG,aAAa,KAAK,CAAC;EAC5B,QAAQ;EACT,CAAC,CACH,CAAC,EAAE,CAAC,CACN,EACF,CACF,CACF;AACD,KAAI,OAAO,OAAO,SAAS,EACzB,OAAM,IAAI,MACR,oBAAoB,KAAK,IAAI,OAAO,OACjC,KAAI,UAAS,MAAM,KAAK,CACxB,KAAK,KAAK,GACd;AAEH,KAAI,OAAO,SAAS,SAAS,EAC3B,SAAQ,KACN,2BAA2B,KAAK,IAAI,OAAO,SACxC,KAAI,YAAW,QAAQ,KAAK,CAC5B,KAAK,KAAK,GACd;AAEH,KAAI,CAAC,OAAO,eAAe,OAAO,YAAY,OAAO,QAAQ,CAAC,WAAW,EACvE,OAAM,IAAI,MACR,iCACE,KACD,iDACF;AAGH,QAAO,OAAO,YAAY,OAAO,QAAQ,CAAC"}
@@ -1,13 +1,13 @@
1
- const require_resolve_options = require('../resolve-options-C3WIGKaG.cjs');
2
- const require_unplugin = require('../unplugin-CW_BVHFj.cjs');
3
- const require_bundle = require('../bundle-CyAIQjG8.cjs');
4
- const require_resolve = require('../resolve-CsStIaEj.cjs');
5
- require('../helpers-CAF8Bmv1.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BYIev5x9.cjs');
3
+ const require_helpers_unplugin = require('./unplugin.cjs');
4
+ const require_helpers_bundle = require('./bundle.cjs');
5
+ const require_helpers_resolve = require('./resolve.cjs');
6
6
 
7
7
  exports.DEFAULT_ESBUILD_CONFIG = require_resolve_options.DEFAULT_ESBUILD_CONFIG;
8
- exports.bundle = require_bundle.bundle;
9
- exports.createEsbuildPlugin = require_unplugin.createEsbuildPlugin;
10
- exports.resolve = require_resolve.resolve;
8
+ exports.bundle = require_helpers_bundle.bundle;
9
+ exports.createEsbuildPlugin = require_helpers_unplugin.createEsbuildPlugin;
10
+ exports.resolve = require_helpers_resolve.resolve;
11
11
  exports.resolveEntry = require_resolve_options.resolveEntry;
12
- exports.resolveModule = require_resolve.resolveModule;
12
+ exports.resolveModule = require_helpers_resolve.resolveModule;
13
13
  exports.resolveOptions = require_resolve_options.resolveOptions;
@@ -1,7 +1,5 @@
1
- import { t as bundle } from "../bundle-CGOgHuWO.cjs";
2
- import { n as resolveModule, t as resolve } from "../resolve-DaXV27Bb.cjs";
3
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-Dv4d9qj2.cjs";
4
- import "../plugin-7iQtkKC4.cjs";
5
- import { t as createEsbuildPlugin } from "../unplugin-DYA9P9Jn.cjs";
6
- import "../index-DeEmP3Jc.cjs";
1
+ import { t as bundle } from "../bundle-PDlKUkld.cjs";
2
+ import { n as resolveModule, t as resolve } from "../resolve-BIyvH_xj.cjs";
3
+ import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-DGAa2QLt.cjs";
4
+ import { t as createEsbuildPlugin } from "../unplugin-DT4SEWTe.cjs";
7
5
  export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
@@ -1,8 +1,5 @@
1
- import { t as bundle } from "../bundle-CC14KyoT.mjs";
2
- import { n as resolveModule, t as resolve } from "../resolve-CaJwH6sa.mjs";
3
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-2OYkM7N0.mjs";
4
- import "../build-Bw5BbOcS.mjs";
5
- import "../plugin-Bg_EXmOz.mjs";
6
- import { t as createEsbuildPlugin } from "../unplugin-Cv-iqtwL.mjs";
7
- import "../index-BXxhKmeA.mjs";
1
+ import { t as bundle } from "../bundle-CYWEMAg5.mjs";
2
+ import { n as resolveModule, t as resolve } from "../resolve-BcMpWb5V.mjs";
3
+ import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-CL9zAGPa.mjs";
4
+ import { t as createEsbuildPlugin } from "../unplugin-Cv30XR60.mjs";
8
5
  export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
@@ -1,7 +1,6 @@
1
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-C-213jz6.mjs";
2
- import { t as createEsbuildPlugin } from "../unplugin-_Yvl6iM8.mjs";
3
- import { t as bundle } from "../bundle-Mt5bozRV.mjs";
4
- import { n as resolveModule, t as resolve } from "../resolve-C8OzoP-s.mjs";
5
- import "../helpers-BAUlPOQe.mjs";
1
+ import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./resolve-options.mjs";
2
+ import { createEsbuildPlugin } from "./unplugin.mjs";
3
+ import { bundle } from "./bundle.mjs";
4
+ import { resolve, resolveModule } from "./resolve.mjs";
6
5
 
7
6
  export { DEFAULT_ESBUILD_CONFIG, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
@@ -1,4 +1,5 @@
1
- const require_resolve_options = require('../resolve-options-C3WIGKaG.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BYIev5x9.cjs');
2
3
 
3
4
  exports.DEFAULT_ESBUILD_CONFIG = require_resolve_options.DEFAULT_ESBUILD_CONFIG;
4
5
  exports.resolveEntry = require_resolve_options.resolveEntry;
@@ -1,2 +1,2 @@
1
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-Dv4d9qj2.cjs";
1
+ import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-DGAa2QLt.cjs";
2
2
  export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
@@ -1,2 +1,2 @@
1
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-2OYkM7N0.mjs";
1
+ import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-CL9zAGPa.mjs";
2
2
  export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
@@ -1,3 +1,87 @@
1
- import { n as resolveEntry, r as resolveOptions, t as DEFAULT_ESBUILD_CONFIG } from "../resolve-options-C-213jz6.mjs";
1
+ import defu from "defu";
2
+ import { resolveEntryOutput } from "@powerlines/core/lib/entry";
3
+ import { joinPaths } from "@stryke/path/join-paths";
4
+ import { replaceExtension, replacePath } from "@stryke/path/replace";
5
+ import { camelCase } from "@stryke/string-format/camel-case";
6
+ import { isString } from "@stryke/type-checks/is-string";
2
7
 
3
- export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
8
+ //#region src/helpers/resolve-options.ts
9
+ const DEFAULT_ESBUILD_CONFIG = {
10
+ target: "esnext",
11
+ platform: "neutral",
12
+ format: "esm",
13
+ write: true,
14
+ minify: true,
15
+ sourcemap: false,
16
+ bundle: true,
17
+ treeShaking: true,
18
+ keepNames: true,
19
+ splitting: true,
20
+ logLevel: "silent"
21
+ };
22
+ /**
23
+ * Resolves the entry options for esbuild.
24
+ *
25
+ * @param context - The build context.
26
+ * @param entryPoints - The entry points to resolve.
27
+ * @returns The resolved entry options.
28
+ */
29
+ function resolveEntry(context, entryPoints = []) {
30
+ return entryPoints.reduce((ret, entry) => {
31
+ if (isString(entry)) ret[replaceExtension(replacePath(entry, context.config.root))] = replacePath(entry, context.config.root);
32
+ else ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;
33
+ return ret;
34
+ }, {});
35
+ }
36
+ /**
37
+ * Resolves the esbuild options.
38
+ *
39
+ * @param context - The build context.
40
+ * @returns The resolved esbuild options.
41
+ */
42
+ function resolveOptions(context) {
43
+ if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
44
+ if (value) if (Array.isArray(value)) {
45
+ if (camelCase(key) !== key) {
46
+ if (value.length === 1) return `
47
+ import ${camelCase(key)} from "${value[0]}";
48
+ export { ${camelCase(key)} as "${key}" }`;
49
+ else if (value.length > 1) return `
50
+ import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
51
+ export { ${camelCase(key)} as "${key}" }`;
52
+ } else if (value.length === 1) return `
53
+ import ${key} from "${value[0]}";
54
+ export { ${key} };`;
55
+ else if (value.length > 1) return `
56
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
57
+ export { ${key} };`;
58
+ } else if (camelCase(key) !== key) return `
59
+ import ${camelCase(key)} from "${value[0]}";
60
+ export { ${camelCase(key)} as "${key}" }`;
61
+ else return `
62
+ import ${key} from "${value}";
63
+ export { ${key} };`;
64
+ return "";
65
+ }).join("\n"));
66
+ return defu({
67
+ alias: context.alias,
68
+ inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
69
+ }, context.config?.esbuild ? context.config.esbuild : {}, {
70
+ mainFields: context.config.resolve.mainFields,
71
+ conditions: context.config.resolve.conditions,
72
+ define: context.config.define,
73
+ resolveExtensions: context.config.resolve.extensions,
74
+ packages: context.config.resolve.skipNodeModulesBundle ? "external" : context.config?.esbuild ? (context.config?.esbuild).packages : void 0,
75
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
76
+ platform: context.config.platform,
77
+ outdir: context.config.output.buildPath,
78
+ tsconfig: context.tsconfig.tsconfigFilePath,
79
+ minify: context.config.mode !== "development",
80
+ metafile: context.config.mode === "development",
81
+ sourcemap: context.config.mode === "development"
82
+ }, DEFAULT_ESBUILD_CONFIG);
83
+ }
84
+
85
+ //#endregion
86
+ export { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions };
87
+ //# sourceMappingURL=resolve-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.mjs","names":[],"sources":["../../src/helpers/resolve-options.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 { Context, ResolvedEntryTypeDefinition } from \"@powerlines/core\";\nimport { resolveEntryOutput } from \"@powerlines/core/lib/entry\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { BuildOptions, Format, LogLevel, Platform } from \"esbuild\";\nimport { EsbuildPluginContext } from \"../types/plugin\";\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\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(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): BuildOptions[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[replaceExtension(replacePath(entry, context.config.root))] =\n replacePath(entry, context.config.root);\n } else {\n ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function resolveOptions(context: Context): BuildOptions {\n if (context.config.inject && Object.keys(context.config.inject).length > 0) {\n context.fs.writeSync(\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n ),\n Object.entries(context.config.inject)\n .map(([key, value]) => {\n if (value) {\n if (Array.isArray(value)) {\n if (camelCase(key) !== key) {\n if (value.length === 1) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n }\n } else if (value.length === 1) {\n return `\nimport ${key} from \"${value[0]}\";\nexport { ${key} };`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from \"${value[0]}\";\nexport { ${key} };`;\n }\n } else if (camelCase(key) !== key) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else {\n return `\nimport ${key} from \"${value}\";\nexport { ${key} };`;\n }\n }\n\n return \"\";\n })\n .join(\"\\n\")\n );\n }\n\n return defu(\n {\n alias: context.alias,\n inject:\n context.config.inject && Object.keys(context.config.inject).length > 0\n ? [\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n )\n ]\n : undefined\n },\n (context as EsbuildPluginContext).config?.esbuild\n ? (context as EsbuildPluginContext).config.esbuild\n : {},\n {\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n resolveExtensions: context.config.resolve.extensions,\n packages: context.config.resolve.skipNodeModulesBundle\n ? \"external\"\n : (context as EsbuildPluginContext).config?.esbuild\n ? ((context as EsbuildPluginContext).config?.esbuild as BuildOptions)\n .packages\n : undefined,\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.platform,\n outdir: context.config.output.buildPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n ) as BuildOptions;\n}\n"],"mappings":";;;;;;;;AA4BA,MAAa,yBAAgD;CAC3D,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,aAAa;CACb,WAAW;CACX,WAAW;CACX,UAAU;CACX;;;;;;;;AASD,SAAgB,aACd,SACA,cAAwD,EAAE,EAC7B;AAC7B,QAAO,YAAY,QAChB,KAAK,UAAU;AACd,MAAI,SAAS,MAAM,CACjB,KAAI,iBAAiB,YAAY,OAAO,QAAQ,OAAO,KAAK,CAAC,IAC3D,YAAY,OAAO,QAAQ,OAAO,KAAK;MAEzC,KAAI,MAAM,UAAU,mBAAmB,SAAS,MAAM,IAAI,MAAM;AAGlE,SAAO;IAET,EAAE,CACH;;;;;;;;AASH,SAAgB,eAAe,SAAgC;AAC7D,KAAI,QAAQ,OAAO,UAAU,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,EACvE,SAAQ,GAAG,UACT,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,QAAQ,eACR,iBACD,EACD,OAAO,QAAQ,QAAQ,OAAO,OAAO,CAClC,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,MACF,KAAI,MAAM,QAAQ,MAAM,EACtB;OAAI,UAAU,IAAI,KAAK,KACrB;QAAI,MAAM,WAAW,EACnB,QAAO;SAChB,UAAU,IAAI,CAAC,SAAS,MAAM,GAAG;WAC/B,UAAU,IAAI,CAAC,OAAO,IAAI;aACV,MAAM,SAAS,EACxB,QAAO;SAChB,MAAM,OAAO,MAAM,QAAQ,UAAU,IAAI,KAAK,KAAK,MAAM,GAAG,MAAM,UAAU,IAAI,CAAC,IAAI,SAAS,MAAM,GAAG;WACrG,UAAU,IAAI,CAAC,OAAO,IAAI;cAEZ,MAAM,WAAW,EAC1B,QAAO;SACd,IAAI,SAAS,MAAM,GAAG;WACpB,IAAI;YACU,MAAM,SAAS,EACxB,QAAO;SACd,MAAM,OAAO,MAAM,QAAQ,QAAQ,KAAK,MAAM,GAAG,MAAM,IAAI,IAAI,SAAS,MAAM,GAAG;WAC/E,IAAI;aAEQ,UAAU,IAAI,KAAK,IAC5B,QAAO;SACZ,UAAU,IAAI,CAAC,SAAS,MAAM,GAAG;WAC/B,UAAU,IAAI,CAAC,OAAO,IAAI;MAEvB,QAAO;SACZ,IAAI,SAAS,MAAM;WACjB,IAAI;AAIL,SAAO;GACP,CACD,KAAK,KAAK,CACd;AAGH,QAAO,KACL;EACE,OAAO,QAAQ;EACf,QACE,QAAQ,OAAO,UAAU,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,IACjE,CACE,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,QAAQ,eACR,iBACD,CACF,GACD;EACP,EACA,QAAiC,QAAQ,UACrC,QAAiC,OAAO,UACzC,EAAE,EACN;EACE,YAAY,QAAQ,OAAO,QAAQ;EACnC,YAAY,QAAQ,OAAO,QAAQ;EACnC,QAAQ,QAAQ,OAAO;EACvB,mBAAmB,QAAQ,OAAO,QAAQ;EAC1C,UAAU,QAAQ,OAAO,QAAQ,wBAC7B,aACC,QAAiC,QAAQ,WACtC,QAAiC,QAAQ,SACxC,WACH;EACN,QAAS,MAAM,QAAQ,QAAQ,OAAO,OAAO,OAAO,GAChD,QAAQ,OAAO,OAAO,OAAO,KAC7B,QAAQ,OAAO,OAAO;EAC1B,UAAU,QAAQ,OAAO;EACzB,QAAQ,QAAQ,OAAO,OAAO;EAC9B,UAAU,QAAQ,SAAS;EAC3B,QAAQ,QAAQ,OAAO,SAAS;EAChC,UAAU,QAAQ,OAAO,SAAS;EAClC,WAAW,QAAQ,OAAO,SAAS;EACpC,EACD,uBACD"}
@@ -1,4 +1,64 @@
1
- const require_resolve = require('../resolve-CsStIaEj.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BYIev5x9.cjs');
3
+ let _powerlines_plugin_esbuild_helpers_bundle = require("@powerlines/plugin-esbuild/helpers/bundle");
4
+ let _stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
5
+ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
2
6
 
3
- exports.resolve = require_resolve.resolve;
4
- exports.resolveModule = require_resolve.resolveModule;
7
+ //#region src/helpers/resolve.ts
8
+ /**
9
+ * Compiles a type definition to a module and returns the module.
10
+ *
11
+ * @param context - The context object containing the environment paths.
12
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
13
+ * @param overrides - Optional overrides for the ESBuild configuration.
14
+ * @returns A promise that resolves to the compiled module.
15
+ */
16
+ async function resolveModule(context, type, overrides = {}) {
17
+ let typeDefinition;
18
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(type);
19
+ else typeDefinition = type;
20
+ const result = await (0, _powerlines_plugin_esbuild_helpers_bundle.bundle)(context, typeDefinition.file, overrides);
21
+ let resolved;
22
+ try {
23
+ resolved = await context.resolver.evalModule(result.text, {
24
+ filename: result.path,
25
+ forceTranspile: true
26
+ });
27
+ } catch (error) {
28
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(error.message) && new RegExp(`Cannot find module '${context.config.framework || "powerlines"}:.*'`).test(error.message)) {
29
+ const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework || "powerlines"}:.*)'`))?.[1];
30
+ throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${typeDefinition.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
31
+
32
+ Bundle output for module:
33
+ ${result.text}` : ""}`);
34
+ }
35
+ throw new Error(`Failed to evaluate the bundled module for "${typeDefinition.file}". Error: ${error.message}${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
36
+
37
+ Bundle output for module:
38
+ ${result.text}` : ""}`);
39
+ }
40
+ return resolved;
41
+ }
42
+ /**
43
+ * Compiles a type definition to a module and returns the specified export from the module.
44
+ *
45
+ * @param context - The context object containing the environment paths.
46
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
47
+ * @param overrides - Optional overrides for the ESBuild configuration.
48
+ * @returns A promise that resolves to the compiled module.
49
+ */
50
+ async function resolve(context, type, overrides = {}) {
51
+ let typeDefinition;
52
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(type);
53
+ else typeDefinition = type;
54
+ const resolved = await resolveModule(context, typeDefinition, overrides);
55
+ let exportName = typeDefinition.name;
56
+ if (!exportName) exportName = "default";
57
+ const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];
58
+ if (resolvedExport === void 0) throw new Error(`The export "${exportName}" could not be resolved in the "${typeDefinition.file}" module. ${Object.keys(resolved).length === 0 ? `After bundling, no exports were found in the module. Please ensure that the "${typeDefinition.file}" module has a "${exportName}" export with the desired value.` : `After bundling, the available exports were: ${Object.keys(resolved).join(", ")}. Please ensure that the export exists and is correctly named.`}`);
59
+ return resolvedExport;
60
+ }
61
+
62
+ //#endregion
63
+ exports.resolve = resolve;
64
+ exports.resolveModule = resolveModule;
@@ -1,2 +1,2 @@
1
- import { n as resolveModule, t as resolve } from "../resolve-DaXV27Bb.cjs";
1
+ import { n as resolveModule, t as resolve } from "../resolve-BIyvH_xj.cjs";
2
2
  export { resolve, resolveModule };
@@ -1,2 +1,2 @@
1
- import { n as resolveModule, t as resolve } from "../resolve-CaJwH6sa.mjs";
1
+ import { n as resolveModule, t as resolve } from "../resolve-BcMpWb5V.mjs";
2
2
  export { resolve, resolveModule };
@@ -1,3 +1,62 @@
1
- import { n as resolveModule, t as resolve } from "../resolve-C8OzoP-s.mjs";
1
+ import { bundle } from "@powerlines/plugin-esbuild/helpers/bundle";
2
+ import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
2
4
 
3
- export { resolve, resolveModule };
5
+ //#region src/helpers/resolve.ts
6
+ /**
7
+ * Compiles a type definition to a module and returns the module.
8
+ *
9
+ * @param context - The context object containing the environment paths.
10
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
11
+ * @param overrides - Optional overrides for the ESBuild configuration.
12
+ * @returns A promise that resolves to the compiled module.
13
+ */
14
+ async function resolveModule(context, type, overrides = {}) {
15
+ let typeDefinition;
16
+ if (isSetString(type)) typeDefinition = parseTypeDefinition(type);
17
+ else typeDefinition = type;
18
+ const result = await bundle(context, typeDefinition.file, overrides);
19
+ let resolved;
20
+ try {
21
+ resolved = await context.resolver.evalModule(result.text, {
22
+ filename: result.path,
23
+ forceTranspile: true
24
+ });
25
+ } catch (error) {
26
+ if (isSetString(error.message) && new RegExp(`Cannot find module '${context.config.framework || "powerlines"}:.*'`).test(error.message)) {
27
+ const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework || "powerlines"}:.*)'`))?.[1];
28
+ throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${typeDefinition.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
29
+
30
+ Bundle output for module:
31
+ ${result.text}` : ""}`);
32
+ }
33
+ throw new Error(`Failed to evaluate the bundled module for "${typeDefinition.file}". Error: ${error.message}${context.config.logLevel === "debug" || context.config.logLevel === "trace" ? `
34
+
35
+ Bundle output for module:
36
+ ${result.text}` : ""}`);
37
+ }
38
+ return resolved;
39
+ }
40
+ /**
41
+ * Compiles a type definition to a module and returns the specified export from the module.
42
+ *
43
+ * @param context - The context object containing the environment paths.
44
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
45
+ * @param overrides - Optional overrides for the ESBuild configuration.
46
+ * @returns A promise that resolves to the compiled module.
47
+ */
48
+ async function resolve(context, type, overrides = {}) {
49
+ let typeDefinition;
50
+ if (isSetString(type)) typeDefinition = parseTypeDefinition(type);
51
+ else typeDefinition = type;
52
+ const resolved = await resolveModule(context, typeDefinition, overrides);
53
+ let exportName = typeDefinition.name;
54
+ if (!exportName) exportName = "default";
55
+ const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];
56
+ if (resolvedExport === void 0) throw new Error(`The export "${exportName}" could not be resolved in the "${typeDefinition.file}" module. ${Object.keys(resolved).length === 0 ? `After bundling, no exports were found in the module. Please ensure that the "${typeDefinition.file}" module has a "${exportName}" export with the desired value.` : `After bundling, the available exports were: ${Object.keys(resolved).join(", ")}. Please ensure that the export exists and is correctly named.`}`);
57
+ return resolvedExport;
58
+ }
59
+
60
+ //#endregion
61
+ export { resolve, resolveModule };
62
+ //# sourceMappingURL=resolve.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/helpers/resolve.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 { PluginContext } from \"@powerlines/core\";\nimport { bundle } from \"@powerlines/plugin-esbuild/helpers/bundle\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { BuildOptions } from \"esbuild\";\n\n/**\n * Compiles a type definition to a module and returns the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolveModule<TResult>(\n context: PluginContext,\n type: TypeDefinitionParameter,\n overrides: Partial<BuildOptions> = {}\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const result = await bundle(context, typeDefinition.file, overrides);\n\n let resolved: any;\n try {\n resolved = await context.resolver.evalModule(result.text, {\n filename: result.path,\n forceTranspile: true\n });\n } catch (error) {\n if (\n isSetString((error as Error).message) &&\n new RegExp(\n `Cannot find module '${context.config.framework || \"powerlines\"}:.*'`\n ).test((error as Error).message)\n ) {\n const moduleName = (error as Error).message.match(\n new RegExp(\n `Cannot find module '(${context.config.framework || \"powerlines\"}:.*)'`\n )\n )?.[1];\n throw new Error(\n `The module \"${moduleName}\" could not be resolved while evaluating \"${\n typeDefinition.file\n }\". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${\n context.config.logLevel === \"debug\" ||\n context.config.logLevel === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n throw new Error(\n `Failed to evaluate the bundled module for \"${\n typeDefinition.file\n }\". Error: ${(error as Error).message}${\n context.config.logLevel === \"debug\" ||\n context.config.logLevel === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n return resolved;\n}\n\n/**\n * Compiles a type definition to a module and returns the specified export from the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolve<TResult>(\n context: PluginContext,\n type: TypeDefinitionParameter,\n overrides: Partial<BuildOptions> = {}\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const resolved = await resolveModule<Record<string, any>>(\n context,\n typeDefinition,\n overrides\n );\n\n let exportName = typeDefinition.name;\n if (!exportName) {\n exportName = \"default\";\n }\n\n const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];\n if (resolvedExport === undefined) {\n throw new Error(\n `The export \"${exportName}\" could not be resolved in the \"${\n typeDefinition.file\n }\" module. ${\n Object.keys(resolved).length === 0\n ? `After bundling, no exports were found in the module. Please ensure that the \"${\n typeDefinition.file\n }\" module has a \"${exportName}\" export with the desired value.`\n : `After bundling, the available exports were: ${Object.keys(\n resolved\n ).join(\n \", \"\n )}. Please ensure that the export exists and is correctly named.`\n }`\n );\n }\n\n return resolvedExport;\n}\n"],"mappings":";;;;;;;;;;;;;AAoCA,eAAsB,cACpB,SACA,MACA,YAAmC,EAAE,EACnB;CAClB,IAAI;AACJ,KAAI,YAAY,KAAK,CACnB,kBAAiB,oBAAoB,KAAK;KAE1C,kBAAiB;CAGnB,MAAM,SAAS,MAAM,OAAO,SAAS,eAAe,MAAM,UAAU;CAEpE,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,QAAQ,SAAS,WAAW,OAAO,MAAM;GACxD,UAAU,OAAO;GACjB,gBAAgB;GACjB,CAAC;UACK,OAAO;AACd,MACE,YAAa,MAAgB,QAAQ,IACrC,IAAI,OACF,uBAAuB,QAAQ,OAAO,aAAa,aAAa,MACjE,CAAC,KAAM,MAAgB,QAAQ,EAChC;GACA,MAAM,aAAc,MAAgB,QAAQ,MAC1C,IAAI,OACF,wBAAwB,QAAQ,OAAO,aAAa,aAAa,OAClE,CACF,GAAG;AACJ,SAAM,IAAI,MACR,eAAe,WAAW,4CACxB,eAAe,KAChB,uHACC,QAAQ,OAAO,aAAa,WAC5B,QAAQ,OAAO,aAAa,UACxB;;;EAGZ,OAAO,SACK,KAEP;;AAGH,QAAM,IAAI,MACR,8CACE,eAAe,KAChB,YAAa,MAAgB,UAC5B,QAAQ,OAAO,aAAa,WAC5B,QAAQ,OAAO,aAAa,UACxB;;;EAGV,OAAO,SACG,KAEP;;AAGH,QAAO;;;;;;;;;;AAWT,eAAsB,QACpB,SACA,MACA,YAAmC,EAAE,EACnB;CAClB,IAAI;AACJ,KAAI,YAAY,KAAK,CACnB,kBAAiB,oBAAoB,KAAK;KAE1C,kBAAiB;CAGnB,MAAM,WAAW,MAAM,cACrB,SACA,gBACA,UACD;CAED,IAAI,aAAa,eAAe;AAChC,KAAI,CAAC,WACH,cAAa;CAGf,MAAM,iBAAiB,SAAS,eAAe,SAAS,MAAM;AAC9D,KAAI,mBAAmB,OACrB,OAAM,IAAI,MACR,eAAe,WAAW,kCACxB,eAAe,KAChB,YACC,OAAO,KAAK,SAAS,CAAC,WAAW,IAC7B,gFACE,eAAe,KAChB,kBAAkB,WAAW,oCAC9B,+CAA+C,OAAO,KACpD,SACD,CAAC,KACA,KACD,CAAC,kEAET;AAGH,QAAO"}
@@ -1,3 +1,12 @@
1
- const require_unplugin = require('../unplugin-CW_BVHFj.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BYIev5x9.cjs');
3
+ let _powerlines_core_lib_unplugin = require("@powerlines/core/lib/unplugin");
4
+ let unplugin = require("unplugin");
2
5
 
3
- exports.createEsbuildPlugin = require_unplugin.createEsbuildPlugin;
6
+ //#region src/helpers/unplugin.ts
7
+ function createEsbuildPlugin(context) {
8
+ return (0, unplugin.createEsbuildPlugin)((0, _powerlines_core_lib_unplugin.createUnplugin)(context))({});
9
+ }
10
+
11
+ //#endregion
12
+ exports.createEsbuildPlugin = createEsbuildPlugin;
@@ -1,3 +1,2 @@
1
- import "../plugin-7iQtkKC4.cjs";
2
- import { t as createEsbuildPlugin } from "../unplugin-DYA9P9Jn.cjs";
1
+ import { t as createEsbuildPlugin } from "../unplugin-DT4SEWTe.cjs";
3
2
  export { createEsbuildPlugin };
@@ -1,4 +1,2 @@
1
- import "../build-Bw5BbOcS.mjs";
2
- import "../plugin-Bg_EXmOz.mjs";
3
- import { t as createEsbuildPlugin } from "../unplugin-Cv-iqtwL.mjs";
1
+ import { t as createEsbuildPlugin } from "../unplugin-Cv30XR60.mjs";
4
2
  export { createEsbuildPlugin };