@powerlines/plugin-rollup 0.7.233 → 0.7.235

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 (114) hide show
  1. package/dist/helpers/unplugin.cjs +2 -3
  2. package/dist/helpers/unplugin.mjs +1 -2
  3. package/dist/index.cjs +2 -2
  4. package/dist/index.d.cts +3 -2
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +3 -3
  7. package/dist/types/plugin.d.cts +3 -3
  8. package/dist/types/plugin.d.mts +3 -3
  9. package/package.json +4 -4
  10. package/dist/powerlines/package.cjs +0 -11
  11. package/dist/powerlines/package.mjs +0 -5
  12. package/dist/powerlines/schemas/fs.cjs +0 -226
  13. package/dist/powerlines/schemas/fs.mjs +0 -224
  14. package/dist/powerlines/src/api.cjs +0 -568
  15. package/dist/powerlines/src/api.mjs +0 -566
  16. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -50
  17. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -47
  18. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -78
  19. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -76
  20. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -65
  21. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  22. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  23. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -63
  24. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -24
  25. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -23
  26. package/dist/powerlines/src/internal/helpers/install.cjs +0 -36
  27. package/dist/powerlines/src/internal/helpers/install.mjs +0 -35
  28. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -97
  29. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -93
  30. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  31. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  32. package/dist/powerlines/src/lib/build/rollup.cjs +0 -126
  33. package/dist/powerlines/src/lib/build/rollup.mjs +0 -119
  34. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  35. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  36. package/dist/powerlines/src/lib/constants/environments.cjs +0 -8
  37. package/dist/powerlines/src/lib/constants/environments.mjs +0 -6
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  40. package/dist/powerlines/src/lib/contexts/context.cjs +0 -951
  41. package/dist/powerlines/src/lib/contexts/context.mjs +0 -949
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -78
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -77
  46. package/dist/powerlines/src/lib/entry.cjs +0 -85
  47. package/dist/powerlines/src/lib/entry.mjs +0 -83
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -912
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -910
  58. package/dist/powerlines/src/lib/logger.cjs +0 -58
  59. package/dist/powerlines/src/lib/logger.mjs +0 -55
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -103
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -101
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -4
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -6
  70. package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +0 -66
  71. package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +0 -65
  72. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -71
  73. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -70
  74. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  75. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  76. package/dist/powerlines/src/lib/utilities/format.cjs +0 -48
  77. package/dist/powerlines/src/lib/utilities/format.mjs +0 -46
  78. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -44
  79. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -40
  80. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  81. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  82. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
  83. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
  84. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  85. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  86. package/dist/powerlines/src/types/api.d.cts +0 -104
  87. package/dist/powerlines/src/types/api.d.mts +0 -104
  88. package/dist/powerlines/src/types/babel.d.mts +0 -2
  89. package/dist/powerlines/src/types/build.cjs +0 -23
  90. package/dist/powerlines/src/types/build.d.cts +0 -185
  91. package/dist/powerlines/src/types/build.d.mts +0 -185
  92. package/dist/powerlines/src/types/build.mjs +0 -21
  93. package/dist/powerlines/src/types/commands.cjs +0 -16
  94. package/dist/powerlines/src/types/commands.d.cts +0 -8
  95. package/dist/powerlines/src/types/commands.d.mts +0 -9
  96. package/dist/powerlines/src/types/commands.mjs +0 -15
  97. package/dist/powerlines/src/types/config.d.cts +0 -424
  98. package/dist/powerlines/src/types/config.d.mts +0 -425
  99. package/dist/powerlines/src/types/context.d.cts +0 -514
  100. package/dist/powerlines/src/types/context.d.mts +0 -514
  101. package/dist/powerlines/src/types/fs.d.cts +0 -486
  102. package/dist/powerlines/src/types/fs.d.mts +0 -486
  103. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  104. package/dist/powerlines/src/types/hooks.d.mts +0 -32
  105. package/dist/powerlines/src/types/plugin.cjs +0 -33
  106. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  107. package/dist/powerlines/src/types/plugin.d.mts +0 -205
  108. package/dist/powerlines/src/types/plugin.mjs +0 -32
  109. package/dist/powerlines/src/types/resolved.d.cts +0 -93
  110. package/dist/powerlines/src/types/resolved.d.mts +0 -93
  111. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  112. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
  113. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
  114. package/dist/powerlines/src/types/unplugin.d.mts +0 -23
@@ -1,93 +0,0 @@
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 };
@@ -1,43 +0,0 @@
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;
@@ -1,41 +0,0 @@
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 };
@@ -1,126 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_convert_to_array = require("@stryke/convert/to-array");
3
- let defu = require("defu");
4
- defu = require_rolldown_runtime.__toESM(defu);
5
- let __rollup_plugin_alias = require("@rollup/plugin-alias");
6
- __rollup_plugin_alias = require_rolldown_runtime.__toESM(__rollup_plugin_alias);
7
- let __rollup_plugin_babel = require("@rollup/plugin-babel");
8
- let __rollup_plugin_inject = require("@rollup/plugin-inject");
9
- __rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
10
- let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
11
- __rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
12
- let __rollup_plugin_replace = require("@rollup/plugin-replace");
13
- __rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
14
- let __stryke_helpers_omit = require("@stryke/helpers/omit");
15
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
16
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
17
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
18
- let node_fs = require("node:fs");
19
- let rollup_plugin_typescript2 = require("rollup-plugin-typescript2");
20
- rollup_plugin_typescript2 = require_rolldown_runtime.__toESM(rollup_plugin_typescript2);
21
-
22
- //#region ../powerlines/src/lib/build/rollup.ts
23
- /**
24
- * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
25
- *
26
- * @remarks
27
- * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
28
- */
29
- const dtsBundlePlugin = {
30
- name: "powerlines:dts-bundle",
31
- async generateBundle(_opts, bundle) {
32
- for (const [, file] of Object.entries(bundle)) {
33
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
34
- const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
35
- const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
36
- this.emitFile({
37
- type: "asset",
38
- fileName: dtsFileName,
39
- source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
40
- });
41
- }
42
- }
43
- };
44
- /**
45
- * Resolves the options for [rollup](https://rollupjs.org).
46
- *
47
- * @param context - The build context.
48
- * @returns The resolved options.
49
- */
50
- function extractRollupConfig(context) {
51
- return (0, defu.default)({
52
- input: (0, node_fs.globSync)((0, __stryke_convert_to_array.toArray)(context.entry).map((entry) => (0, __stryke_type_checks_is_string.isString)(entry) ? entry : entry.file)).flat(),
53
- external: (source, importer, isResolved) => {
54
- const externalFn = context.config.build.variant === "rollup" && context.config.build.override.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.override.external) ? context.config.build.override.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build.override.external).includes(id) : context.config.build.variant === "vite" && context.config.build.override.build?.rollupOptions?.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.override.build?.rollupOptions?.external) ? context.config.build.override.build?.rollupOptions?.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build?.build?.rollupOptions?.external).includes(id) : context.config.build.variant === "rollup" && context.config.build.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.external) ? context.config.build.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build.external).includes(id) : context.config.build.variant === "vite" && context.config.build.build?.rollupOptions?.external ? (0, __stryke_type_checks_is_function.isFunction)(context.config.build.build?.rollupOptions?.external) ? context.config.build.build?.rollupOptions?.external : (id) => (0, __stryke_convert_to_array.toArray)(context.config.build?.build?.rollupOptions?.external).includes(id) : void 0;
55
- if ((0, __stryke_type_checks_is_function.isFunction)(externalFn) && externalFn(source, importer, isResolved)) return true;
56
- if (context.config.build.external && (0, __stryke_convert_to_array.toArray)(context.config.build.external).includes(source)) return true;
57
- if (context.config.build.noExternal && (0, __stryke_convert_to_array.toArray)(context.config.build.noExternal).includes(source)) return false;
58
- if (context.builtins.includes(source)) return context.config.projectType !== "application";
59
- return !context.config.build.skipNodeModulesBundle;
60
- },
61
- plugins: [
62
- (0, rollup_plugin_typescript2.default)({
63
- check: false,
64
- tsconfig: context.tsconfig.tsconfigFilePath
65
- }),
66
- context.config.build.define && Object.keys(context.config.build.define).length > 0 && (0, __rollup_plugin_replace.default)({
67
- sourceMap: context.config.mode === "development",
68
- preventAssignment: true,
69
- ...context.config.build.define ?? {}
70
- }),
71
- context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && (0, __rollup_plugin_inject.default)({
72
- sourceMap: context.config.mode === "development",
73
- ...context.config.build.inject
74
- }),
75
- (0, __rollup_plugin_alias.default)({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
76
- if (!ret.find((e) => e.find === id)) ret.push({
77
- find: id,
78
- replacement: path
79
- });
80
- else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
81
- return ret;
82
- }, []) }),
83
- (0, __rollup_plugin_babel.getBabelInputPlugin)((0, defu.default)(context.config.transform.babel, {
84
- caller: {
85
- name: "powerlines",
86
- supportsStaticESM: true
87
- },
88
- cwd: context.config.projectRoot,
89
- babelrc: false,
90
- extensions: [
91
- ".js",
92
- ".jsx",
93
- ".ts",
94
- ".tsx"
95
- ],
96
- babelHelpers: "bundled",
97
- skipPreflightCheck: true,
98
- exclude: /node_modules/
99
- })),
100
- (0, __rollup_plugin_node_resolve.default)({
101
- moduleDirectories: ["node_modules"],
102
- preferBuiltins: true
103
- }),
104
- dtsBundlePlugin
105
- ].filter(Boolean)
106
- }, context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rollup" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build?.rollupOptions : {}, {
107
- cache: !context.config.skipCache ? (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "rollup") : false,
108
- logLevel: context.config.logLevel,
109
- output: [{
110
- dir: context.config.output.buildPath,
111
- format: "es",
112
- entryFileNames: "[name].js",
113
- preserveModules: true,
114
- sourcemap: context.config.mode === "development"
115
- }, {
116
- dir: context.config.output.buildPath,
117
- format: "cjs",
118
- entryFileNames: "[name].cjs",
119
- preserveModules: true,
120
- sourcemap: context.config.mode === "development"
121
- }]
122
- });
123
- }
124
-
125
- //#endregion
126
- exports.extractRollupConfig = extractRollupConfig;
@@ -1,119 +0,0 @@
1
- import { toArray } from "@stryke/convert/to-array";
2
- import defu$1 from "defu";
3
- import alias from "@rollup/plugin-alias";
4
- import { getBabelInputPlugin } from "@rollup/plugin-babel";
5
- import inject from "@rollup/plugin-inject";
6
- import resolve from "@rollup/plugin-node-resolve";
7
- import replace from "@rollup/plugin-replace";
8
- import { omit } from "@stryke/helpers/omit";
9
- import { joinPaths } from "@stryke/path/join-paths";
10
- import { isFunction } from "@stryke/type-checks/is-function";
11
- import { isString } from "@stryke/type-checks/is-string";
12
- import { globSync } from "node:fs";
13
- import typescriptPlugin from "rollup-plugin-typescript2";
14
-
15
- //#region ../powerlines/src/lib/build/rollup.ts
16
- /**
17
- * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
18
- *
19
- * @remarks
20
- * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
21
- */
22
- const dtsBundlePlugin = {
23
- name: "powerlines:dts-bundle",
24
- async generateBundle(_opts, bundle) {
25
- for (const [, file] of Object.entries(bundle)) {
26
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
27
- const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
28
- const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
29
- this.emitFile({
30
- type: "asset",
31
- fileName: dtsFileName,
32
- source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
33
- });
34
- }
35
- }
36
- };
37
- /**
38
- * Resolves the options for [rollup](https://rollupjs.org).
39
- *
40
- * @param context - The build context.
41
- * @returns The resolved options.
42
- */
43
- function extractRollupConfig(context) {
44
- return defu$1({
45
- input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
46
- external: (source, importer, isResolved) => {
47
- const externalFn = context.config.build.variant === "rollup" && context.config.build.override.external ? isFunction(context.config.build.override.external) ? context.config.build.override.external : (id) => toArray(context.config.build.override.external).includes(id) : context.config.build.variant === "vite" && context.config.build.override.build?.rollupOptions?.external ? isFunction(context.config.build.override.build?.rollupOptions?.external) ? context.config.build.override.build?.rollupOptions?.external : (id) => toArray(context.config.build?.build?.rollupOptions?.external).includes(id) : context.config.build.variant === "rollup" && context.config.build.external ? isFunction(context.config.build.external) ? context.config.build.external : (id) => toArray(context.config.build.external).includes(id) : context.config.build.variant === "vite" && context.config.build.build?.rollupOptions?.external ? isFunction(context.config.build.build?.rollupOptions?.external) ? context.config.build.build?.rollupOptions?.external : (id) => toArray(context.config.build?.build?.rollupOptions?.external).includes(id) : void 0;
48
- if (isFunction(externalFn) && externalFn(source, importer, isResolved)) return true;
49
- if (context.config.build.external && toArray(context.config.build.external).includes(source)) return true;
50
- if (context.config.build.noExternal && toArray(context.config.build.noExternal).includes(source)) return false;
51
- if (context.builtins.includes(source)) return context.config.projectType !== "application";
52
- return !context.config.build.skipNodeModulesBundle;
53
- },
54
- plugins: [
55
- typescriptPlugin({
56
- check: false,
57
- tsconfig: context.tsconfig.tsconfigFilePath
58
- }),
59
- context.config.build.define && Object.keys(context.config.build.define).length > 0 && replace({
60
- sourceMap: context.config.mode === "development",
61
- preventAssignment: true,
62
- ...context.config.build.define ?? {}
63
- }),
64
- context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && inject({
65
- sourceMap: context.config.mode === "development",
66
- ...context.config.build.inject
67
- }),
68
- alias({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
69
- if (!ret.find((e) => e.find === id)) ret.push({
70
- find: id,
71
- replacement: path
72
- });
73
- else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
74
- return ret;
75
- }, []) }),
76
- getBabelInputPlugin(defu$1(context.config.transform.babel, {
77
- caller: {
78
- name: "powerlines",
79
- supportsStaticESM: true
80
- },
81
- cwd: context.config.projectRoot,
82
- babelrc: false,
83
- extensions: [
84
- ".js",
85
- ".jsx",
86
- ".ts",
87
- ".tsx"
88
- ],
89
- babelHelpers: "bundled",
90
- skipPreflightCheck: true,
91
- exclude: /node_modules/
92
- })),
93
- resolve({
94
- moduleDirectories: ["node_modules"],
95
- preferBuiltins: true
96
- }),
97
- dtsBundlePlugin
98
- ].filter(Boolean)
99
- }, context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rollup" ? omit(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build?.rollupOptions : {}, {
100
- cache: !context.config.skipCache ? joinPaths(context.cachePath, "rollup") : false,
101
- logLevel: context.config.logLevel,
102
- output: [{
103
- dir: context.config.output.buildPath,
104
- format: "es",
105
- entryFileNames: "[name].js",
106
- preserveModules: true,
107
- sourcemap: context.config.mode === "development"
108
- }, {
109
- dir: context.config.output.buildPath,
110
- format: "cjs",
111
- entryFileNames: "[name].cjs",
112
- preserveModules: true,
113
- sourcemap: context.config.mode === "development"
114
- }]
115
- });
116
- }
117
-
118
- //#endregion
119
- export { extractRollupConfig };
@@ -1,79 +0,0 @@
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 __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
6
- let __stryke_path_append = require("@stryke/path/append");
7
- let __stryke_path_replace = require("@stryke/path/replace");
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;
@@ -1,76 +0,0 @@
1
- import defu$1 from "defu";
2
- import { joinPaths } from "@stryke/path/join-paths";
3
- import { isFunction } from "@stryke/type-checks/is-function";
4
- import { appendPath } from "@stryke/path/append";
5
- import { replacePath } from "@stryke/path/replace";
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 };
@@ -1,8 +0,0 @@
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;
@@ -1,6 +0,0 @@
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 };