@powerlines/plugin-unbuild 0.5.345 → 0.5.346

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 (51) hide show
  1. package/README.md +14 -16
  2. package/dist/{build-CTNIcTZR.d.mts → build-BwqbRruN.d.mts} +1 -1
  3. package/dist/build-BwqbRruN.d.mts.map +1 -0
  4. package/dist/{build-D-HKMVs4.d.cts → build-Dwhf5qER.d.cts} +1 -1
  5. package/dist/build-Dwhf5qER.d.cts.map +1 -0
  6. package/dist/helpers/index.cjs +2 -1
  7. package/dist/helpers/index.d.cts +1 -1
  8. package/dist/helpers/index.d.mts +1 -1
  9. package/dist/helpers/index.mjs +1 -1
  10. package/dist/helpers/resolve-options.cjs +2 -1
  11. package/dist/helpers/resolve-options.d.cts +17 -2
  12. package/dist/helpers/resolve-options.d.cts.map +1 -0
  13. package/dist/helpers/resolve-options.d.mts +17 -2
  14. package/dist/helpers/resolve-options.d.mts.map +1 -0
  15. package/dist/helpers/resolve-options.mjs +122 -2
  16. package/dist/helpers/resolve-options.mjs.map +1 -0
  17. package/dist/index.cjs +5 -6
  18. package/dist/index.d.cts +2 -3
  19. package/dist/index.d.cts.map +1 -1
  20. package/dist/index.d.mts +2 -3
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +2 -3
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{resolve-options-COWDeANr.cjs → resolve-options-BCjPXFKK.cjs} +15 -15
  25. package/dist/types/build.d.cts +1 -1
  26. package/dist/types/build.d.mts +1 -1
  27. package/dist/types/index.d.cts +2 -3
  28. package/dist/types/index.d.mts +2 -3
  29. package/dist/types/plugin.d.cts +19 -2
  30. package/dist/types/plugin.d.cts.map +1 -0
  31. package/dist/types/plugin.d.mts +19 -2
  32. package/dist/types/plugin.d.mts.map +1 -0
  33. package/package.json +17 -16
  34. package/dist/build-CTNIcTZR.d.mts.map +0 -1
  35. package/dist/build-CcJjLdFm.mjs +0 -1
  36. package/dist/build-D-HKMVs4.d.cts.map +0 -1
  37. package/dist/build-MNonspIb.cjs +0 -0
  38. package/dist/index-BR1oNnaF.d.cts +0 -1
  39. package/dist/index-vkGVyY9v.d.mts +0 -1
  40. package/dist/plugin-DeNRjk0Q.d.cts +0 -19
  41. package/dist/plugin-DeNRjk0Q.d.cts.map +0 -1
  42. package/dist/plugin-iqCdm9Mq.d.mts +0 -19
  43. package/dist/plugin-iqCdm9Mq.d.mts.map +0 -1
  44. package/dist/plugin-jZ9N9Mz-.mjs +0 -1
  45. package/dist/plugin-pBKbb5K9.cjs +0 -0
  46. package/dist/resolve-options-BF6hy5ew.d.cts +0 -17
  47. package/dist/resolve-options-BF6hy5ew.d.cts.map +0 -1
  48. package/dist/resolve-options-Bnm3rLPK.d.mts +0 -17
  49. package/dist/resolve-options-Bnm3rLPK.d.mts.map +0 -1
  50. package/dist/resolve-options-CpHtoivj.mjs +0 -123
  51. package/dist/resolve-options-CpHtoivj.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.5.340-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.5.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 Unbuild.
58
58
 
59
59
  ## Table of Contents
60
60
 
61
- - [Powerlines - Unbuild Plugin](#powerlines---unbuild-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 UnbuildOptions$1 = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw"
5
5
  declare type __ΩUnbuildOptions = any[];
6
6
  //#endregion
7
7
  export { __ΩUnbuildOptions as n, UnbuildOptions$1 as t };
8
- //# sourceMappingURL=build-CTNIcTZR.d.mts.map
8
+ //# sourceMappingURL=build-BwqbRruN.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-BwqbRruN.d.mts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,gBAAA,GAAiB,OAAA,CAC3B,IAAA,CACE,cAAA;AAAA"}
@@ -5,4 +5,4 @@ type UnbuildOptions$1 = Partial<Omit<UnbuildOptions, "tsconfig" | "tsconfigRaw"
5
5
  declare type __ΩUnbuildOptions = any[];
6
6
  //#endregion
7
7
  export { __ΩUnbuildOptions as n, UnbuildOptions$1 as t };
8
- //# sourceMappingURL=build-D-HKMVs4.d.cts.map
8
+ //# sourceMappingURL=build-Dwhf5qER.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-Dwhf5qER.d.cts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,gBAAA,GAAiB,OAAA,CAC3B,IAAA,CACE,cAAA;AAAA"}
@@ -1,4 +1,5 @@
1
- const require_resolve_options = require('../resolve-options-COWDeANr.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BCjPXFKK.cjs');
2
3
 
3
4
  exports.DEFAULT_UNBUILD_CONFIG = require_resolve_options.DEFAULT_UNBUILD_CONFIG;
4
5
  exports.resolveOptions = require_resolve_options.resolveOptions;
@@ -1,2 +1,2 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-BF6hy5ew.cjs";
1
+ import { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader } from "./resolve-options.cjs";
2
2
  export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
@@ -1,2 +1,2 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-Bnm3rLPK.mjs";
1
+ import { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader } from "./resolve-options.mjs";
2
2
  export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
@@ -1,3 +1,3 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-CpHtoivj.mjs";
1
+ import { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader } from "./resolve-options.mjs";
2
2
 
3
3
  export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
@@ -1,4 +1,5 @@
1
- const require_resolve_options = require('../resolve-options-COWDeANr.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_resolve_options = require('../resolve-options-BCjPXFKK.cjs');
2
3
 
3
4
  exports.DEFAULT_UNBUILD_CONFIG = require_resolve_options.DEFAULT_UNBUILD_CONFIG;
4
5
  exports.resolveOptions = require_resolve_options.resolveOptions;
@@ -1,2 +1,17 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-BF6hy5ew.cjs";
2
- export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
1
+ import { Context } from "@powerlines/core";
2
+ import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
+ import { Loader, UnbuildOptions } from "@storm-software/unbuild/types";
4
+
5
+ //#region src/helpers/resolve-options.d.ts
6
+ declare const DEFAULT_UNBUILD_CONFIG: Partial<UnbuildOptions>;
7
+ declare const unbuildLoader: (context: UNSAFE_PluginContext) => Loader;
8
+ /**
9
+ * Extracts the unbuild configuration from the context.
10
+ *
11
+ * @param context - The build context.
12
+ * @returns The resolved unbuild configuration.
13
+ */
14
+ declare function resolveOptions(context: Context): UnbuildOptions;
15
+ //#endregion
16
+ export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
17
+ //# sourceMappingURL=resolve-options.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.d.cts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"mappings":";;;;;cAkCa,sBAAA,EAqBR,OAAA,CAAQ,cAAA;AAAA,cAEA,aAAA,GAAiB,OAAA,EAAS,oBAAA,KAAuB,MAAA;AAvB9D;;;;;AAuBA;AAvBA,iBAiJgB,cAAA,CAAe,OAAA,EAAS,OAAA,GAAU,cAAA"}
@@ -1,2 +1,17 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-Bnm3rLPK.mjs";
2
- export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
1
+ import { Context } from "@powerlines/core";
2
+ import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
+ import { Loader, UnbuildOptions } from "@storm-software/unbuild/types";
4
+
5
+ //#region src/helpers/resolve-options.d.ts
6
+ declare const DEFAULT_UNBUILD_CONFIG: Partial<UnbuildOptions>;
7
+ declare const unbuildLoader: (context: UNSAFE_PluginContext) => Loader;
8
+ /**
9
+ * Extracts the unbuild configuration from the context.
10
+ *
11
+ * @param context - The build context.
12
+ * @returns The resolved unbuild configuration.
13
+ */
14
+ declare function resolveOptions(context: Context): UnbuildOptions;
15
+ //#endregion
16
+ export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
17
+ //# sourceMappingURL=resolve-options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.d.mts","names":[],"sources":["../../src/helpers/resolve-options.ts"],"mappings":";;;;;cAkCa,sBAAA,EAqBR,OAAA,CAAQ,cAAA;AAAA,cAEA,aAAA,GAAiB,OAAA,EAAS,oBAAA,KAAuB,MAAA;AAvB9D;;;;;AAuBA;AAvBA,iBAiJgB,cAAA,CAAe,OAAA,EAAS,OAAA,GAAU,cAAA"}
@@ -1,3 +1,123 @@
1
- import { n as resolveOptions, r as unbuildLoader, t as DEFAULT_UNBUILD_CONFIG } from "../resolve-options-CpHtoivj.mjs";
1
+ import { getString } from "@powerlines/core/lib/utilities/source-file";
2
+ import { resolveOptions as resolveOptions$1 } from "@powerlines/plugin-rollup/helpers/resolve-options";
3
+ import { joinPaths } from "@stryke/path/join-paths";
4
+ import { isObject } from "@stryke/type-checks/is-object";
5
+ import defu from "defu";
6
+ import { transform } from "esbuild";
2
7
 
3
- export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
8
+ //#region src/helpers/resolve-options.ts
9
+ const DEFAULT_UNBUILD_CONFIG = {
10
+ dts: true,
11
+ clean: false,
12
+ includeSrc: false,
13
+ treeShaking: true,
14
+ splitting: true,
15
+ stub: false,
16
+ watchOptions: {},
17
+ outputPath: "dist",
18
+ generatePackageJson: true,
19
+ banner: " ",
20
+ rollup: {
21
+ dts: {},
22
+ emitCJS: true,
23
+ replace: {},
24
+ resolve: {},
25
+ json: {},
26
+ esbuild: { target: "es2020" },
27
+ commonjs: {},
28
+ alias: {}
29
+ }
30
+ };
31
+ const unbuildLoader = (context) => {
32
+ return async (input, { options }) => {
33
+ if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
34
+ const output = [];
35
+ let contents = await input.getContents();
36
+ if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
37
+ const extension = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
38
+ output.push({
39
+ contents,
40
+ srcPath: input.srcPath,
41
+ path: input.path,
42
+ extension,
43
+ declaration: true
44
+ });
45
+ }
46
+ let transformed = contents;
47
+ let result = await context.$$internal.callHook("transform", {
48
+ sequential: true,
49
+ order: "pre"
50
+ }, transformed, input.path);
51
+ if (result) transformed = result;
52
+ result = await context.$$internal.callHook("transform", {
53
+ sequential: true,
54
+ order: "normal"
55
+ }, getString(transformed), input.path);
56
+ if (result) transformed = result;
57
+ result = await context.$$internal.callHook("transform", {
58
+ sequential: true,
59
+ order: "post"
60
+ }, getString(transformed), input.path);
61
+ if (result) transformed = result;
62
+ if ([
63
+ ".ts",
64
+ ".mts",
65
+ ".cts"
66
+ ].includes(input.extension)) contents = await transform(getString(transformed), {
67
+ ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
68
+ loader: "ts"
69
+ }).then((r) => r.code);
70
+ else if ([".tsx", ".jsx"].includes(input.extension)) contents = await transform(getString(transformed), {
71
+ loader: input.extension === ".tsx" ? "tsx" : "jsx",
72
+ ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
73
+ }).then((r) => r.code);
74
+ const isCjs = options.format === "cjs";
75
+ if (isCjs) contents = context.resolver.transform({
76
+ source: contents,
77
+ retainLines: false
78
+ }).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
79
+ let extension = isCjs ? ".js" : ".mjs";
80
+ if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
81
+ output.push({
82
+ contents,
83
+ path: input.path,
84
+ extension
85
+ });
86
+ return output;
87
+ };
88
+ };
89
+ /**
90
+ * Extracts the unbuild configuration from the context.
91
+ *
92
+ * @param context - The build context.
93
+ * @returns The resolved unbuild configuration.
94
+ */
95
+ function resolveOptions(context) {
96
+ return defu({ alias: context.alias }, context.config.unbuild ? context.config.unbuild : {}, {
97
+ projectName: context.config.name,
98
+ name: context.config.name,
99
+ orgName: isObject(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
100
+ sourceRoot: joinPaths(context.config.root, "src"),
101
+ projectRoot: context.config.root,
102
+ outputPath: context.config.output.buildPath || "dist",
103
+ platform: context.config.platform,
104
+ external: context.builtins.reduce((ret, id) => {
105
+ if (!ret.includes(id)) ret.push(id);
106
+ return ret;
107
+ }, context.config.resolve.external ?? []),
108
+ loaders: [unbuildLoader(context)],
109
+ jiti: {
110
+ interopDefault: true,
111
+ fsCache: joinPaths(context.envPaths.cache, "jiti"),
112
+ moduleCache: true
113
+ },
114
+ rollup: resolveOptions$1(context),
115
+ debug: context.config.mode === "development",
116
+ minify: context.config.mode !== "development",
117
+ sourcemap: context.config.mode === "development"
118
+ }, DEFAULT_UNBUILD_CONFIG);
119
+ }
120
+
121
+ //#endregion
122
+ export { DEFAULT_UNBUILD_CONFIG, resolveOptions, unbuildLoader };
123
+ //# sourceMappingURL=resolve-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.mjs","names":["resolveRollupOptions"],"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 { Context } from \"@powerlines/core\";\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport { UNSAFE_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { resolveOptions as resolveRollupOptions } from \"@powerlines/plugin-rollup/helpers/resolve-options\";\nimport type {\n UnbuildOptions as ExternalUnbuildOptions,\n Loader,\n LoaderResult\n} from \"@storm-software/unbuild/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport defu from \"defu\";\nimport { transform } from \"esbuild\";\nimport { TransformResult } from \"unplugin\";\nimport { UnbuildPluginResolvedConfig } from \"../types\";\n\nexport const DEFAULT_UNBUILD_CONFIG = {\n dts: true,\n clean: false,\n includeSrc: false,\n treeShaking: true,\n splitting: true,\n stub: false,\n watchOptions: {},\n outputPath: \"dist\",\n generatePackageJson: true,\n banner: \" \",\n rollup: {\n dts: {},\n emitCJS: true,\n replace: {},\n resolve: {},\n json: {},\n esbuild: { target: \"es2020\" },\n commonjs: {},\n alias: {}\n }\n} as Partial<ExternalUnbuildOptions>;\n\nexport const unbuildLoader = (context: UNSAFE_PluginContext): Loader => {\n return async (input, { options }) => {\n if (\n !/\\.(?:c|m)?[jt]sx?$/.test(input.path) ||\n /\\.d\\.[cm]?ts$/.test(input.path)\n ) {\n return;\n }\n\n const output: LoaderResult = [];\n\n let contents = await input.getContents();\n\n // declaration\n if (options.declaration && !input.srcPath?.match(/\\.d\\.[cm]?ts$/)) {\n const cm = input.srcPath?.match(/(?<=\\.)(?:c|m)(?=[jt]s$)/)?.[0] || \"\";\n const extension = `.d.${cm}ts`;\n output.push({\n contents,\n srcPath: input.srcPath,\n path: input.path,\n extension,\n declaration: true\n });\n }\n\n let transformed: TransformResult | string = contents;\n\n let result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"pre\"\n },\n transformed,\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"normal\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"post\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n // typescript => js\n if ([\".ts\", \".mts\", \".cts\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n ),\n loader: \"ts\"\n }).then(r => r.code);\n } else if ([\".tsx\", \".jsx\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n loader: input.extension === \".tsx\" ? \"tsx\" : \"jsx\",\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n )\n }).then(r => r.code);\n }\n\n // esm => cjs\n const isCjs = options.format === \"cjs\";\n if (isCjs) {\n contents = context.resolver\n .transform({\n source: contents,\n retainLines: false\n })\n .replace(/^exports.default = /gm, \"module.exports = \")\n .replace(/^var _default = exports.default = /gm, \"module.exports = \")\n .replace(\"module.exports = void 0;\", \"\");\n }\n\n let extension = isCjs ? \".js\" : \".mjs\"; // TODO: Default to .cjs in next major version\n if (options.ext) {\n extension = options.ext.startsWith(\".\") ? options.ext : `.${options.ext}`;\n }\n\n output.push({\n contents,\n path: input.path,\n extension\n });\n\n return output;\n };\n};\n\n/**\n * Extracts the unbuild configuration from the context.\n *\n * @param context - The build context.\n * @returns The resolved unbuild configuration.\n */\nexport function resolveOptions(context: Context): ExternalUnbuildOptions {\n return defu(\n {\n alias: context.alias\n },\n (context.config as UnbuildPluginResolvedConfig).unbuild\n ? (context.config as UnbuildPluginResolvedConfig).unbuild\n : {},\n {\n projectName: context.config.name,\n name: context.config.name,\n orgName: isObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization,\n sourceRoot: joinPaths(context.config.root, \"src\"),\n projectRoot: context.config.root,\n outputPath: context.config.output.buildPath || \"dist\",\n platform: context.config.platform,\n external: context.builtins.reduce((ret, id) => {\n if (!ret.includes(id)) {\n ret.push(id);\n }\n\n return ret;\n }, context.config.resolve.external ?? []),\n loaders: [unbuildLoader(context as UNSAFE_PluginContext)],\n jiti: {\n interopDefault: true,\n fsCache: joinPaths(context.envPaths.cache, \"jiti\"),\n moduleCache: true\n },\n rollup: resolveRollupOptions(context) as any,\n debug: context.config.mode === \"development\",\n minify: context.config.mode !== \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_UNBUILD_CONFIG\n );\n}\n"],"mappings":";;;;;;;;AAkCA,MAAa,yBAAyB;CACpC,KAAK;CACL,OAAO;CACP,YAAY;CACZ,aAAa;CACb,WAAW;CACX,MAAM;CACN,cAAc,EAAE;CAChB,YAA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O;KACN,QAAQ,OAAO,QAAQ,YAAY,EAAE,CAAC;EACzC,SAAS,CAAC,cAAc,QAAgC,CAAC;EACzD,MAAM;GACJ,gBAAgB;GAChB,SAAS,UAAU,QAAQ,SAAS,OAAO,OAAO;GAClD,aAAa;GACd;EACD,QAAQA,iBAAqB,QAAQ;EACrC,OAAO,QAAQ,OAAO,SAAS;EAC/B,QAAQ,QAAQ,OAAO,SAAS;EAChC,WAAW,QAAQ,OAAO,SAAS;EACpC,EACD,uBACD"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_resolve_options = require('./resolve-options-COWDeANr.cjs');
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_resolve_options = require('./resolve-options-BCjPXFKK.cjs');
3
3
  require('./types/index.cjs');
4
- let __storm_software_unbuild = require("@storm-software/unbuild");
4
+ let _storm_software_unbuild = require("@storm-software/unbuild");
5
5
 
6
6
  //#region src/index.ts
7
7
  /**
@@ -20,12 +20,11 @@ const plugin = (options = {}) => {
20
20
  };
21
21
  },
22
22
  async build() {
23
- await (0, __storm_software_unbuild.build)(require_resolve_options.resolveOptions(this));
23
+ await (0, _storm_software_unbuild.build)(require_resolve_options.resolveOptions(this));
24
24
  }
25
25
  };
26
26
  };
27
- var src_default = plugin;
28
27
 
29
28
  //#endregion
30
- exports.default = src_default;
29
+ exports.default = plugin;
31
30
  exports.plugin = plugin;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "./build-D-HKMVs4.cjs";
2
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "./plugin-DeNRjk0Q.cjs";
3
- import "./index-BR1oNnaF.cjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "./build-Dwhf5qER.cjs";
2
+ import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./types/plugin.cjs";
4
3
  import { Plugin } from "@powerlines/core";
5
4
 
6
5
  //#region src/index.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAkCc;EAJU;;;;;AAWX,cAAA,MAsBZ,EAAA,CAAA,iBArBkB,oBAqBlB,GArByC,oBAqBzC,CAAA,CAAA,OAAA,CAAA,EAnBU,oBAmBV,EAAA,GAlBE,MAkBF,CAlBS,QAkBT,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAiCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;cAOD,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "./build-CTNIcTZR.mjs";
2
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "./plugin-iqCdm9Mq.mjs";
3
- import "./index-vkGVyY9v.mjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "./build-BwqbRruN.mjs";
2
+ import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./types/plugin.mjs";
4
3
  import { Plugin } from "@powerlines/core";
5
4
 
6
5
  //#region src/index.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAkCc;EAJU;;;;;AAWX,cAAA,MAsBZ,EAAA,CAAA,iBArBkB,oBAqBlB,GArByC,oBAqBzC,CAAA,CAAA,OAAA,CAAA,EAnBU,oBAmBV,EAAA,GAlBE,MAkBF,CAlBS,QAkBT,CAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAiCY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;;;;cAOD,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as resolveOptions, t as DEFAULT_UNBUILD_CONFIG } from "./resolve-options-CpHtoivj.mjs";
1
+ import { DEFAULT_UNBUILD_CONFIG, resolveOptions } from "./helpers/resolve-options.mjs";
2
2
  import "./types/index.mjs";
3
3
  import { build } from "@storm-software/unbuild";
4
4
 
@@ -23,8 +23,7 @@ const plugin = (options = {}) => {
23
23
  }
24
24
  };
25
25
  };
26
- var src_default = plugin;
27
26
 
28
27
  //#endregion
29
- export { src_default as default, plugin };
28
+ export { plugin as default, plugin };
30
29
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Plugin } from \"@powerlines/core\";\nimport { build } from \"@storm-software/unbuild\";\nimport {\n DEFAULT_UNBUILD_CONFIG,\n resolveOptions\n} from \"./helpers/resolve-options\";\nimport {\n UnbuildPluginContext,\n UnbuildPluginOptions,\n UnbuildPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface Config {\n unbuild?: UnbuildPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to build projects using Unbuild.\n */\nexport const plugin = <\n TContext extends UnbuildPluginContext = UnbuildPluginContext\n>(\n options: UnbuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"unbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n unbuild: {\n ...DEFAULT_UNBUILD_CONFIG,\n ...options\n }\n } as Partial<UnbuildPluginResolvedConfig>;\n },\n async build() {\n await build(resolveOptions(this));\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;AAyCA,MAAa,UAGX,UAAgC,EAAE,KACb;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO;IACL,QAAQ,EACN,QAAQ,CAAC,MAAM,EAChB;IACD,SAAS;KACP,GAAG;KACH,GAAG;KACJ;IACF;;EAEH,MAAM,QAAQ;AACZ,SAAM,MAAM,eAAe,KAAK,CAAC;;EAEpC;;AAGH,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Plugin } from \"@powerlines/core\";\nimport { build } from \"@storm-software/unbuild\";\nimport {\n DEFAULT_UNBUILD_CONFIG,\n resolveOptions\n} from \"./helpers/resolve-options\";\nimport {\n UnbuildPluginContext,\n UnbuildPluginOptions,\n UnbuildPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface Config {\n unbuild?: UnbuildPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to build projects using Unbuild.\n */\nexport const plugin = <\n TContext extends UnbuildPluginContext = UnbuildPluginContext\n>(\n options: UnbuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"unbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n unbuild: {\n ...DEFAULT_UNBUILD_CONFIG,\n ...options\n }\n } as Partial<UnbuildPluginResolvedConfig>;\n },\n async build() {\n await build(resolveOptions(this));\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;AAyCA,MAAa,UAGX,UAAgC,EAAE,KACb;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO;IACL,QAAQ,EACN,QAAQ,CAAC,MAAM,EAChB;IACD,SAAS;KACP,GAAG;KACH,GAAG;KACJ;IACF;;EAEH,MAAM,QAAQ;AACZ,SAAM,MAAM,eAAe,KAAK,CAAC;;EAEpC"}
@@ -1,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -25,10 +25,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- let __powerlines_core_lib_utilities_source_file = require("@powerlines/core/lib/utilities/source-file");
29
- let __powerlines_plugin_rollup_helpers_resolve_options = require("@powerlines/plugin-rollup/helpers/resolve-options");
30
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
31
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
28
+ let _powerlines_core_lib_utilities_source_file = require("@powerlines/core/lib/utilities/source-file");
29
+ let _powerlines_plugin_rollup_helpers_resolve_options = require("@powerlines/plugin-rollup/helpers/resolve-options");
30
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
31
+ let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
32
32
  let defu = require("defu");
33
33
  defu = __toESM(defu);
34
34
  let esbuild = require("esbuild");
@@ -62,12 +62,12 @@ const unbuildLoader = (context) => {
62
62
  const output = [];
63
63
  let contents = await input.getContents();
64
64
  if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
65
- const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
65
+ const extension = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
66
66
  output.push({
67
67
  contents,
68
68
  srcPath: input.srcPath,
69
69
  path: input.path,
70
- extension: extension$1,
70
+ extension,
71
71
  declaration: true
72
72
  });
73
73
  }
@@ -80,22 +80,22 @@ const unbuildLoader = (context) => {
80
80
  result = await context.$$internal.callHook("transform", {
81
81
  sequential: true,
82
82
  order: "normal"
83
- }, (0, __powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
83
+ }, (0, _powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
84
84
  if (result) transformed = result;
85
85
  result = await context.$$internal.callHook("transform", {
86
86
  sequential: true,
87
87
  order: "post"
88
- }, (0, __powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
88
+ }, (0, _powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
89
89
  if (result) transformed = result;
90
90
  if ([
91
91
  ".ts",
92
92
  ".mts",
93
93
  ".cts"
94
- ].includes(input.extension)) contents = await (0, esbuild.transform)((0, __powerlines_core_lib_utilities_source_file.getString)(transformed), {
94
+ ].includes(input.extension)) contents = await (0, esbuild.transform)((0, _powerlines_core_lib_utilities_source_file.getString)(transformed), {
95
95
  ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
96
96
  loader: "ts"
97
97
  }).then((r) => r.code);
98
- else if ([".tsx", ".jsx"].includes(input.extension)) contents = await (0, esbuild.transform)((0, __powerlines_core_lib_utilities_source_file.getString)(transformed), {
98
+ else if ([".tsx", ".jsx"].includes(input.extension)) contents = await (0, esbuild.transform)((0, _powerlines_core_lib_utilities_source_file.getString)(transformed), {
99
99
  loader: input.extension === ".tsx" ? "tsx" : "jsx",
100
100
  ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
101
101
  }).then((r) => r.code);
@@ -124,8 +124,8 @@ function resolveOptions(context) {
124
124
  return (0, defu.default)({ alias: context.alias }, context.config.unbuild ? context.config.unbuild : {}, {
125
125
  projectName: context.config.name,
126
126
  name: context.config.name,
127
- orgName: (0, __stryke_type_checks_is_object.isObject)(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
128
- sourceRoot: (0, __stryke_path_join_paths.joinPaths)(context.config.root, "src"),
127
+ orgName: (0, _stryke_type_checks_is_object.isObject)(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
128
+ sourceRoot: (0, _stryke_path_join_paths.joinPaths)(context.config.root, "src"),
129
129
  projectRoot: context.config.root,
130
130
  outputPath: context.config.output.buildPath || "dist",
131
131
  platform: context.config.platform,
@@ -136,10 +136,10 @@ function resolveOptions(context) {
136
136
  loaders: [unbuildLoader(context)],
137
137
  jiti: {
138
138
  interopDefault: true,
139
- fsCache: (0, __stryke_path_join_paths.joinPaths)(context.envPaths.cache, "jiti"),
139
+ fsCache: (0, _stryke_path_join_paths.joinPaths)(context.envPaths.cache, "jiti"),
140
140
  moduleCache: true
141
141
  },
142
- rollup: (0, __powerlines_plugin_rollup_helpers_resolve_options.resolveOptions)(context),
142
+ rollup: (0, _powerlines_plugin_rollup_helpers_resolve_options.resolveOptions)(context),
143
143
  debug: context.config.mode === "development",
144
144
  minify: context.config.mode !== "development",
145
145
  sourcemap: context.config.mode === "development"
@@ -1,2 +1,2 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-D-HKMVs4.cjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-Dwhf5qER.cjs";
2
2
  export { UnbuildOptions, __ΩUnbuildOptions };
@@ -1,2 +1,2 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-CTNIcTZR.mjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-BwqbRruN.mjs";
2
2
  export { UnbuildOptions, __ΩUnbuildOptions };
@@ -1,4 +1,3 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-D-HKMVs4.cjs";
2
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "../plugin-DeNRjk0Q.cjs";
3
- import "../index-BR1oNnaF.cjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-Dwhf5qER.cjs";
2
+ import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./plugin.cjs";
4
3
  export { UnbuildOptions, UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildOptions, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1,4 +1,3 @@
1
- import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-CTNIcTZR.mjs";
2
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "../plugin-iqCdm9Mq.mjs";
3
- import "../index-vkGVyY9v.mjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-BwqbRruN.mjs";
2
+ import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./plugin.mjs";
4
3
  export { UnbuildOptions, UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildOptions, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1,2 +1,19 @@
1
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "../plugin-DeNRjk0Q.cjs";
2
- export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
1
+ import { t as UnbuildOptions } from "../build-Dwhf5qER.cjs";
2
+ import { PluginContext, ResolvedConfig, UserConfig } from "@powerlines/core";
3
+
4
+ //#region src/types/plugin.d.ts
5
+ type UnbuildPluginOptions = Partial<UnbuildOptions>;
6
+ interface UnbuildPluginUserConfig extends UserConfig {
7
+ unbuild?: UnbuildPluginOptions;
8
+ }
9
+ interface UnbuildPluginResolvedConfig extends ResolvedConfig {
10
+ unbuild: UnbuildOptions;
11
+ }
12
+ type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
13
+ declare type __ΩUnbuildPluginOptions = any[];
14
+ declare type __ΩUnbuildPluginUserConfig = any[];
15
+ declare type __ΩUnbuildPluginResolvedConfig = any[];
16
+ declare type __ΩUnbuildPluginContext = any[];
17
+ //#endregion
18
+ export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
19
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAqBY,oBAAA,GAAuB,OAAA,CAAQ,cAAA;AAAA,UAE1B,uBAAA,SAAgC,UAAA;EAC/C,OAAA,GAAU,oBAAA;AAAA;AAAA,UAGK,2BAAA,SAAoC,cAAA;EACnD,OAAA,EAAS,cAAA;AAAA;AAAA,KAGC,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
@@ -1,2 +1,19 @@
1
- import { a as __ΩUnbuildPluginContext, c as __ΩUnbuildPluginUserConfig, i as UnbuildPluginUserConfig, n as UnbuildPluginOptions, o as __ΩUnbuildPluginOptions, r as UnbuildPluginResolvedConfig, s as __ΩUnbuildPluginResolvedConfig, t as UnbuildPluginContext } from "../plugin-iqCdm9Mq.mjs";
2
- export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
1
+ import { t as UnbuildOptions } from "../build-BwqbRruN.mjs";
2
+ import { PluginContext, ResolvedConfig, UserConfig } from "@powerlines/core";
3
+
4
+ //#region src/types/plugin.d.ts
5
+ type UnbuildPluginOptions = Partial<UnbuildOptions>;
6
+ interface UnbuildPluginUserConfig extends UserConfig {
7
+ unbuild?: UnbuildPluginOptions;
8
+ }
9
+ interface UnbuildPluginResolvedConfig extends ResolvedConfig {
10
+ unbuild: UnbuildOptions;
11
+ }
12
+ type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
13
+ declare type __ΩUnbuildPluginOptions = any[];
14
+ declare type __ΩUnbuildPluginUserConfig = any[];
15
+ declare type __ΩUnbuildPluginResolvedConfig = any[];
16
+ declare type __ΩUnbuildPluginContext = any[];
17
+ //#endregion
18
+ export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
19
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;KAqBY,oBAAA,GAAuB,OAAA,CAAQ,cAAA;AAAA,UAE1B,uBAAA,SAAgC,UAAA;EAC/C,OAAA,GAAU,oBAAA;AAAA;AAAA,UAGK,2BAAA,SAAoC,cAAA;EACnD,OAAA,EAAS,cAAA;AAAA;AAAA,KAGC,oBAAA,yBACc,2BAAA,GACtB,2BAAA,IACA,aAAA,CAAc,eAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unbuild",
3
- "version": "0.5.345",
3
+ "version": "0.5.346",
4
4
  "private": false,
5
5
  "description": "A package containing a Powerlines plugin to build projects using Unbuild.",
6
6
  "keywords": ["unbuild", "powerlines", "storm-software", "powerlines-plugin"],
@@ -40,26 +40,27 @@
40
40
  ],
41
41
  "type": "module",
42
42
  "exports": {
43
- ".": { "require": "./dist/index.cjs", "import": "./dist/index.mjs" },
43
+ ".": { "import": "./dist/index.mjs", "require": "./dist/index.cjs" },
44
44
  "./helpers": {
45
- "require": "./dist/helpers/index.cjs",
46
- "import": "./dist/helpers/index.mjs"
45
+ "import": "./dist/helpers/index.mjs",
46
+ "require": "./dist/helpers/index.cjs"
47
47
  },
48
48
  "./helpers/resolve-options": {
49
- "require": "./dist/helpers/resolve-options.cjs",
50
- "import": "./dist/helpers/resolve-options.mjs"
49
+ "import": "./dist/helpers/resolve-options.mjs",
50
+ "require": "./dist/helpers/resolve-options.cjs"
51
51
  },
52
+ "./resolve-options-BCjPXFKK": "./dist/resolve-options-BCjPXFKK.cjs",
52
53
  "./types": {
53
- "require": "./dist/types/index.cjs",
54
- "import": "./dist/types/index.mjs"
54
+ "import": "./dist/types/index.mjs",
55
+ "require": "./dist/types/index.cjs"
55
56
  },
56
57
  "./types/build": {
57
- "require": "./dist/types/build.cjs",
58
- "import": "./dist/types/build.mjs"
58
+ "import": "./dist/types/build.mjs",
59
+ "require": "./dist/types/build.cjs"
59
60
  },
60
61
  "./types/plugin": {
61
- "require": "./dist/types/plugin.cjs",
62
- "import": "./dist/types/plugin.mjs"
62
+ "import": "./dist/types/plugin.mjs",
63
+ "require": "./dist/types/plugin.cjs"
63
64
  },
64
65
  "./*": "./*"
65
66
  },
@@ -69,12 +70,12 @@
69
70
  "typings": "dist/index.d.mts",
70
71
  "files": ["dist/**/*"],
71
72
  "dependencies": {
72
- "@powerlines/core": "^0.2.22",
73
- "@powerlines/plugin-rollup": "^0.7.345",
73
+ "@powerlines/core": "^0.2.23",
74
+ "@powerlines/plugin-rollup": "^0.7.346",
74
75
  "@stryke/path": "^0.26.19",
75
76
  "@stryke/type-checks": "^0.5.38",
76
77
  "defu": "^6.1.4",
77
- "esbuild": "^0.25.12",
78
+ "esbuild": "^0.27.3",
78
79
  "unplugin": "^3.0.0"
79
80
  },
80
81
  "devDependencies": {
@@ -84,5 +85,5 @@
84
85
  "peerDependencies": { "@storm-software/unbuild": ">=0.57.0" },
85
86
  "peerDependenciesMeta": { "@storm-software/unbuild": { "optional": false } },
86
87
  "publishConfig": { "access": "public" },
87
- "gitHead": "0ed0ad0cd6f440d1584ac705987ef985931161db"
88
+ "gitHead": "2fb48143904805988bac9bdbc04cdc4a35ff398b"
88
89
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-CTNIcTZR.d.mts","names":[],"sources":["../src/types/build.ts"],"sourcesContent":[],"mappings":";;;KAoBY,gBAAA,GAAiB,QAC3B,KACE"}
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-D-HKMVs4.d.cts","names":[],"sources":["../src/types/build.ts"],"sourcesContent":[],"mappings":";;;KAoBY,gBAAA,GAAiB,QAC3B,KACE"}
File without changes
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,19 +0,0 @@
1
- import { t as UnbuildOptions } from "./build-D-HKMVs4.cjs";
2
- import { PluginContext, ResolvedConfig, UserConfig } from "@powerlines/core";
3
-
4
- //#region src/types/plugin.d.ts
5
- type UnbuildPluginOptions = Partial<UnbuildOptions>;
6
- interface UnbuildPluginUserConfig extends UserConfig {
7
- unbuild?: UnbuildPluginOptions;
8
- }
9
- interface UnbuildPluginResolvedConfig extends ResolvedConfig {
10
- unbuild: UnbuildOptions;
11
- }
12
- type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
13
- declare type __ΩUnbuildPluginOptions = any[];
14
- declare type __ΩUnbuildPluginUserConfig = any[];
15
- declare type __ΩUnbuildPluginResolvedConfig = any[];
16
- declare type __ΩUnbuildPluginContext = any[];
17
- //#endregion
18
- export { __ΩUnbuildPluginContext as a, __ΩUnbuildPluginUserConfig as c, UnbuildPluginUserConfig as i, UnbuildPluginOptions as n, __ΩUnbuildPluginOptions as o, UnbuildPluginResolvedConfig as r, __ΩUnbuildPluginResolvedConfig as s, UnbuildPluginContext as t };
19
- //# sourceMappingURL=plugin-DeNRjk0Q.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-DeNRjk0Q.d.cts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,oBAAA,GAAuB,QAAQ;UAE1B,uBAAA,SAAgC;EAFrC,OAAA,CAAA,EAGA,oBAHoB;AAEhC;AAIiB,UAAA,2BAAA,SAAoC,cAAA,CAAA;EAIzC,OAAA,EAHD,cAGqB;;AAE5B,KAFQ,oBAER,CAAA,wBADsB,2BACtB,GAAA,2BAAA,CAAA,GACA,aADA,CACc,eADd,CAAA;AACc,uCAAA,GAAA,EAAA;AAAd,0CAAA,GAAA,EAAA;AAAa,8CAAA,GAAA,EAAA"}
@@ -1,19 +0,0 @@
1
- import { t as UnbuildOptions } from "./build-CTNIcTZR.mjs";
2
- import { PluginContext, ResolvedConfig, UserConfig } from "@powerlines/core";
3
-
4
- //#region src/types/plugin.d.ts
5
- type UnbuildPluginOptions = Partial<UnbuildOptions>;
6
- interface UnbuildPluginUserConfig extends UserConfig {
7
- unbuild?: UnbuildPluginOptions;
8
- }
9
- interface UnbuildPluginResolvedConfig extends ResolvedConfig {
10
- unbuild: UnbuildOptions;
11
- }
12
- type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
13
- declare type __ΩUnbuildPluginOptions = any[];
14
- declare type __ΩUnbuildPluginUserConfig = any[];
15
- declare type __ΩUnbuildPluginResolvedConfig = any[];
16
- declare type __ΩUnbuildPluginContext = any[];
17
- //#endregion
18
- export { __ΩUnbuildPluginContext as a, __ΩUnbuildPluginUserConfig as c, UnbuildPluginUserConfig as i, UnbuildPluginOptions as n, __ΩUnbuildPluginOptions as o, UnbuildPluginResolvedConfig as r, __ΩUnbuildPluginResolvedConfig as s, UnbuildPluginContext as t };
19
- //# sourceMappingURL=plugin-iqCdm9Mq.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-iqCdm9Mq.d.mts","names":[],"sources":["../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,oBAAA,GAAuB,QAAQ;UAE1B,uBAAA,SAAgC;EAFrC,OAAA,CAAA,EAGA,oBAHoB;AAEhC;AAIiB,UAAA,2BAAA,SAAoC,cAAA,CAAA;EAIzC,OAAA,EAHD,cAGqB;;AAE5B,KAFQ,oBAER,CAAA,wBADsB,2BACtB,GAAA,2BAAA,CAAA,GACA,aADA,CACc,eADd,CAAA;AACc,uCAAA,GAAA,EAAA;AAAd,0CAAA,GAAA,EAAA;AAAa,8CAAA,GAAA,EAAA"}
@@ -1 +0,0 @@
1
- export { };
File without changes
@@ -1,17 +0,0 @@
1
- import { Context } from "@powerlines/core";
2
- import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
- import { Loader, UnbuildOptions } from "@storm-software/unbuild/types";
4
-
5
- //#region src/helpers/resolve-options.d.ts
6
- declare const DEFAULT_UNBUILD_CONFIG: Partial<UnbuildOptions>;
7
- declare const unbuildLoader: (context: UNSAFE_PluginContext) => Loader;
8
- /**
9
- * Extracts the unbuild configuration from the context.
10
- *
11
- * @param context - The build context.
12
- * @returns The resolved unbuild configuration.
13
- */
14
- declare function resolveOptions(context: Context): UnbuildOptions;
15
- //#endregion
16
- export { resolveOptions as n, unbuildLoader as r, DEFAULT_UNBUILD_CONFIG as t };
17
- //# sourceMappingURL=resolve-options-BF6hy5ew.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-options-BF6hy5ew.d.cts","names":[],"sources":["../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;AAvB9D;AAuBA;AA0HA;;;;iBAAgB,cAAA,UAAwB,UAAU"}
@@ -1,17 +0,0 @@
1
- import { Context } from "@powerlines/core";
2
- import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
- import { Loader, UnbuildOptions } from "@storm-software/unbuild/types";
4
-
5
- //#region src/helpers/resolve-options.d.ts
6
- declare const DEFAULT_UNBUILD_CONFIG: Partial<UnbuildOptions>;
7
- declare const unbuildLoader: (context: UNSAFE_PluginContext) => Loader;
8
- /**
9
- * Extracts the unbuild configuration from the context.
10
- *
11
- * @param context - The build context.
12
- * @returns The resolved unbuild configuration.
13
- */
14
- declare function resolveOptions(context: Context): UnbuildOptions;
15
- //#endregion
16
- export { resolveOptions as n, unbuildLoader as r, DEFAULT_UNBUILD_CONFIG as t };
17
- //# sourceMappingURL=resolve-options-Bnm3rLPK.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-options-Bnm3rLPK.d.mts","names":[],"sources":["../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;AAvB9D;AAuBA;AA0HA;;;;iBAAgB,cAAA,UAAwB,UAAU"}
@@ -1,123 +0,0 @@
1
- import { getString } from "@powerlines/core/lib/utilities/source-file";
2
- import { resolveOptions } from "@powerlines/plugin-rollup/helpers/resolve-options";
3
- import { joinPaths } from "@stryke/path/join-paths";
4
- import { isObject } from "@stryke/type-checks/is-object";
5
- import defu from "defu";
6
- import { transform } from "esbuild";
7
-
8
- //#region src/helpers/resolve-options.ts
9
- const DEFAULT_UNBUILD_CONFIG = {
10
- dts: true,
11
- clean: false,
12
- includeSrc: false,
13
- treeShaking: true,
14
- splitting: true,
15
- stub: false,
16
- watchOptions: {},
17
- outputPath: "dist",
18
- generatePackageJson: true,
19
- banner: " ",
20
- rollup: {
21
- dts: {},
22
- emitCJS: true,
23
- replace: {},
24
- resolve: {},
25
- json: {},
26
- esbuild: { target: "es2020" },
27
- commonjs: {},
28
- alias: {}
29
- }
30
- };
31
- const unbuildLoader = (context) => {
32
- return async (input, { options }) => {
33
- if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
34
- const output = [];
35
- let contents = await input.getContents();
36
- if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
37
- const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
38
- output.push({
39
- contents,
40
- srcPath: input.srcPath,
41
- path: input.path,
42
- extension: extension$1,
43
- declaration: true
44
- });
45
- }
46
- let transformed = contents;
47
- let result = await context.$$internal.callHook("transform", {
48
- sequential: true,
49
- order: "pre"
50
- }, transformed, input.path);
51
- if (result) transformed = result;
52
- result = await context.$$internal.callHook("transform", {
53
- sequential: true,
54
- order: "normal"
55
- }, getString(transformed), input.path);
56
- if (result) transformed = result;
57
- result = await context.$$internal.callHook("transform", {
58
- sequential: true,
59
- order: "post"
60
- }, getString(transformed), input.path);
61
- if (result) transformed = result;
62
- if ([
63
- ".ts",
64
- ".mts",
65
- ".cts"
66
- ].includes(input.extension)) contents = await transform(getString(transformed), {
67
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
68
- loader: "ts"
69
- }).then((r) => r.code);
70
- else if ([".tsx", ".jsx"].includes(input.extension)) contents = await transform(getString(transformed), {
71
- loader: input.extension === ".tsx" ? "tsx" : "jsx",
72
- ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
73
- }).then((r) => r.code);
74
- const isCjs = options.format === "cjs";
75
- if (isCjs) contents = context.resolver.transform({
76
- source: contents,
77
- retainLines: false
78
- }).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
79
- let extension = isCjs ? ".js" : ".mjs";
80
- if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
81
- output.push({
82
- contents,
83
- path: input.path,
84
- extension
85
- });
86
- return output;
87
- };
88
- };
89
- /**
90
- * Extracts the unbuild configuration from the context.
91
- *
92
- * @param context - The build context.
93
- * @returns The resolved unbuild configuration.
94
- */
95
- function resolveOptions$1(context) {
96
- return defu({ alias: context.alias }, context.config.unbuild ? context.config.unbuild : {}, {
97
- projectName: context.config.name,
98
- name: context.config.name,
99
- orgName: isObject(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
100
- sourceRoot: joinPaths(context.config.root, "src"),
101
- projectRoot: context.config.root,
102
- outputPath: context.config.output.buildPath || "dist",
103
- platform: context.config.platform,
104
- external: context.builtins.reduce((ret, id) => {
105
- if (!ret.includes(id)) ret.push(id);
106
- return ret;
107
- }, context.config.resolve.external ?? []),
108
- loaders: [unbuildLoader(context)],
109
- jiti: {
110
- interopDefault: true,
111
- fsCache: joinPaths(context.envPaths.cache, "jiti"),
112
- moduleCache: true
113
- },
114
- rollup: resolveOptions(context),
115
- debug: context.config.mode === "development",
116
- minify: context.config.mode !== "development",
117
- sourcemap: context.config.mode === "development"
118
- }, DEFAULT_UNBUILD_CONFIG);
119
- }
120
-
121
- //#endregion
122
- export { resolveOptions$1 as n, unbuildLoader as r, DEFAULT_UNBUILD_CONFIG as t };
123
- //# sourceMappingURL=resolve-options-CpHtoivj.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-options-CpHtoivj.mjs","names":["output: LoaderResult","extension","transformed: TransformResult | string","resolveOptions","resolveRollupOptions"],"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 { Context } from \"@powerlines/core\";\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport { UNSAFE_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { resolveOptions as resolveRollupOptions } from \"@powerlines/plugin-rollup/helpers/resolve-options\";\nimport type {\n UnbuildOptions as ExternalUnbuildOptions,\n Loader,\n LoaderResult\n} from \"@storm-software/unbuild/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport defu from \"defu\";\nimport { transform } from \"esbuild\";\nimport { TransformResult } from \"unplugin\";\nimport { UnbuildPluginResolvedConfig } from \"../types\";\n\nexport const DEFAULT_UNBUILD_CONFIG = {\n dts: true,\n clean: false,\n includeSrc: false,\n treeShaking: true,\n splitting: true,\n stub: false,\n watchOptions: {},\n outputPath: \"dist\",\n generatePackageJson: true,\n banner: \" \",\n rollup: {\n dts: {},\n emitCJS: true,\n replace: {},\n resolve: {},\n json: {},\n esbuild: { target: \"es2020\" },\n commonjs: {},\n alias: {}\n }\n} as Partial<ExternalUnbuildOptions>;\n\nexport const unbuildLoader = (context: UNSAFE_PluginContext): Loader => {\n return async (input, { options }) => {\n if (\n !/\\.(?:c|m)?[jt]sx?$/.test(input.path) ||\n /\\.d\\.[cm]?ts$/.test(input.path)\n ) {\n return;\n }\n\n const output: LoaderResult = [];\n\n let contents = await input.getContents();\n\n // declaration\n if (options.declaration && !input.srcPath?.match(/\\.d\\.[cm]?ts$/)) {\n const cm = input.srcPath?.match(/(?<=\\.)(?:c|m)(?=[jt]s$)/)?.[0] || \"\";\n const extension = `.d.${cm}ts`;\n output.push({\n contents,\n srcPath: input.srcPath,\n path: input.path,\n extension,\n declaration: true\n });\n }\n\n let transformed: TransformResult | string = contents;\n\n let result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"pre\"\n },\n transformed,\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"normal\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n result = await context.$$internal.callHook(\n \"transform\",\n {\n sequential: true,\n order: \"post\"\n },\n getString(transformed),\n input.path\n );\n if (result) {\n transformed = result;\n }\n\n // typescript => js\n if ([\".ts\", \".mts\", \".cts\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n ),\n loader: \"ts\"\n }).then(r => r.code);\n } else if ([\".tsx\", \".jsx\"].includes(input.extension)) {\n contents = await transform(getString(transformed), {\n loader: input.extension === \".tsx\" ? \"tsx\" : \"jsx\",\n ...Object.fromEntries(\n Object.entries(options.esbuild ?? {}).filter(\n ([key]) => key !== \"absPaths\"\n )\n )\n }).then(r => r.code);\n }\n\n // esm => cjs\n const isCjs = options.format === \"cjs\";\n if (isCjs) {\n contents = context.resolver\n .transform({\n source: contents,\n retainLines: false\n })\n .replace(/^exports.default = /gm, \"module.exports = \")\n .replace(/^var _default = exports.default = /gm, \"module.exports = \")\n .replace(\"module.exports = void 0;\", \"\");\n }\n\n let extension = isCjs ? \".js\" : \".mjs\"; // TODO: Default to .cjs in next major version\n if (options.ext) {\n extension = options.ext.startsWith(\".\") ? options.ext : `.${options.ext}`;\n }\n\n output.push({\n contents,\n path: input.path,\n extension\n });\n\n return output;\n };\n};\n\n/**\n * Extracts the unbuild configuration from the context.\n *\n * @param context - The build context.\n * @returns The resolved unbuild configuration.\n */\nexport function resolveOptions(context: Context): ExternalUnbuildOptions {\n return defu(\n {\n alias: context.alias\n },\n (context.config as UnbuildPluginResolvedConfig).unbuild\n ? (context.config as UnbuildPluginResolvedConfig).unbuild\n : {},\n {\n projectName: context.config.name,\n name: context.config.name,\n orgName: isObject(context.workspaceConfig.organization)\n ? context.workspaceConfig.organization.name\n : context.workspaceConfig.organization,\n sourceRoot: joinPaths(context.config.root, \"src\"),\n projectRoot: context.config.root,\n outputPath: context.config.output.buildPath || \"dist\",\n platform: context.config.platform,\n external: context.builtins.reduce((ret, id) => {\n if (!ret.includes(id)) {\n ret.push(id);\n }\n\n return ret;\n }, context.config.resolve.external ?? []),\n loaders: [unbuildLoader(context as UNSAFE_PluginContext)],\n jiti: {\n interopDefault: true,\n fsCache: joinPaths(context.envPaths.cache, \"jiti\"),\n moduleCache: true\n },\n rollup: resolveRollupOptions(context) as any,\n debug: context.config.mode === \"development\",\n minify: context.config.mode !== \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_UNBUILD_CONFIG\n );\n}\n"],"mappings":";;;;;;;;AAkCA,MAAa,yBAAyB;CACpC,KAAK;CACL,OAAO;CACP,YAAY;CACZ,aAAa;CACb,WAAW;CACX,MAAM;CACN,cAAc,EAAE;CAChB,YAAY;CACZ,qBAAqB;CACrB,QAAQ;CACR,QAAQ;EACN,KAAK,EAAE;EACP,SAAS;EACT,SAAS,EAAE;EACX,SAAS,EAAE;EACX,MAAM,EAAE;EACR,SAAS,EAAE,QAAQ,UAAU;EAC7B,UAAU,EAAE;EACZ,OAAO,EAAE;EACV;CACF;AAED,MAAa,iBAAiB,YAA0C;AACtE,QAAO,OAAO,OAAO,EAAE,cAAc;AACnC,MACE,CAAC,qBAAqB,KAAK,MAAM,KAAK,IACtC,gBAAgB,KAAK,MAAM,KAAK,CAEhC;EAGF,MAAMA,SAAuB,EAAE;EAE/B,IAAI,WAAW,MAAM,MAAM,aAAa;AAGxC,MAAI,QAAQ,eAAe,CAAC,MAAM,SAAS,MAAM,gBAAgB,EAAE;GAEjE,MAAMC,cAAY,MADP,MAAM,SAA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