@powerlines/plugin-tsup 0.12.241 → 0.12.242

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 (116) hide show
  1. package/dist/helpers/unplugin.cjs +3 -2
  2. package/dist/helpers/unplugin.mjs +2 -1
  3. package/dist/index.cjs +3 -3
  4. package/dist/index.d.cts +2 -3
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +3 -3
  7. package/dist/powerlines/package.cjs +11 -0
  8. package/dist/powerlines/package.mjs +5 -0
  9. package/dist/powerlines/schemas/fs.cjs +226 -0
  10. package/dist/powerlines/schemas/fs.mjs +224 -0
  11. package/dist/powerlines/src/api.cjs +568 -0
  12. package/dist/powerlines/src/api.mjs +566 -0
  13. package/dist/powerlines/src/internal/helpers/environment.cjs +50 -0
  14. package/dist/powerlines/src/internal/helpers/environment.mjs +47 -0
  15. package/dist/powerlines/src/internal/helpers/generate-types.cjs +78 -0
  16. package/dist/powerlines/src/internal/helpers/generate-types.mjs +76 -0
  17. package/dist/powerlines/src/internal/helpers/hooks.cjs +65 -0
  18. package/dist/powerlines/src/internal/helpers/hooks.d.cts +47 -0
  19. package/dist/powerlines/src/internal/helpers/hooks.d.mts +49 -0
  20. package/dist/powerlines/src/internal/helpers/hooks.mjs +63 -0
  21. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +24 -0
  22. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +23 -0
  23. package/dist/powerlines/src/internal/helpers/install.cjs +36 -0
  24. package/dist/powerlines/src/internal/helpers/install.mjs +35 -0
  25. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +97 -0
  26. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +93 -0
  27. package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
  28. package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
  29. package/dist/powerlines/src/lib/build/esbuild.cjs +28 -0
  30. package/dist/powerlines/src/lib/build/esbuild.mjs +26 -0
  31. package/dist/powerlines/src/lib/build/tsup.cjs +81 -0
  32. package/dist/powerlines/src/lib/build/tsup.mjs +78 -0
  33. package/dist/powerlines/src/lib/config-file.cjs +79 -0
  34. package/dist/powerlines/src/lib/config-file.mjs +76 -0
  35. package/dist/powerlines/src/lib/constants/environments.cjs +8 -0
  36. package/dist/powerlines/src/lib/constants/environments.mjs +6 -0
  37. package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
  38. package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
  39. package/dist/powerlines/src/lib/contexts/context.cjs +951 -0
  40. package/dist/powerlines/src/lib/contexts/context.mjs +949 -0
  41. package/dist/powerlines/src/lib/contexts/environment-context.cjs +195 -0
  42. package/dist/powerlines/src/lib/contexts/environment-context.mjs +194 -0
  43. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +78 -0
  44. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +77 -0
  45. package/dist/powerlines/src/lib/entry.cjs +86 -0
  46. package/dist/powerlines/src/lib/entry.mjs +83 -0
  47. package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
  48. package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
  49. package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
  50. package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
  51. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
  52. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
  53. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
  54. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
  55. package/dist/powerlines/src/lib/fs/vfs.cjs +912 -0
  56. package/dist/powerlines/src/lib/fs/vfs.mjs +910 -0
  57. package/dist/powerlines/src/lib/logger.cjs +58 -0
  58. package/dist/powerlines/src/lib/logger.mjs +55 -0
  59. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +103 -0
  60. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +101 -0
  61. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
  62. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
  63. package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
  64. package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
  65. package/dist/powerlines/src/lib/unplugin/helpers.cjs +29 -0
  66. package/dist/powerlines/src/lib/unplugin/helpers.mjs +27 -0
  67. package/dist/powerlines/src/lib/unplugin/index.cjs +4 -0
  68. package/dist/powerlines/src/lib/unplugin/index.mjs +6 -0
  69. package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +66 -0
  70. package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +65 -0
  71. package/dist/powerlines/src/lib/unplugin/plugin.cjs +71 -0
  72. package/dist/powerlines/src/lib/unplugin/plugin.mjs +70 -0
  73. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  74. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  75. package/dist/powerlines/src/lib/utilities/format.cjs +48 -0
  76. package/dist/powerlines/src/lib/utilities/format.mjs +46 -0
  77. package/dist/powerlines/src/lib/utilities/meta.cjs +44 -0
  78. package/dist/powerlines/src/lib/utilities/meta.mjs +40 -0
  79. package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
  80. package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -0
  81. package/dist/powerlines/src/plugin-utils/helpers.cjs +167 -0
  82. package/dist/powerlines/src/plugin-utils/helpers.mjs +156 -0
  83. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
  84. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
  85. package/dist/powerlines/src/types/api.d.cts +104 -0
  86. package/dist/powerlines/src/types/api.d.mts +104 -0
  87. package/dist/powerlines/src/types/babel.d.mts +2 -0
  88. package/dist/powerlines/src/types/build.cjs +23 -0
  89. package/dist/powerlines/src/types/build.d.cts +185 -0
  90. package/dist/powerlines/src/types/build.d.mts +185 -0
  91. package/dist/powerlines/src/types/build.mjs +21 -0
  92. package/dist/powerlines/src/types/commands.cjs +16 -0
  93. package/dist/powerlines/src/types/commands.d.cts +8 -0
  94. package/dist/powerlines/src/types/commands.d.mts +9 -0
  95. package/dist/powerlines/src/types/commands.mjs +15 -0
  96. package/dist/powerlines/src/types/config.d.cts +424 -0
  97. package/dist/powerlines/src/types/config.d.mts +424 -0
  98. package/dist/powerlines/src/types/context.d.cts +514 -0
  99. package/dist/powerlines/src/types/context.d.mts +514 -0
  100. package/dist/powerlines/src/types/fs.d.cts +486 -0
  101. package/dist/powerlines/src/types/fs.d.mts +486 -0
  102. package/dist/powerlines/src/types/hooks.d.cts +32 -0
  103. package/dist/powerlines/src/types/hooks.d.mts +32 -0
  104. package/dist/powerlines/src/types/plugin.cjs +33 -0
  105. package/dist/powerlines/src/types/plugin.d.cts +205 -0
  106. package/dist/powerlines/src/types/plugin.d.mts +205 -0
  107. package/dist/powerlines/src/types/plugin.mjs +32 -0
  108. package/dist/powerlines/src/types/resolved.d.cts +93 -0
  109. package/dist/powerlines/src/types/resolved.d.mts +93 -0
  110. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  111. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  112. package/dist/powerlines/src/types/unplugin.d.cts +22 -0
  113. package/dist/powerlines/src/types/unplugin.d.mts +23 -0
  114. package/dist/types/plugin.d.cts +4 -4
  115. package/dist/types/plugin.d.mts +4 -4
  116. package/package.json +4 -4
@@ -0,0 +1,93 @@
1
+ import { getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound } from "../../lib/typescript/tsconfig.mjs";
2
+ import { joinPaths } from "@stryke/path/join-paths";
3
+ import { isPackageExists } from "@stryke/fs/package-fns";
4
+ import chalk from "chalk";
5
+ import { findFileName, findFilePath, relativePath } from "@stryke/path/file-path-fns";
6
+ import { getObjectDiff } from "@donedeal0/superdiff";
7
+ import { readJsonFile } from "@stryke/fs/json";
8
+ import { StormJSON } from "@stryke/json/storm-json";
9
+ import { titleCase } from "@stryke/string-format/title-case";
10
+
11
+ //#region ../powerlines/src/internal/helpers/resolve-tsconfig.ts
12
+ function getTsconfigDtsPath(context) {
13
+ return joinPaths(relativePath(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
14
+ }
15
+ async function resolveTsconfigChanges(context) {
16
+ const tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
17
+ const tsconfigJson = await readJsonFile(getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig));
18
+ tsconfigJson.compilerOptions ??= {};
19
+ if (context.config.output.dts !== false) {
20
+ const dtsRelativePath = getTsconfigDtsPath(context);
21
+ if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [context.dtsPath, dtsRelativePath]))) {
22
+ tsconfigJson.include ??= [];
23
+ tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
24
+ }
25
+ }
26
+ if (!tsconfig.options.lib?.some((lib) => [
27
+ "lib.esnext.d.ts",
28
+ "lib.es2021.d.ts",
29
+ "lib.es2022.d.ts",
30
+ "lib.es2023.d.ts"
31
+ ].includes(lib.toLowerCase()))) {
32
+ tsconfigJson.compilerOptions.lib ??= [];
33
+ tsconfigJson.compilerOptions.lib.push("esnext");
34
+ }
35
+ if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
36
+ if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
37
+ if (context.config.build.platform === "node") {
38
+ if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
39
+ tsconfigJson.compilerOptions.types ??= [];
40
+ tsconfigJson.compilerOptions.types.push("node");
41
+ }
42
+ }
43
+ return tsconfigJson;
44
+ }
45
+ async function initializeTsconfig(context) {
46
+ context.debug("Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
47
+ if (!isPackageExists("typescript")) throw new Error("The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"");
48
+ const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
49
+ context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
50
+ context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
51
+ context.debug("Writing updated TypeScript configuration (tsconfig.json) file to disk.");
52
+ await context.fs.write(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
53
+ context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
54
+ }
55
+ async function resolveTsconfig(context) {
56
+ const updateTsconfigJson = await readJsonFile(context.tsconfig.tsconfigFilePath);
57
+ if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
58
+ const result = getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
59
+ ignoreArrayOrder: true,
60
+ showOnly: {
61
+ statuses: [
62
+ "added",
63
+ "deleted",
64
+ "updated"
65
+ ],
66
+ granularity: "deep"
67
+ }
68
+ });
69
+ const changes = [];
70
+ const getChanges = (difference, property) => {
71
+ if (difference.status === "added" || difference.status === "deleted" || difference.status === "updated") if (difference.diff) for (const diff of difference.diff) getChanges(diff, property ? `${property}.${difference.property}` : difference.property);
72
+ else changes.push({
73
+ field: property ? `${property}.${difference.property}` : difference.property,
74
+ status: difference.status,
75
+ previous: difference.status === "added" ? "---" : StormJSON.stringify(difference.previousValue),
76
+ current: difference.status === "deleted" ? "---" : StormJSON.stringify(difference.currentValue)
77
+ });
78
+ };
79
+ for (const diff of result.diff) getChanges(diff);
80
+ if (changes.length > 0) context.warn(`Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
81
+
82
+ ${changes.map((change, i) => `${chalk.bold.whiteBright(`${i + 1}. ${titleCase(change.status)} the ${change.field} field: `)}
83
+ ${chalk.red(` - Previous: ${change.previous} `)}
84
+ ${chalk.green(` - Updated: ${change.current} `)}
85
+ `).join("\n")}
86
+ `);
87
+ await context.fs.write(context.tsconfig.tsconfigFilePath, StormJSON.stringify(updateTsconfigJson));
88
+ context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
89
+ if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
90
+ }
91
+
92
+ //#endregion
93
+ export { getTsconfigDtsPath, initializeTsconfig, resolveTsconfig };
@@ -0,0 +1,43 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let defu = require("defu");
3
+ defu = require_rolldown_runtime.__toESM(defu);
4
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
5
+ let jiti = require("jiti");
6
+
7
+ //#region ../powerlines/src/internal/helpers/resolver.ts
8
+ /**
9
+ * Create a Jiti resolver for the given workspace and project root.
10
+ *
11
+ * @param options - The options for creating the resolver.
12
+ * @returns A Jiti instance configured for the specified workspace and project root.
13
+ */
14
+ function resolveOptions(options) {
15
+ return (0, defu.default)(options, {
16
+ interopDefault: true,
17
+ fsCache: options.mode !== "development" ? (0, __stryke_path_join_paths.joinPaths)(options.cacheDir, "jiti") : false,
18
+ moduleCache: options.mode !== "development"
19
+ });
20
+ }
21
+ /**
22
+ * Create a Jiti resolver for the given workspace and project root.
23
+ *
24
+ * @param options - The options for creating the resolver.
25
+ * @returns A Jiti instance configured for the specified workspace and project root.
26
+ */
27
+ function createPluginResolver(options) {
28
+ return (0, jiti.createJiti)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, options.projectRoot), resolveOptions({ ...options }));
29
+ }
30
+ /**
31
+ * Create a Jiti resolver for the given workspace and project root.
32
+ *
33
+ * @param options - The options for creating the resolver.
34
+ * @returns A Jiti instance configured for the specified workspace and project root.
35
+ */
36
+ function createResolver(options) {
37
+ const baseResolver = (0, jiti.createJiti)((0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, options.projectRoot), resolveOptions(options));
38
+ baseResolver.plugin = createPluginResolver(options);
39
+ return baseResolver;
40
+ }
41
+
42
+ //#endregion
43
+ exports.createResolver = createResolver;
@@ -0,0 +1,41 @@
1
+ import defu$1 from "defu";
2
+ import { joinPaths } from "@stryke/path/join-paths";
3
+ import { createJiti } from "jiti";
4
+
5
+ //#region ../powerlines/src/internal/helpers/resolver.ts
6
+ /**
7
+ * Create a Jiti resolver for the given workspace and project root.
8
+ *
9
+ * @param options - The options for creating the resolver.
10
+ * @returns A Jiti instance configured for the specified workspace and project root.
11
+ */
12
+ function resolveOptions(options) {
13
+ return defu$1(options, {
14
+ interopDefault: true,
15
+ fsCache: options.mode !== "development" ? joinPaths(options.cacheDir, "jiti") : false,
16
+ moduleCache: options.mode !== "development"
17
+ });
18
+ }
19
+ /**
20
+ * Create a Jiti resolver for the given workspace and project root.
21
+ *
22
+ * @param options - The options for creating the resolver.
23
+ * @returns A Jiti instance configured for the specified workspace and project root.
24
+ */
25
+ function createPluginResolver(options) {
26
+ return createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({ ...options }));
27
+ }
28
+ /**
29
+ * Create a Jiti resolver for the given workspace and project root.
30
+ *
31
+ * @param options - The options for creating the resolver.
32
+ * @returns A Jiti instance configured for the specified workspace and project root.
33
+ */
34
+ function createResolver(options) {
35
+ const baseResolver = createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
36
+ baseResolver.plugin = createPluginResolver(options);
37
+ return baseResolver;
38
+ }
39
+
40
+ //#endregion
41
+ export { createResolver };
@@ -0,0 +1,28 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_entry = require('../entry.cjs');
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
5
+ let __stryke_helpers_omit = require("@stryke/helpers/omit");
6
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
7
+ let __stryke_path_replace = require("@stryke/path/replace");
8
+ require("@stryke/string-format/camel-case");
9
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
+
11
+ //#region ../powerlines/src/lib/build/esbuild.ts
12
+ /**
13
+ * Resolves the entry options for esbuild.
14
+ *
15
+ * @param context - The build context.
16
+ * @param entryPoints - The entry points to resolve.
17
+ * @returns The resolved entry options.
18
+ */
19
+ function resolveESBuildEntry(context, entryPoints = []) {
20
+ return entryPoints.reduce((ret, entry) => {
21
+ if ((0, __stryke_type_checks_is_string.isString)(entry)) ret[(0, __stryke_path_replace.replaceExtension)((0, __stryke_path_replace.replacePath)(entry, context.config.sourceRoot || context.config.projectRoot))] = (0, __stryke_path_replace.replacePath)(entry, context.config.sourceRoot || context.config.projectRoot);
22
+ else ret[entry.output || require_entry.resolveEntryOutput(context, entry)] = entry.file;
23
+ return ret;
24
+ }, {});
25
+ }
26
+
27
+ //#endregion
28
+ exports.resolveESBuildEntry = resolveESBuildEntry;
@@ -0,0 +1,26 @@
1
+ import { resolveEntryOutput } from "../entry.mjs";
2
+ import defu$1 from "defu";
3
+ import { omit } from "@stryke/helpers/omit";
4
+ import { joinPaths } from "@stryke/path/join-paths";
5
+ import { replaceExtension, replacePath } from "@stryke/path/replace";
6
+ import "@stryke/string-format/camel-case";
7
+ import { isString } from "@stryke/type-checks/is-string";
8
+
9
+ //#region ../powerlines/src/lib/build/esbuild.ts
10
+ /**
11
+ * Resolves the entry options for esbuild.
12
+ *
13
+ * @param context - The build context.
14
+ * @param entryPoints - The entry points to resolve.
15
+ * @returns The resolved entry options.
16
+ */
17
+ function resolveESBuildEntry(context, entryPoints = []) {
18
+ return entryPoints.reduce((ret, entry) => {
19
+ if (isString(entry)) ret[replaceExtension(replacePath(entry, context.config.sourceRoot || context.config.projectRoot))] = replacePath(entry, context.config.sourceRoot || context.config.projectRoot);
20
+ else ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;
21
+ return ret;
22
+ }, {});
23
+ }
24
+
25
+ //#endregion
26
+ export { resolveESBuildEntry };
@@ -0,0 +1,81 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_esbuild = require('./esbuild.cjs');
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
5
+ let __storm_software_tsup_constants = require("@storm-software/tsup/constants");
6
+ let __stryke_convert_to_array = require("@stryke/convert/to-array");
7
+ let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
8
+ let __stryke_helpers_omit = require("@stryke/helpers/omit");
9
+
10
+ //#region ../powerlines/src/lib/build/tsup.ts
11
+ const DEFAULT_TSUP_CONFIG = {
12
+ ...__storm_software_tsup_constants.DEFAULT_BUILD_OPTIONS,
13
+ platform: "neutral",
14
+ target: "esnext",
15
+ config: false,
16
+ minify: true,
17
+ sourcemap: false,
18
+ cjsInterop: true,
19
+ bundle: true,
20
+ dts: true,
21
+ shims: true,
22
+ silent: true,
23
+ treeshake: true,
24
+ keepNames: true,
25
+ splitting: true,
26
+ banner: {}
27
+ };
28
+ /**
29
+ * Resolves the entry options for [tsup](https://github.com/egoist/tsup).
30
+ *
31
+ * @param context - The build context.
32
+ * @param entryPoints - The entry points to resolve.
33
+ * @returns The resolved entry options.
34
+ */
35
+ function resolveTsupEntry(context, entryPoints) {
36
+ return require_esbuild.resolveESBuildEntry(context, entryPoints);
37
+ }
38
+ /**
39
+ * Resolves the options for [tsup](https://github.com/egoist/tsup).
40
+ *
41
+ * @param context - The build context.
42
+ * @returns The resolved options.
43
+ */
44
+ function extractTsupConfig(context) {
45
+ const result = (0, defu.default)({
46
+ esbuildOptions: ((options, ctx) => {
47
+ if (context.config.build.variant === "tsup") {
48
+ if (context.config.build.esbuildOptions) context.config.build.esbuildOptions?.(options, ctx);
49
+ else if (context.config.build.override.esbuildOptions) context.config.build.override.esbuildOptions?.(options, ctx);
50
+ }
51
+ options.alias = {
52
+ ...context.alias,
53
+ ...options.alias
54
+ };
55
+ }),
56
+ noExternal: context.builtins
57
+ }, context.config.build.variant === "tsup" ? context.config.build.override : {}, context.config.build.variant === "tsup" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, {
58
+ name: context.config.name,
59
+ assets: context.config.output.assets,
60
+ resolveExtensions: context.config.build.extensions,
61
+ outputPath: context.config.output.buildPath,
62
+ projectRoot: context.config.projectRoot,
63
+ tsconfig: context.tsconfig.tsconfigFilePath,
64
+ dts: context.config.build.variant !== "tsup" || !context.config.build?.experimentalDts && !context.config.build.override?.experimentalDts ? { compilerOptions: context.tsconfig.tsconfigJson.compilerOptions } : void 0,
65
+ format: context.config.output.format,
66
+ mode: context.config.mode,
67
+ treeshake: context.config.build.variant === "tsup" ? context.config.build?.treeshake : context.config.build.variant === "tsup" ? context.config.build?.treeShaking : void 0,
68
+ minify: context.config.mode !== "development",
69
+ metafile: context.config.mode === "development",
70
+ sourcemap: context.config.mode === "development",
71
+ silent: context.config.logLevel === null || context.config.mode === "production",
72
+ verbose: context.config.logLevel === null || context.config.logLevel === "trace" || context.config.mode === "development",
73
+ workspaceConfig: { workspaceRoot: context.workspaceConfig.workspaceRoot }
74
+ }, DEFAULT_TSUP_CONFIG);
75
+ result.format = (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(result.format));
76
+ return result;
77
+ }
78
+
79
+ //#endregion
80
+ exports.extractTsupConfig = extractTsupConfig;
81
+ exports.resolveTsupEntry = resolveTsupEntry;
@@ -0,0 +1,78 @@
1
+ import { resolveESBuildEntry } from "./esbuild.mjs";
2
+ import defu$1 from "defu";
3
+ import { DEFAULT_BUILD_OPTIONS } from "@storm-software/tsup/constants";
4
+ import { toArray } from "@stryke/convert/to-array";
5
+ import { getUnique } from "@stryke/helpers/get-unique";
6
+ import { omit } from "@stryke/helpers/omit";
7
+
8
+ //#region ../powerlines/src/lib/build/tsup.ts
9
+ const DEFAULT_TSUP_CONFIG = {
10
+ ...DEFAULT_BUILD_OPTIONS,
11
+ platform: "neutral",
12
+ target: "esnext",
13
+ config: false,
14
+ minify: true,
15
+ sourcemap: false,
16
+ cjsInterop: true,
17
+ bundle: true,
18
+ dts: true,
19
+ shims: true,
20
+ silent: true,
21
+ treeshake: true,
22
+ keepNames: true,
23
+ splitting: true,
24
+ banner: {}
25
+ };
26
+ /**
27
+ * Resolves the entry options for [tsup](https://github.com/egoist/tsup).
28
+ *
29
+ * @param context - The build context.
30
+ * @param entryPoints - The entry points to resolve.
31
+ * @returns The resolved entry options.
32
+ */
33
+ function resolveTsupEntry(context, entryPoints) {
34
+ return resolveESBuildEntry(context, entryPoints);
35
+ }
36
+ /**
37
+ * Resolves the options for [tsup](https://github.com/egoist/tsup).
38
+ *
39
+ * @param context - The build context.
40
+ * @returns The resolved options.
41
+ */
42
+ function extractTsupConfig(context) {
43
+ const result = defu$1({
44
+ esbuildOptions: ((options, ctx) => {
45
+ if (context.config.build.variant === "tsup") {
46
+ if (context.config.build.esbuildOptions) context.config.build.esbuildOptions?.(options, ctx);
47
+ else if (context.config.build.override.esbuildOptions) context.config.build.override.esbuildOptions?.(options, ctx);
48
+ }
49
+ options.alias = {
50
+ ...context.alias,
51
+ ...options.alias
52
+ };
53
+ }),
54
+ noExternal: context.builtins
55
+ }, context.config.build.variant === "tsup" ? context.config.build.override : {}, context.config.build.variant === "tsup" ? omit(context.config.build, ["override", "variant"]) : {}, {
56
+ name: context.config.name,
57
+ assets: context.config.output.assets,
58
+ resolveExtensions: context.config.build.extensions,
59
+ outputPath: context.config.output.buildPath,
60
+ projectRoot: context.config.projectRoot,
61
+ tsconfig: context.tsconfig.tsconfigFilePath,
62
+ dts: context.config.build.variant !== "tsup" || !context.config.build?.experimentalDts && !context.config.build.override?.experimentalDts ? { compilerOptions: context.tsconfig.tsconfigJson.compilerOptions } : void 0,
63
+ format: context.config.output.format,
64
+ mode: context.config.mode,
65
+ treeshake: context.config.build.variant === "tsup" ? context.config.build?.treeshake : context.config.build.variant === "tsup" ? context.config.build?.treeShaking : void 0,
66
+ minify: context.config.mode !== "development",
67
+ metafile: context.config.mode === "development",
68
+ sourcemap: context.config.mode === "development",
69
+ silent: context.config.logLevel === null || context.config.mode === "production",
70
+ verbose: context.config.logLevel === null || context.config.logLevel === "trace" || context.config.mode === "development",
71
+ workspaceConfig: { workspaceRoot: context.workspaceConfig.workspaceRoot }
72
+ }, DEFAULT_TSUP_CONFIG);
73
+ result.format = getUnique(toArray(result.format));
74
+ return result;
75
+ }
76
+
77
+ //#endregion
78
+ export { extractTsupConfig, resolveTsupEntry };
@@ -0,0 +1,79 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_append = require("@stryke/path/append");
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
5
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
6
+ let __stryke_path_replace = require("@stryke/path/replace");
7
+ let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
8
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
9
+ let __stryke_fs_exists = require("@stryke/fs/exists");
10
+ let __storm_software_config_tools_get_config = require("@storm-software/config-tools/get-config");
11
+ let c12 = require("c12");
12
+
13
+ //#region ../powerlines/src/lib/config-file.ts
14
+ /**
15
+ * Loads the workspace configuration.
16
+ *
17
+ * @param workspaceRoot - The root directory of the workspace.
18
+ * @param cwd - The current working directory to start searching from.
19
+ * @returns A promise that resolves to the loaded workspace configuration.
20
+ */
21
+ async function loadWorkspaceConfig(workspaceRoot, cwd) {
22
+ return (0, defu.default)({ workspaceRoot }, await (0, __storm_software_config_tools_get_config.getWorkspaceConfig)(true, {
23
+ cwd,
24
+ workspaceRoot,
25
+ useDefault: true
26
+ }));
27
+ }
28
+ /**
29
+ * Loads the user configuration file for the project.
30
+ *
31
+ * @param projectRoot - The root directory of the project.
32
+ * @param workspaceRoot - The root directory of the workspace.
33
+ * @param jiti - An instance of Jiti to resolve modules from
34
+ * @param command - The {@link PowerlinesCommand} string associated with the current running process
35
+ * @param mode - The mode in which the project is running (default is "production").
36
+ * @param configFile - An optional path to a specific configuration file.
37
+ * @param framework - The framework name to use for default configuration file names.
38
+ * @returns A promise that resolves to the resolved user configuration.
39
+ */
40
+ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mode = "production", configFile, framework = "powerlines") {
41
+ let resolvedUserConfig = {};
42
+ let resolvedUserConfigFile;
43
+ if (configFile) resolvedUserConfigFile = (0, __stryke_fs_exists.existsSync)((0, __stryke_path_replace.replacePath)(configFile, projectRoot)) ? (0, __stryke_path_replace.replacePath)(configFile, projectRoot) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), (0, __stryke_path_replace.replacePath)(configFile, projectRoot))) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), (0, __stryke_path_replace.replacePath)(configFile, projectRoot)) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), configFile)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), configFile) : void 0;
44
+ if (!resolvedUserConfigFile) resolvedUserConfigFile = (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.ts`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.ts`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.js`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.js`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.mts`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.mts`) : (0, __stryke_fs_exists.existsSync)((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.mjs`)) ? (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot), `${framework}.config.mjs`) : void 0;
45
+ if (resolvedUserConfigFile) {
46
+ const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
47
+ if (resolved) {
48
+ let config = {};
49
+ if ((0, __stryke_type_checks_is_function.isFunction)(resolved)) config = await Promise.resolve(resolved({
50
+ command,
51
+ mode,
52
+ isSsrBuild: false,
53
+ isPreview: false
54
+ }));
55
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(config)) resolvedUserConfig = {
56
+ ...config,
57
+ config,
58
+ configFile: resolvedUserConfigFile
59
+ };
60
+ }
61
+ }
62
+ const result = await (0, c12.loadConfig)({
63
+ cwd: projectRoot,
64
+ name: framework,
65
+ envName: mode,
66
+ globalRc: true,
67
+ packageJson: true,
68
+ dotenv: true,
69
+ jiti
70
+ });
71
+ return (0, defu.default)(resolvedUserConfig, (0, __stryke_type_checks_is_set_object.isSetObject)(result?.config) ? {
72
+ ...result.config,
73
+ ...result
74
+ } : {});
75
+ }
76
+
77
+ //#endregion
78
+ exports.loadUserConfigFile = loadUserConfigFile;
79
+ exports.loadWorkspaceConfig = loadWorkspaceConfig;
@@ -0,0 +1,76 @@
1
+ import { appendPath } from "@stryke/path/append";
2
+ import defu$1 from "defu";
3
+ import { joinPaths } from "@stryke/path/join-paths";
4
+ import { replacePath } from "@stryke/path/replace";
5
+ import { isFunction } from "@stryke/type-checks/is-function";
6
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
7
+ import { existsSync } from "@stryke/fs/exists";
8
+ import { getWorkspaceConfig } from "@storm-software/config-tools/get-config";
9
+ import { loadConfig } from "c12";
10
+
11
+ //#region ../powerlines/src/lib/config-file.ts
12
+ /**
13
+ * Loads the workspace configuration.
14
+ *
15
+ * @param workspaceRoot - The root directory of the workspace.
16
+ * @param cwd - The current working directory to start searching from.
17
+ * @returns A promise that resolves to the loaded workspace configuration.
18
+ */
19
+ async function loadWorkspaceConfig(workspaceRoot, cwd) {
20
+ return defu$1({ workspaceRoot }, await getWorkspaceConfig(true, {
21
+ cwd,
22
+ workspaceRoot,
23
+ useDefault: true
24
+ }));
25
+ }
26
+ /**
27
+ * Loads the user configuration file for the project.
28
+ *
29
+ * @param projectRoot - The root directory of the project.
30
+ * @param workspaceRoot - The root directory of the workspace.
31
+ * @param jiti - An instance of Jiti to resolve modules from
32
+ * @param command - The {@link PowerlinesCommand} string associated with the current running process
33
+ * @param mode - The mode in which the project is running (default is "production").
34
+ * @param configFile - An optional path to a specific configuration file.
35
+ * @param framework - The framework name to use for default configuration file names.
36
+ * @returns A promise that resolves to the resolved user configuration.
37
+ */
38
+ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mode = "production", configFile, framework = "powerlines") {
39
+ let resolvedUserConfig = {};
40
+ let resolvedUserConfigFile;
41
+ if (configFile) resolvedUserConfigFile = existsSync(replacePath(configFile, projectRoot)) ? replacePath(configFile, projectRoot) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), replacePath(configFile, projectRoot))) ? joinPaths(appendPath(projectRoot, workspaceRoot), replacePath(configFile, projectRoot)) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), configFile)) ? joinPaths(appendPath(projectRoot, workspaceRoot), configFile) : void 0;
42
+ if (!resolvedUserConfigFile) resolvedUserConfigFile = existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.ts`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.ts`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.js`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.js`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.mts`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.mts`) : existsSync(joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.mjs`)) ? joinPaths(appendPath(projectRoot, workspaceRoot), `${framework}.config.mjs`) : void 0;
43
+ if (resolvedUserConfigFile) {
44
+ const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
45
+ if (resolved) {
46
+ let config = {};
47
+ if (isFunction(resolved)) config = await Promise.resolve(resolved({
48
+ command,
49
+ mode,
50
+ isSsrBuild: false,
51
+ isPreview: false
52
+ }));
53
+ if (isSetObject(config)) resolvedUserConfig = {
54
+ ...config,
55
+ config,
56
+ configFile: resolvedUserConfigFile
57
+ };
58
+ }
59
+ }
60
+ const result = await loadConfig({
61
+ cwd: projectRoot,
62
+ name: framework,
63
+ envName: mode,
64
+ globalRc: true,
65
+ packageJson: true,
66
+ dotenv: true,
67
+ jiti
68
+ });
69
+ return defu$1(resolvedUserConfig, isSetObject(result?.config) ? {
70
+ ...result.config,
71
+ ...result
72
+ } : {});
73
+ }
74
+
75
+ //#endregion
76
+ export { loadUserConfigFile, loadWorkspaceConfig };
@@ -0,0 +1,8 @@
1
+
2
+ //#region ../powerlines/src/lib/constants/environments.ts
3
+ const DEFAULT_ENVIRONMENT = "default";
4
+ const GLOBAL_ENVIRONMENT = "__global__";
5
+
6
+ //#endregion
7
+ exports.DEFAULT_ENVIRONMENT = DEFAULT_ENVIRONMENT;
8
+ exports.GLOBAL_ENVIRONMENT = GLOBAL_ENVIRONMENT;
@@ -0,0 +1,6 @@
1
+ //#region ../powerlines/src/lib/constants/environments.ts
2
+ const DEFAULT_ENVIRONMENT = "default";
3
+ const GLOBAL_ENVIRONMENT = "__global__";
4
+
5
+ //#endregion
6
+ export { DEFAULT_ENVIRONMENT, GLOBAL_ENVIRONMENT };