@powerlines/plugin-unbuild 0.5.307 → 0.5.309

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 (106) hide show
  1. package/dist/build-BGmzCfG9.d.mts +8 -0
  2. package/dist/build-BGmzCfG9.d.mts.map +1 -0
  3. package/dist/build-CcJjLdFm.mjs +1 -0
  4. package/dist/build-D-HKMVs4.d.cts +8 -0
  5. package/dist/build-D-HKMVs4.d.cts.map +1 -0
  6. package/dist/build-MNonspIb.cjs +0 -0
  7. package/dist/helpers/index.cjs +4 -4
  8. package/dist/helpers/index.d.cts +1 -1
  9. package/dist/helpers/index.d.mts +1 -1
  10. package/dist/helpers/index.mjs +1 -1
  11. package/dist/helpers/resolve-options.cjs +4 -125
  12. package/dist/helpers/resolve-options.d.cts +2 -17
  13. package/dist/helpers/resolve-options.d.mts +2 -18
  14. package/dist/helpers/resolve-options.mjs +2 -122
  15. package/dist/index-BR1oNnaF.d.cts +1 -0
  16. package/dist/index-DEHBdV_z.d.mts +1 -0
  17. package/dist/index.cjs +6 -4
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.cts.map +1 -1
  20. package/dist/index.d.mts +4 -5
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +4 -1
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/plugin-CXxxQ0lD.d.cts +19 -0
  25. package/dist/plugin-CXxxQ0lD.d.cts.map +1 -0
  26. package/dist/plugin-Dt6qEKIr.d.mts +19 -0
  27. package/dist/plugin-Dt6qEKIr.d.mts.map +1 -0
  28. package/dist/plugin-jZ9N9Mz-.mjs +1 -0
  29. package/dist/plugin-pBKbb5K9.cjs +0 -0
  30. package/dist/resolve-options-COWDeANr.cjs +173 -0
  31. package/dist/resolve-options-CpHtoivj.mjs +123 -0
  32. package/dist/resolve-options-CpHtoivj.mjs.map +1 -0
  33. package/dist/resolve-options-DPRrB4Qj.d.cts +17 -0
  34. package/dist/resolve-options-DPRrB4Qj.d.cts.map +1 -0
  35. package/dist/resolve-options-DRA_XDDs.d.mts +17 -0
  36. package/dist/resolve-options-DRA_XDDs.d.mts.map +1 -0
  37. package/dist/types/build.cjs +1 -0
  38. package/dist/types/build.d.cts +2 -8
  39. package/dist/types/build.d.mts +2 -8
  40. package/dist/types/build.mjs +2 -0
  41. package/dist/types/index.cjs +3 -0
  42. package/dist/types/index.d.cts +3 -2
  43. package/dist/types/index.d.mts +3 -2
  44. package/dist/types/index.mjs +4 -0
  45. package/dist/types/plugin.cjs +1 -0
  46. package/dist/types/plugin.d.cts +3 -20
  47. package/dist/types/plugin.d.mts +3 -21
  48. package/dist/types/plugin.mjs +2 -0
  49. package/dist/types-BtDR9wb1.mjs +1 -0
  50. package/dist/types-o3zWarRp.cjs +0 -0
  51. package/package.json +4 -4
  52. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  53. package/dist/core/src/lib/utilities/source-file.cjs +0 -22
  54. package/dist/core/src/lib/utilities/source-file.mjs +0 -22
  55. package/dist/core/src/lib/utilities/source-file.mjs.map +0 -1
  56. package/dist/core/src/types/_internal.d.cts +0 -85
  57. package/dist/core/src/types/_internal.d.cts.map +0 -1
  58. package/dist/core/src/types/_internal.d.mts +0 -85
  59. package/dist/core/src/types/_internal.d.mts.map +0 -1
  60. package/dist/core/src/types/api.d.cts +0 -103
  61. package/dist/core/src/types/api.d.cts.map +0 -1
  62. package/dist/core/src/types/api.d.mts +0 -103
  63. package/dist/core/src/types/api.d.mts.map +0 -1
  64. package/dist/core/src/types/commands.d.cts +0 -9
  65. package/dist/core/src/types/commands.d.cts.map +0 -1
  66. package/dist/core/src/types/commands.d.mts +0 -10
  67. package/dist/core/src/types/commands.d.mts.map +0 -1
  68. package/dist/core/src/types/config.d.cts +0 -551
  69. package/dist/core/src/types/config.d.cts.map +0 -1
  70. package/dist/core/src/types/config.d.mts +0 -551
  71. package/dist/core/src/types/config.d.mts.map +0 -1
  72. package/dist/core/src/types/context.d.cts +0 -511
  73. package/dist/core/src/types/context.d.cts.map +0 -1
  74. package/dist/core/src/types/context.d.mts +0 -511
  75. package/dist/core/src/types/context.d.mts.map +0 -1
  76. package/dist/core/src/types/fs.d.cts +0 -487
  77. package/dist/core/src/types/fs.d.cts.map +0 -1
  78. package/dist/core/src/types/fs.d.mts +0 -487
  79. package/dist/core/src/types/fs.d.mts.map +0 -1
  80. package/dist/core/src/types/hooks.d.cts +0 -99
  81. package/dist/core/src/types/hooks.d.cts.map +0 -1
  82. package/dist/core/src/types/hooks.d.mts +0 -99
  83. package/dist/core/src/types/hooks.d.mts.map +0 -1
  84. package/dist/core/src/types/index.d.mts +0 -9
  85. package/dist/core/src/types/plugin.d.cts +0 -204
  86. package/dist/core/src/types/plugin.d.cts.map +0 -1
  87. package/dist/core/src/types/plugin.d.mts +0 -204
  88. package/dist/core/src/types/plugin.d.mts.map +0 -1
  89. package/dist/core/src/types/tsconfig.d.cts +0 -70
  90. package/dist/core/src/types/tsconfig.d.cts.map +0 -1
  91. package/dist/core/src/types/tsconfig.d.mts +0 -70
  92. package/dist/core/src/types/tsconfig.d.mts.map +0 -1
  93. package/dist/core/src/types/unplugin.d.cts +0 -24
  94. package/dist/core/src/types/unplugin.d.cts.map +0 -1
  95. package/dist/core/src/types/unplugin.d.mts +0 -25
  96. package/dist/core/src/types/unplugin.d.mts.map +0 -1
  97. package/dist/helpers/resolve-options.d.cts.map +0 -1
  98. package/dist/helpers/resolve-options.d.mts.map +0 -1
  99. package/dist/helpers/resolve-options.mjs.map +0 -1
  100. package/dist/plugin-rollup/src/helpers/resolve-options.cjs +0 -122
  101. package/dist/plugin-rollup/src/helpers/resolve-options.mjs +0 -116
  102. package/dist/plugin-rollup/src/helpers/resolve-options.mjs.map +0 -1
  103. package/dist/types/build.d.cts.map +0 -1
  104. package/dist/types/build.d.mts.map +0 -1
  105. package/dist/types/plugin.d.cts.map +0 -1
  106. package/dist/types/plugin.d.mts.map +0 -1
@@ -0,0 +1,173 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
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");
32
+ let defu = require("defu");
33
+ defu = __toESM(defu);
34
+ let esbuild = require("esbuild");
35
+
36
+ //#region src/helpers/resolve-options.ts
37
+ const DEFAULT_UNBUILD_CONFIG = {
38
+ dts: true,
39
+ clean: false,
40
+ includeSrc: false,
41
+ treeShaking: true,
42
+ splitting: true,
43
+ stub: false,
44
+ watchOptions: {},
45
+ outputPath: "dist",
46
+ generatePackageJson: true,
47
+ banner: " ",
48
+ rollup: {
49
+ dts: {},
50
+ emitCJS: true,
51
+ replace: {},
52
+ resolve: {},
53
+ json: {},
54
+ esbuild: { target: "es2020" },
55
+ commonjs: {},
56
+ alias: {}
57
+ }
58
+ };
59
+ const unbuildLoader = (context) => {
60
+ return async (input, { options }) => {
61
+ if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
62
+ const output = [];
63
+ let contents = await input.getContents();
64
+ if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
65
+ const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
66
+ output.push({
67
+ contents,
68
+ srcPath: input.srcPath,
69
+ path: input.path,
70
+ extension: extension$1,
71
+ declaration: true
72
+ });
73
+ }
74
+ let transformed = contents;
75
+ let result = await context.$$internal.callHook("transform", {
76
+ sequential: true,
77
+ order: "pre"
78
+ }, transformed, input.path);
79
+ if (result) transformed = result;
80
+ result = await context.$$internal.callHook("transform", {
81
+ sequential: true,
82
+ order: "normal"
83
+ }, (0, __powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
84
+ if (result) transformed = result;
85
+ result = await context.$$internal.callHook("transform", {
86
+ sequential: true,
87
+ order: "post"
88
+ }, (0, __powerlines_core_lib_utilities_source_file.getString)(transformed), input.path);
89
+ if (result) transformed = result;
90
+ if ([
91
+ ".ts",
92
+ ".mts",
93
+ ".cts"
94
+ ].includes(input.extension)) contents = await (0, esbuild.transform)((0, __powerlines_core_lib_utilities_source_file.getString)(transformed), {
95
+ ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
96
+ loader: "ts"
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), {
99
+ loader: input.extension === ".tsx" ? "tsx" : "jsx",
100
+ ...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
101
+ }).then((r) => r.code);
102
+ const isCjs = options.format === "cjs";
103
+ if (isCjs) contents = context.resolver.transform({
104
+ source: contents,
105
+ retainLines: false
106
+ }).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
107
+ let extension = isCjs ? ".js" : ".mjs";
108
+ if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
109
+ output.push({
110
+ contents,
111
+ path: input.path,
112
+ extension
113
+ });
114
+ return output;
115
+ };
116
+ };
117
+ /**
118
+ * Extracts the unbuild configuration from the context.
119
+ *
120
+ * @param context - The build context.
121
+ * @returns The resolved unbuild configuration.
122
+ */
123
+ function resolveOptions(context) {
124
+ return (0, defu.default)({ alias: context.alias }, context.config.unbuild ? context.config.unbuild : {}, {
125
+ projectName: context.config.name,
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"),
129
+ projectRoot: context.config.root,
130
+ outputPath: context.config.output.buildPath || "dist",
131
+ platform: context.config.platform,
132
+ external: context.builtins.reduce((ret, id) => {
133
+ if (!ret.includes(id)) ret.push(id);
134
+ return ret;
135
+ }, context.config.resolve.external ?? []),
136
+ loaders: [unbuildLoader(context)],
137
+ jiti: {
138
+ interopDefault: true,
139
+ fsCache: (0, __stryke_path_join_paths.joinPaths)(context.envPaths.cache, "jiti"),
140
+ moduleCache: true
141
+ },
142
+ rollup: (0, __powerlines_plugin_rollup_helpers_resolve_options.resolveOptions)(context),
143
+ debug: context.config.mode === "development",
144
+ minify: context.config.mode !== "development",
145
+ sourcemap: context.config.mode === "development"
146
+ }, DEFAULT_UNBUILD_CONFIG);
147
+ }
148
+
149
+ //#endregion
150
+ Object.defineProperty(exports, 'DEFAULT_UNBUILD_CONFIG', {
151
+ enumerable: true,
152
+ get: function () {
153
+ return DEFAULT_UNBUILD_CONFIG;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, '__toESM', {
157
+ enumerable: true,
158
+ get: function () {
159
+ return __toESM;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, 'resolveOptions', {
163
+ enumerable: true,
164
+ get: function () {
165
+ return resolveOptions;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, 'unbuildLoader', {
169
+ enumerable: true,
170
+ get: function () {
171
+ return unbuildLoader;
172
+ }
173
+ });
@@ -0,0 +1,123 @@
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
@@ -0,0 +1 @@
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 { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport { Context } from \"@powerlines/core/types\";\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":"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"}
@@ -0,0 +1,17 @@
1
+ import { Context } from "@powerlines/core/types";
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-DPRrB4Qj.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options-DPRrB4Qj.d.cts","names":[],"sources":["../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;AAvB9D;AAuBA;AA0HA;;;;iBAAgB,cAAA,UAAwB,UAAU"}
@@ -0,0 +1,17 @@
1
+ import { Context } from "@powerlines/core/types";
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-DRA_XDDs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options-DRA_XDDs.d.mts","names":[],"sources":["../src/helpers/resolve-options.ts"],"sourcesContent":[],"mappings":";;;;;cAkCa,wBAqBR,QAAQ;cAEA,yBAA0B,yBAAuB;AAvB9D;AAuBA;AA0HA;;;;iBAAgB,cAAA,UAAwB,UAAU"}
@@ -0,0 +1 @@
1
+ require('../build-MNonspIb.cjs');
@@ -1,8 +1,2 @@
1
- import { UnbuildOptions as UnbuildOptions$1 } from "@storm-software/unbuild/types";
2
-
3
- //#region src/types/build.d.ts
4
- type UnbuildOptions = Partial<Omit<UnbuildOptions$1, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">>;
5
- declare type __ΩUnbuildOptions = any[];
6
- //#endregion
7
- export { UnbuildOptions, __ΩUnbuildOptions };
8
- //# sourceMappingURL=build.d.cts.map
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-D-HKMVs4.cjs";
2
+ export { UnbuildOptions, __ΩUnbuildOptions };
@@ -1,8 +1,2 @@
1
- import { UnbuildOptions as UnbuildOptions$1 } from "@storm-software/unbuild/types";
2
-
3
- //#region src/types/build.d.ts
4
- type UnbuildOptions = Partial<Omit<UnbuildOptions$1, "tsconfig" | "tsconfigRaw" | "assets" | "outputPath" | "mode" | "format" | "platform" | "projectRoot" | "env" | "entry" | "entryPoints">>;
5
- declare type __ΩUnbuildOptions = any[];
6
- //#endregion
7
- export { UnbuildOptions, __ΩUnbuildOptions };
8
- //# sourceMappingURL=build.d.mts.map
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-BGmzCfG9.mjs";
2
+ export { UnbuildOptions, __ΩUnbuildOptions };
@@ -1 +1,3 @@
1
+ import "../build-CcJjLdFm.mjs";
2
+
1
3
  export { };
@@ -0,0 +1,3 @@
1
+ require('../build-MNonspIb.cjs');
2
+ require('../plugin-pBKbb5K9.cjs');
3
+ require('../types-o3zWarRp.cjs');
@@ -1,3 +1,4 @@
1
- import { UnbuildOptions, __ΩUnbuildOptions } from "./build.cjs";
2
- import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./plugin.cjs";
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-CXxxQ0lD.cjs";
3
+ import "../index-BR1oNnaF.cjs";
3
4
  export { UnbuildOptions, UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildOptions, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1,3 +1,4 @@
1
- import { UnbuildOptions, __ΩUnbuildOptions } from "./build.mjs";
2
- import { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig } from "./plugin.mjs";
1
+ import { n as __ΩUnbuildOptions, t as UnbuildOptions } from "../build-BGmzCfG9.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-Dt6qEKIr.mjs";
3
+ import "../index-DEHBdV_z.mjs";
3
4
  export { UnbuildOptions, UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildOptions, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1 +1,5 @@
1
+ import "../build-CcJjLdFm.mjs";
2
+ import "../plugin-jZ9N9Mz-.mjs";
3
+ import "../types-BtDR9wb1.mjs";
4
+
1
5
  export { };
@@ -0,0 +1 @@
1
+ require('../plugin-pBKbb5K9.cjs');
@@ -1,20 +1,3 @@
1
- import { PluginContext } from "../core/src/types/context.cjs";
2
- import { ResolvedConfig, UserConfig } from "../core/src/types/config.cjs";
3
- import { UnbuildOptions } from "./build.cjs";
4
-
5
- //#region src/types/plugin.d.ts
6
- type UnbuildPluginOptions = Partial<UnbuildOptions>;
7
- interface UnbuildPluginUserConfig extends UserConfig {
8
- unbuild?: UnbuildPluginOptions;
9
- }
10
- interface UnbuildPluginResolvedConfig extends ResolvedConfig {
11
- unbuild: UnbuildOptions;
12
- }
13
- type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
14
- declare type __ΩUnbuildPluginOptions = any[];
15
- declare type __ΩUnbuildPluginUserConfig = any[];
16
- declare type __ΩUnbuildPluginResolvedConfig = any[];
17
- declare type __ΩUnbuildPluginContext = any[];
18
- //#endregion
19
- export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
20
- //# sourceMappingURL=plugin.d.cts.map
1
+ import "../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-CXxxQ0lD.cjs";
3
+ export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1,21 +1,3 @@
1
- import { PluginContext } from "../core/src/types/context.mjs";
2
- import { ResolvedConfig, UserConfig } from "../core/src/types/config.mjs";
3
- import "../core/src/types/index.mjs";
4
- import { UnbuildOptions } from "./build.mjs";
5
-
6
- //#region src/types/plugin.d.ts
7
- type UnbuildPluginOptions = Partial<UnbuildOptions>;
8
- interface UnbuildPluginUserConfig extends UserConfig {
9
- unbuild?: UnbuildPluginOptions;
10
- }
11
- interface UnbuildPluginResolvedConfig extends ResolvedConfig {
12
- unbuild: UnbuildOptions;
13
- }
14
- type UnbuildPluginContext<TResolvedConfig extends UnbuildPluginResolvedConfig = UnbuildPluginResolvedConfig> = PluginContext<TResolvedConfig>;
15
- declare type __ΩUnbuildPluginOptions = any[];
16
- declare type __ΩUnbuildPluginUserConfig = any[];
17
- declare type __ΩUnbuildPluginResolvedConfig = any[];
18
- declare type __ΩUnbuildPluginContext = any[];
19
- //#endregion
20
- export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
21
- //# sourceMappingURL=plugin.d.mts.map
1
+ import "../build-BGmzCfG9.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-Dt6qEKIr.mjs";
3
+ export { UnbuildPluginContext, UnbuildPluginOptions, UnbuildPluginResolvedConfig, UnbuildPluginUserConfig, __ΩUnbuildPluginContext, __ΩUnbuildPluginOptions, __ΩUnbuildPluginResolvedConfig, __ΩUnbuildPluginUserConfig };
@@ -1 +1,3 @@
1
+ import "../plugin-jZ9N9Mz-.mjs";
2
+
1
3
  export { };
@@ -0,0 +1 @@
1
+ export { };
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-unbuild",
3
- "version": "0.5.307",
3
+ "version": "0.5.309",
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"],
@@ -69,8 +69,8 @@
69
69
  "typings": "dist/index.d.mts",
70
70
  "files": ["dist/**/*"],
71
71
  "dependencies": {
72
- "@powerlines/core": "^0.0.8",
73
- "@powerlines/plugin-rollup": "^0.7.307",
72
+ "@powerlines/core": "^0.0.10",
73
+ "@powerlines/plugin-rollup": "^0.7.309",
74
74
  "@stryke/path": "^0.26.6",
75
75
  "@stryke/type-checks": "^0.5.25",
76
76
  "defu": "^6.1.4",
@@ -84,5 +84,5 @@
84
84
  "peerDependencies": { "@storm-software/unbuild": ">=0.57.0" },
85
85
  "peerDependenciesMeta": { "@storm-software/unbuild": { "optional": false } },
86
86
  "publishConfig": { "access": "public" },
87
- "gitHead": "2c6fd0cd3aad8656cedb9912f2b5894730be7dd7"
87
+ "gitHead": "c5eba2320a22122bbefaca9aba105dd8a98f19b9"
88
88
  }
@@ -1,29 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
@@ -1,22 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- require("@stryke/fs/read-file");
3
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
5
- require("magic-string");
6
-
7
- //#region ../core/src/lib/utilities/source-file.ts
8
- /**
9
- * Get the string from the source.
10
- *
11
- * @param code - The source string or magic string.
12
- * @returns The source string.
13
- */
14
- function getString(code) {
15
- if (!code) return "";
16
- if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
17
- if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
18
- return code.toString();
19
- }
20
-
21
- //#endregion
22
- exports.getString = getString;
@@ -1,22 +0,0 @@
1
- import "@stryke/fs/read-file";
2
- import { isSetObject } from "@stryke/type-checks/is-set-object";
3
- import { isString } from "@stryke/type-checks/is-string";
4
- import "magic-string";
5
-
6
- //#region ../core/src/lib/utilities/source-file.ts
7
- /**
8
- * Get the string from the source.
9
- *
10
- * @param code - The source string or magic string.
11
- * @returns The source string.
12
- */
13
- function getString(code) {
14
- if (!code) return "";
15
- if (isString(code)) return code;
16
- if (isSetObject(code) && "code" in code) return code.code;
17
- return code.toString();
18
- }
19
-
20
- //#endregion
21
- export { getString };
22
- //# sourceMappingURL=source-file.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-file.mjs","names":[],"sources":["../../../../../../core/src/lib/utilities/source-file.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 { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,UACd,MACQ;AACR,KAAI,CAAC,KACH,QAAO;AAGT,KAAI,SAAS,KAAK,CAChB,QAAO;AAGT,KAAI,YAAY,KAAK,IAAI,UAAU,KACjC,QAAO,KAAK;AAGd,QAAO,KAAK,UAAU"}