@powerlines/plugin-rolldown 0.7.126 → 0.7.128
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.
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/helpers/index.cjs +3 -1
- package/dist/helpers/index.mjs +3 -1
- package/dist/helpers/unplugin.cjs +12 -1
- package/dist/helpers/unplugin.mjs +11 -1
- package/dist/index.cjs +38 -1
- package/dist/index.mjs +33 -1
- package/dist/powerlines/schemas/fs.cjs +226 -1
- package/dist/powerlines/schemas/fs.mjs +224 -1
- package/dist/powerlines/src/api.cjs +576 -9
- package/dist/powerlines/src/api.mjs +578 -1
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -1
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -1
- package/dist/powerlines/src/internal/helpers/environment.cjs +52 -1
- package/dist/powerlines/src/internal/helpers/environment.mjs +48 -1
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +50 -7
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +48 -7
- package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -1
- package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -1
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -3
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -3
- package/dist/powerlines/src/internal/helpers/install.cjs +37 -1
- package/dist/powerlines/src/internal/helpers/install.mjs +36 -1
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +97 -7
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +93 -7
- package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -1
- package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -1
- package/dist/powerlines/src/lib/build/rolldown.cjs +125 -1
- package/dist/powerlines/src/lib/build/rolldown.mjs +119 -1
- package/dist/powerlines/src/lib/build/rollup.cjs +45 -1
- package/dist/powerlines/src/lib/build/rollup.mjs +39 -1
- package/dist/powerlines/src/lib/config-file.cjs +79 -1
- package/dist/powerlines/src/lib/config-file.mjs +76 -1
- package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -1
- package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -1
- package/dist/powerlines/src/lib/contexts/context.cjs +931 -1
- package/dist/powerlines/src/lib/contexts/context.mjs +929 -1
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -1
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -1
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -1
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -1
- package/dist/powerlines/src/lib/entry.cjs +69 -1
- package/dist/powerlines/src/lib/entry.mjs +67 -1
- package/dist/powerlines/src/lib/fs/helpers.cjs +85 -1
- package/dist/powerlines/src/lib/fs/helpers.mjs +81 -1
- package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -1
- package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -1
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -1
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -1
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -1
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -1
- package/dist/powerlines/src/lib/fs/vfs.cjs +830 -1
- package/dist/powerlines/src/lib/fs/vfs.mjs +828 -1
- package/dist/powerlines/src/lib/logger.cjs +58 -1
- package/dist/powerlines/src/lib/logger.mjs +55 -1
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -1
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -1
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -4
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -4
- package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -1
- package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -1
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -1
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -1
- package/dist/powerlines/src/lib/unplugin/index.cjs +3 -1
- package/dist/powerlines/src/lib/unplugin/index.mjs +5 -1
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +127 -5
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +126 -5
- package/dist/powerlines/src/lib/utilities/file-header.cjs +19 -7
- package/dist/powerlines/src/lib/utilities/file-header.mjs +18 -7
- package/dist/powerlines/src/lib/utilities/meta.cjs +45 -1
- package/dist/powerlines/src/lib/utilities/meta.mjs +41 -1
- package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -1
- package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -1
- package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -1
- package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -1
- package/dist/powerlines/src/plugin-utils/paths.cjs +36 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +35 -1
- package/dist/powerlines/src/types/build.cjs +15 -1
- package/dist/powerlines/src/types/build.mjs +14 -1
- package/dist/powerlines/src/types/commands.cjs +16 -1
- package/dist/powerlines/src/types/commands.mjs +15 -1
- package/dist/powerlines/src/types/config.d.mts +0 -1
- package/dist/powerlines/src/types/context.d.cts +43 -2
- package/dist/powerlines/src/types/context.d.mts +43 -2
- package/dist/powerlines/src/types/fs.d.cts +14 -0
- package/dist/powerlines/src/types/fs.d.mts +14 -0
- package/dist/powerlines/src/types/plugin.cjs +32 -1
- package/dist/powerlines/src/types/plugin.mjs +31 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +10 -10
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_tsconfig = require('../../lib/typescript/tsconfig.cjs');
|
|
3
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
4
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
5
|
+
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
6
|
+
let chalk = require("chalk");
|
|
7
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
8
|
+
let __donedeal0_superdiff = require("@donedeal0/superdiff");
|
|
9
|
+
let __stryke_fs_json = require("@stryke/fs/json");
|
|
10
|
+
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
11
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
12
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
2
13
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
//#region ../powerlines/src/internal/helpers/resolve-tsconfig.ts
|
|
15
|
+
function getTsconfigDtsPath(context) {
|
|
16
|
+
return (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_file_path_fns.relativePath)((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot), (0, __stryke_path_file_path_fns.findFilePath)(context.dtsPath)), (0, __stryke_path_file_path_fns.findFileName)(context.dtsPath));
|
|
17
|
+
}
|
|
18
|
+
async function resolveTsconfigChanges(context) {
|
|
19
|
+
const tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
|
|
20
|
+
const tsconfigJson = await (0, __stryke_fs_json.readJsonFile)(require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig));
|
|
21
|
+
tsconfigJson.compilerOptions ??= {};
|
|
22
|
+
if (context.config.output.dts !== false) {
|
|
23
|
+
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
24
|
+
if (!tsconfigJson.include?.some((filePattern) => require_tsconfig.isIncludeMatchFound(filePattern, [context.dtsPath, dtsRelativePath]))) {
|
|
25
|
+
tsconfigJson.include ??= [];
|
|
26
|
+
tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!tsconfig.options.lib?.some((lib) => [
|
|
30
|
+
"lib.esnext.d.ts",
|
|
31
|
+
"lib.es2021.d.ts",
|
|
32
|
+
"lib.es2022.d.ts",
|
|
33
|
+
"lib.es2023.d.ts"
|
|
34
|
+
].includes(lib.toLowerCase()))) {
|
|
35
|
+
tsconfigJson.compilerOptions.lib ??= [];
|
|
36
|
+
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
37
|
+
}
|
|
38
|
+
if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
|
|
39
|
+
if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
|
|
40
|
+
if (context.config.build.platform === "node") {
|
|
41
|
+
if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
|
|
42
|
+
tsconfigJson.compilerOptions.types ??= [];
|
|
43
|
+
tsconfigJson.compilerOptions.types.push("node");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return tsconfigJson;
|
|
47
|
+
}
|
|
48
|
+
async function initializeTsconfig(context) {
|
|
49
|
+
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
|
|
50
|
+
if (!(0, __stryke_fs_package_fns.isPackageExists)("typescript")) throw new Error("The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"");
|
|
51
|
+
const tsconfigFilePath = require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
52
|
+
context.tsconfig.originalTsconfigJson = await (0, __stryke_fs_json.readJsonFile)(tsconfigFilePath);
|
|
53
|
+
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
54
|
+
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
55
|
+
await context.fs.write(tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(context.tsconfig.tsconfigJson));
|
|
56
|
+
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
57
|
+
}
|
|
58
|
+
async function resolveTsconfig(context) {
|
|
59
|
+
const updateTsconfigJson = await (0, __stryke_fs_json.readJsonFile)(context.tsconfig.tsconfigFilePath);
|
|
60
|
+
if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
|
|
61
|
+
const result = (0, __donedeal0_superdiff.getObjectDiff)(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
|
|
62
|
+
ignoreArrayOrder: true,
|
|
63
|
+
showOnly: {
|
|
64
|
+
statuses: [
|
|
65
|
+
"added",
|
|
66
|
+
"deleted",
|
|
67
|
+
"updated"
|
|
68
|
+
],
|
|
69
|
+
granularity: "deep"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const changes = [];
|
|
73
|
+
const getChanges = (difference, property) => {
|
|
74
|
+
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);
|
|
75
|
+
else changes.push({
|
|
76
|
+
field: property ? `${property}.${difference.property}` : difference.property,
|
|
77
|
+
status: difference.status,
|
|
78
|
+
previous: difference.status === "added" ? "---" : __stryke_json_storm_json.StormJSON.stringify(difference.previousValue),
|
|
79
|
+
current: difference.status === "deleted" ? "---" : __stryke_json_storm_json.StormJSON.stringify(difference.currentValue)
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
for (const diff of result.diff) getChanges(diff);
|
|
83
|
+
if (changes.length > 0) context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
|
|
84
|
+
|
|
85
|
+
${changes.map((change, i) => `${chalk.default.bold.whiteBright(`${i + 1}. ${(0, __stryke_string_format_title_case.titleCase)(change.status)} the ${change.field} field: `)}
|
|
86
|
+
${chalk.default.red(` - Previous: ${change.previous} `)}
|
|
87
|
+
${chalk.default.green(` - Updated: ${change.current} `)}
|
|
88
|
+
`).join("\n")}
|
|
89
|
+
`);
|
|
90
|
+
await context.fs.write(context.tsconfig.tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(updateTsconfigJson));
|
|
91
|
+
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
92
|
+
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
exports.getTsconfigDtsPath = getTsconfigDtsPath;
|
|
97
|
+
exports.initializeTsconfig = initializeTsconfig;
|
|
98
|
+
exports.resolveTsconfig = resolveTsconfig;
|
|
@@ -1,8 +1,94 @@
|
|
|
1
|
-
import{getParsedTypeScriptConfig
|
|
1
|
+
import { getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound } from "../../lib/typescript/tsconfig.mjs";
|
|
2
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
4
|
+
import { isPackageExists } from "@stryke/fs/package-fns";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { getObjectDiff } from "@donedeal0/superdiff";
|
|
7
|
+
import { readJsonFile } from "@stryke/fs/json";
|
|
8
|
+
import { StormJSON } from "@stryke/json/storm-json";
|
|
9
|
+
import { findFileName, findFilePath, relativePath } from "@stryke/path/file-path-fns";
|
|
10
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
//#region ../powerlines/src/internal/helpers/resolve-tsconfig.ts
|
|
13
|
+
function getTsconfigDtsPath(context) {
|
|
14
|
+
return joinPaths(relativePath(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
|
|
15
|
+
}
|
|
16
|
+
async function resolveTsconfigChanges(context) {
|
|
17
|
+
const tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
|
|
18
|
+
const tsconfigJson = await readJsonFile(getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig));
|
|
19
|
+
tsconfigJson.compilerOptions ??= {};
|
|
20
|
+
if (context.config.output.dts !== false) {
|
|
21
|
+
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
22
|
+
if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [context.dtsPath, dtsRelativePath]))) {
|
|
23
|
+
tsconfigJson.include ??= [];
|
|
24
|
+
tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!tsconfig.options.lib?.some((lib) => [
|
|
28
|
+
"lib.esnext.d.ts",
|
|
29
|
+
"lib.es2021.d.ts",
|
|
30
|
+
"lib.es2022.d.ts",
|
|
31
|
+
"lib.es2023.d.ts"
|
|
32
|
+
].includes(lib.toLowerCase()))) {
|
|
33
|
+
tsconfigJson.compilerOptions.lib ??= [];
|
|
34
|
+
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
35
|
+
}
|
|
36
|
+
if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
|
|
37
|
+
if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
|
|
38
|
+
if (context.config.build.platform === "node") {
|
|
39
|
+
if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
|
|
40
|
+
tsconfigJson.compilerOptions.types ??= [];
|
|
41
|
+
tsconfigJson.compilerOptions.types.push("node");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return tsconfigJson;
|
|
45
|
+
}
|
|
46
|
+
async function initializeTsconfig(context) {
|
|
47
|
+
context.log(LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
|
|
48
|
+
if (!isPackageExists("typescript")) throw new Error("The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"");
|
|
49
|
+
const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
50
|
+
context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
|
|
51
|
+
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
52
|
+
context.log(LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
53
|
+
await context.fs.write(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
|
|
54
|
+
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
55
|
+
}
|
|
56
|
+
async function resolveTsconfig(context) {
|
|
57
|
+
const updateTsconfigJson = await readJsonFile(context.tsconfig.tsconfigFilePath);
|
|
58
|
+
if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
|
|
59
|
+
const result = getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
|
|
60
|
+
ignoreArrayOrder: true,
|
|
61
|
+
showOnly: {
|
|
62
|
+
statuses: [
|
|
63
|
+
"added",
|
|
64
|
+
"deleted",
|
|
65
|
+
"updated"
|
|
66
|
+
],
|
|
67
|
+
granularity: "deep"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const changes = [];
|
|
71
|
+
const getChanges = (difference, property) => {
|
|
72
|
+
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);
|
|
73
|
+
else changes.push({
|
|
74
|
+
field: property ? `${property}.${difference.property}` : difference.property,
|
|
75
|
+
status: difference.status,
|
|
76
|
+
previous: difference.status === "added" ? "---" : StormJSON.stringify(difference.previousValue),
|
|
77
|
+
current: difference.status === "deleted" ? "---" : StormJSON.stringify(difference.currentValue)
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
for (const diff of result.diff) getChanges(diff);
|
|
81
|
+
if (changes.length > 0) context.log(LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
|
|
82
|
+
|
|
83
|
+
${changes.map((change, i) => `${chalk.bold.whiteBright(`${i + 1}. ${titleCase(change.status)} the ${change.field} field: `)}
|
|
84
|
+
${chalk.red(` - Previous: ${change.previous} `)}
|
|
85
|
+
${chalk.green(` - Updated: ${change.current} `)}
|
|
86
|
+
`).join("\n")}
|
|
87
|
+
`);
|
|
88
|
+
await context.fs.write(context.tsconfig.tsconfigFilePath, StormJSON.stringify(updateTsconfigJson));
|
|
89
|
+
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
90
|
+
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { getTsconfigDtsPath, initializeTsconfig, resolveTsconfig };
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
const
|
|
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 +1,41 @@
|
|
|
1
|
-
import
|
|
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 +1,125 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_rollup = require('./rollup.cjs');
|
|
3
|
+
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
4
|
+
let defu = require("defu");
|
|
5
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
6
|
+
let __rollup_plugin_babel = require("@rollup/plugin-babel");
|
|
7
|
+
let __rollup_plugin_inject = require("@rollup/plugin-inject");
|
|
8
|
+
__rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
|
|
9
|
+
let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
10
|
+
__rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
|
|
11
|
+
let __rollup_plugin_replace = require("@rollup/plugin-replace");
|
|
12
|
+
__rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
|
|
13
|
+
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
14
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
15
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
16
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
17
|
+
let node_fs = require("node:fs");
|
|
18
|
+
let rolldown_experimental = require("rolldown/experimental");
|
|
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/rolldown.ts
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the options for [rolldown](https://rolldown.rs).
|
|
25
|
+
*
|
|
26
|
+
* @param context - The build context.
|
|
27
|
+
* @returns The resolved options.
|
|
28
|
+
*/
|
|
29
|
+
function extractRolldownConfig(context) {
|
|
30
|
+
return (0, defu.default)({
|
|
31
|
+
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(),
|
|
32
|
+
external: (source, importer, isResolved) => {
|
|
33
|
+
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;
|
|
34
|
+
if ((0, __stryke_type_checks_is_function.isFunction)(externalFn) && externalFn(source, importer, isResolved)) return true;
|
|
35
|
+
if (context.config.build.external && (0, __stryke_convert_to_array.toArray)(context.config.build.external).includes(source)) return true;
|
|
36
|
+
if (context.config.build.noExternal && (0, __stryke_convert_to_array.toArray)(context.config.build.noExternal).includes(source)) return false;
|
|
37
|
+
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
38
|
+
return !context.config.build.skipNodeModulesBundle;
|
|
39
|
+
},
|
|
40
|
+
plugins: [
|
|
41
|
+
(0, rollup_plugin_typescript2.default)({
|
|
42
|
+
check: false,
|
|
43
|
+
tsconfig: context.tsconfig.tsconfigFilePath
|
|
44
|
+
}),
|
|
45
|
+
context.config.build.define && Object.keys(context.config.build.define).length > 0 && (0, __rollup_plugin_replace.default)({
|
|
46
|
+
sourceMap: context.config.mode === "development",
|
|
47
|
+
preventAssignment: true,
|
|
48
|
+
...context.config.build.define ?? {}
|
|
49
|
+
}),
|
|
50
|
+
context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && (0, __rollup_plugin_inject.default)({
|
|
51
|
+
sourceMap: context.config.mode === "development",
|
|
52
|
+
...context.config.build.inject
|
|
53
|
+
}),
|
|
54
|
+
(0, rolldown_experimental.viteAliasPlugin)({ entries: context.builtins.reduce((ret, id) => {
|
|
55
|
+
if (!ret.find((e) => e.find === id)) {
|
|
56
|
+
const path = context.fs.ids[id];
|
|
57
|
+
if (path) ret.push({
|
|
58
|
+
find: id,
|
|
59
|
+
replacement: path
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return ret;
|
|
63
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
64
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
65
|
+
find: id,
|
|
66
|
+
replacement: path
|
|
67
|
+
});
|
|
68
|
+
return ret;
|
|
69
|
+
}, []) : []) }),
|
|
70
|
+
(0, __rollup_plugin_babel.getBabelInputPlugin)((0, defu.default)(context.config.transform.babel, {
|
|
71
|
+
caller: {
|
|
72
|
+
name: "powerlines",
|
|
73
|
+
supportsStaticESM: true
|
|
74
|
+
},
|
|
75
|
+
cwd: context.config.projectRoot,
|
|
76
|
+
babelrc: false,
|
|
77
|
+
extensions: [
|
|
78
|
+
".js",
|
|
79
|
+
".jsx",
|
|
80
|
+
".ts",
|
|
81
|
+
".tsx"
|
|
82
|
+
],
|
|
83
|
+
babelHelpers: "bundled",
|
|
84
|
+
skipPreflightCheck: true,
|
|
85
|
+
exclude: /node_modules/
|
|
86
|
+
})),
|
|
87
|
+
(0, __rollup_plugin_node_resolve.default)({
|
|
88
|
+
moduleDirectories: ["node_modules"],
|
|
89
|
+
preferBuiltins: true
|
|
90
|
+
}),
|
|
91
|
+
require_rollup.dtsBundlePlugin
|
|
92
|
+
]
|
|
93
|
+
}, context.config.build.variant === "rolldown" || context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rolldown" || context.config.build.variant === "rollup" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build : {}, {
|
|
94
|
+
experimental: { viteMode: context.config.build.variant === "vite" },
|
|
95
|
+
resolve: {
|
|
96
|
+
mainFields: context.config.build.mainFields,
|
|
97
|
+
conditions: context.config.build.conditions,
|
|
98
|
+
define: context.config.build.define,
|
|
99
|
+
extensions: context.config.build.extensions
|
|
100
|
+
},
|
|
101
|
+
platform: context.config.build.platform,
|
|
102
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
103
|
+
cache: !context.config.skipCache ? (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "rolldown") : false,
|
|
104
|
+
logLevel: context.config.logLevel,
|
|
105
|
+
onLog: context.log,
|
|
106
|
+
jsx: "automatic",
|
|
107
|
+
keepNames: true,
|
|
108
|
+
treeshake: true,
|
|
109
|
+
minify: context.config.mode === "production",
|
|
110
|
+
output: [{
|
|
111
|
+
dir: context.config.output.buildPath,
|
|
112
|
+
format: "es",
|
|
113
|
+
preserveModules: true,
|
|
114
|
+
sourcemap: context.config.mode === "development"
|
|
115
|
+
}, {
|
|
116
|
+
dir: context.config.output.buildPath,
|
|
117
|
+
format: "cjs",
|
|
118
|
+
preserveModules: true,
|
|
119
|
+
sourcemap: context.config.mode === "development"
|
|
120
|
+
}]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
exports.extractRolldownConfig = extractRolldownConfig;
|
|
@@ -1 +1,119 @@
|
|
|
1
|
-
import{dtsBundlePlugin
|
|
1
|
+
import { dtsBundlePlugin } from "./rollup.mjs";
|
|
2
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
3
|
+
import defu$1 from "defu";
|
|
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 { viteAliasPlugin } from "rolldown/experimental";
|
|
14
|
+
import typescriptPlugin from "rollup-plugin-typescript2";
|
|
15
|
+
|
|
16
|
+
//#region ../powerlines/src/lib/build/rolldown.ts
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the options for [rolldown](https://rolldown.rs).
|
|
19
|
+
*
|
|
20
|
+
* @param context - The build context.
|
|
21
|
+
* @returns The resolved options.
|
|
22
|
+
*/
|
|
23
|
+
function extractRolldownConfig(context) {
|
|
24
|
+
return defu$1({
|
|
25
|
+
input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
|
|
26
|
+
external: (source, importer, isResolved) => {
|
|
27
|
+
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;
|
|
28
|
+
if (isFunction(externalFn) && externalFn(source, importer, isResolved)) return true;
|
|
29
|
+
if (context.config.build.external && toArray(context.config.build.external).includes(source)) return true;
|
|
30
|
+
if (context.config.build.noExternal && toArray(context.config.build.noExternal).includes(source)) return false;
|
|
31
|
+
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
32
|
+
return !context.config.build.skipNodeModulesBundle;
|
|
33
|
+
},
|
|
34
|
+
plugins: [
|
|
35
|
+
typescriptPlugin({
|
|
36
|
+
check: false,
|
|
37
|
+
tsconfig: context.tsconfig.tsconfigFilePath
|
|
38
|
+
}),
|
|
39
|
+
context.config.build.define && Object.keys(context.config.build.define).length > 0 && replace({
|
|
40
|
+
sourceMap: context.config.mode === "development",
|
|
41
|
+
preventAssignment: true,
|
|
42
|
+
...context.config.build.define ?? {}
|
|
43
|
+
}),
|
|
44
|
+
context.config.build.inject && Object.keys(context.config.build.inject).length > 0 && inject({
|
|
45
|
+
sourceMap: context.config.mode === "development",
|
|
46
|
+
...context.config.build.inject
|
|
47
|
+
}),
|
|
48
|
+
viteAliasPlugin({ entries: context.builtins.reduce((ret, id) => {
|
|
49
|
+
if (!ret.find((e) => e.find === id)) {
|
|
50
|
+
const path = context.fs.ids[id];
|
|
51
|
+
if (path) ret.push({
|
|
52
|
+
find: id,
|
|
53
|
+
replacement: path
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return ret;
|
|
57
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
58
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
59
|
+
find: id,
|
|
60
|
+
replacement: path
|
|
61
|
+
});
|
|
62
|
+
return ret;
|
|
63
|
+
}, []) : []) }),
|
|
64
|
+
getBabelInputPlugin(defu$1(context.config.transform.babel, {
|
|
65
|
+
caller: {
|
|
66
|
+
name: "powerlines",
|
|
67
|
+
supportsStaticESM: true
|
|
68
|
+
},
|
|
69
|
+
cwd: context.config.projectRoot,
|
|
70
|
+
babelrc: false,
|
|
71
|
+
extensions: [
|
|
72
|
+
".js",
|
|
73
|
+
".jsx",
|
|
74
|
+
".ts",
|
|
75
|
+
".tsx"
|
|
76
|
+
],
|
|
77
|
+
babelHelpers: "bundled",
|
|
78
|
+
skipPreflightCheck: true,
|
|
79
|
+
exclude: /node_modules/
|
|
80
|
+
})),
|
|
81
|
+
resolve({
|
|
82
|
+
moduleDirectories: ["node_modules"],
|
|
83
|
+
preferBuiltins: true
|
|
84
|
+
}),
|
|
85
|
+
dtsBundlePlugin
|
|
86
|
+
]
|
|
87
|
+
}, context.config.build.variant === "rolldown" || context.config.build.variant === "rollup" ? context.config.build.override : {}, context.config.build.variant === "vite" ? context.config.build.override.build?.rollupOptions : {}, context.config.build.variant === "rolldown" || context.config.build.variant === "rollup" ? omit(context.config.build, ["override", "variant"]) : {}, context.config.build.variant === "vite" ? context.config.build.build : {}, {
|
|
88
|
+
experimental: { viteMode: context.config.build.variant === "vite" },
|
|
89
|
+
resolve: {
|
|
90
|
+
mainFields: context.config.build.mainFields,
|
|
91
|
+
conditions: context.config.build.conditions,
|
|
92
|
+
define: context.config.build.define,
|
|
93
|
+
extensions: context.config.build.extensions
|
|
94
|
+
},
|
|
95
|
+
platform: context.config.build.platform,
|
|
96
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
97
|
+
cache: !context.config.skipCache ? joinPaths(context.cachePath, "rolldown") : false,
|
|
98
|
+
logLevel: context.config.logLevel,
|
|
99
|
+
onLog: context.log,
|
|
100
|
+
jsx: "automatic",
|
|
101
|
+
keepNames: true,
|
|
102
|
+
treeshake: true,
|
|
103
|
+
minify: context.config.mode === "production",
|
|
104
|
+
output: [{
|
|
105
|
+
dir: context.config.output.buildPath,
|
|
106
|
+
format: "es",
|
|
107
|
+
preserveModules: true,
|
|
108
|
+
sourcemap: context.config.mode === "development"
|
|
109
|
+
}, {
|
|
110
|
+
dir: context.config.output.buildPath,
|
|
111
|
+
format: "cjs",
|
|
112
|
+
preserveModules: true,
|
|
113
|
+
sourcemap: context.config.mode === "development"
|
|
114
|
+
}]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { extractRolldownConfig };
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
const
|
|
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_babel = require("@rollup/plugin-babel");
|
|
6
|
+
let __rollup_plugin_inject = require("@rollup/plugin-inject");
|
|
7
|
+
__rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
|
|
8
|
+
let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
9
|
+
__rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
|
|
10
|
+
let __rollup_plugin_replace = require("@rollup/plugin-replace");
|
|
11
|
+
__rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
|
|
12
|
+
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
13
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
14
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
15
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
16
|
+
let node_fs = require("node:fs");
|
|
17
|
+
let rollup_plugin_typescript2 = require("rollup-plugin-typescript2");
|
|
18
|
+
rollup_plugin_typescript2 = require_rolldown_runtime.__toESM(rollup_plugin_typescript2);
|
|
19
|
+
require("@rollup/plugin-alias");
|
|
20
|
+
|
|
21
|
+
//#region ../powerlines/src/lib/build/rollup.ts
|
|
22
|
+
/**
|
|
23
|
+
* A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
|
|
27
|
+
*/
|
|
28
|
+
const dtsBundlePlugin = {
|
|
29
|
+
name: "powerlines:dts-bundle",
|
|
30
|
+
async generateBundle(_opts, bundle) {
|
|
31
|
+
for (const [, file] of Object.entries(bundle)) {
|
|
32
|
+
if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
|
|
33
|
+
const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
|
|
34
|
+
const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
|
|
35
|
+
this.emitFile({
|
|
36
|
+
type: "asset",
|
|
37
|
+
fileName: dtsFileName,
|
|
38
|
+
source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.dtsBundlePlugin = dtsBundlePlugin;
|