@powerlines/plugin-vite 0.14.292 → 0.14.293
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/core/src/lib/entry.mjs +15 -0
- package/dist/core/src/lib/logger.mjs +40 -0
- package/dist/core/src/lib/logger.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/helpers.mjs +19 -0
- package/dist/core/src/lib/unplugin/helpers.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/index.mjs +5 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs +66 -0
- package/dist/core/src/lib/unplugin/module-resolution.mjs.map +1 -0
- package/dist/core/src/lib/unplugin/plugin.mjs +71 -0
- package/dist/core/src/lib/unplugin/plugin.mjs.map +1 -0
- package/dist/core/src/lib/utilities/source-file.mjs +22 -0
- package/dist/core/src/lib/utilities/source-file.mjs.map +1 -0
- package/dist/core/src/plugin-utils/paths.mjs +4 -0
- package/dist/core/src/types/_internal.d.mts +85 -0
- package/dist/core/src/types/_internal.d.mts.map +1 -0
- package/dist/core/src/types/api.d.mts +103 -0
- package/dist/core/src/types/api.d.mts.map +1 -0
- package/dist/core/src/types/commands.d.mts +10 -0
- package/dist/core/src/types/commands.d.mts.map +1 -0
- package/dist/core/src/types/config.d.mts +552 -0
- package/dist/core/src/types/config.d.mts.map +1 -0
- package/dist/core/src/types/context.d.mts +511 -0
- package/dist/core/src/types/context.d.mts.map +1 -0
- package/dist/core/src/types/fs.d.mts +487 -0
- package/dist/core/src/types/fs.d.mts.map +1 -0
- package/dist/core/src/types/hooks.d.mts +99 -0
- package/dist/core/src/types/hooks.d.mts.map +1 -0
- package/dist/core/src/types/index.d.mts +9 -0
- package/dist/core/src/types/plugin.d.mts +204 -0
- package/dist/core/src/types/plugin.d.mts.map +1 -0
- package/dist/core/src/types/tsconfig.d.mts +70 -0
- package/dist/core/src/types/tsconfig.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.d.mts +25 -0
- package/dist/core/src/types/unplugin.d.mts.map +1 -0
- package/dist/core/src/types/unplugin.mjs +22 -0
- package/dist/core/src/types/unplugin.mjs.map +1 -0
- package/dist/helpers/index.d.mts +2 -1
- package/dist/helpers/index.mjs +2 -1
- package/dist/helpers/resolve-options.d.mts +16 -0
- package/dist/helpers/resolve-options.d.mts.map +1 -0
- package/dist/helpers/resolve-options.mjs +69 -0
- package/dist/helpers/resolve-options.mjs.map +1 -0
- package/dist/helpers/unplugin.mjs +2 -1
- package/dist/helpers/unplugin.mjs.map +1 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -7
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-esbuild/src/helpers/resolve-options.mjs +73 -0
- package/dist/plugin-esbuild/src/helpers/resolve-options.mjs.map +1 -0
- package/dist/plugin-rolldown/src/helpers/resolve-options.mjs +117 -0
- package/dist/plugin-rolldown/src/helpers/resolve-options.mjs.map +1 -0
- package/dist/plugin-rollup/src/helpers/resolve-options.mjs +116 -0
- package/dist/plugin-rollup/src/helpers/resolve-options.mjs.map +1 -0
- package/dist/types/{internal.d.mts → _internal.d.mts} +3 -3
- package/dist/types/_internal.d.mts.map +1 -0
- package/dist/types/build.d.mts +13 -0
- package/dist/types/build.d.mts.map +1 -0
- package/dist/types/build.mjs +1 -0
- package/dist/types/index.d.mts +3 -2
- package/dist/types/plugin.d.mts +13 -7
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +30 -107
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/helpers/index.cjs +0 -3
- package/dist/helpers/index.d.cts +0 -2
- package/dist/helpers/unplugin.cjs +0 -11
- package/dist/helpers/unplugin.d.cts +0 -8
- package/dist/helpers/unplugin.d.cts.map +0 -1
- package/dist/index.cjs +0 -47
- package/dist/index.d.cts +0 -14
- package/dist/index.d.cts.map +0 -1
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +0 -2
- package/dist/types/internal.cjs +0 -0
- package/dist/types/internal.d.cts +0 -15
- package/dist/types/internal.d.cts.map +0 -1
- package/dist/types/internal.d.mts.map +0 -1
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +0 -18
- package/dist/types/plugin.d.cts.map +0 -1
- /package/dist/types/{internal.mjs → _internal.mjs} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import "../../../core/src/lib/entry.mjs";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
4
|
+
import "@stryke/path/replace";
|
|
5
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
6
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
7
|
+
|
|
8
|
+
//#region ../plugin-esbuild/src/helpers/resolve-options.ts
|
|
9
|
+
const DEFAULT_ESBUILD_CONFIG = {
|
|
10
|
+
target: "esnext",
|
|
11
|
+
platform: "neutral",
|
|
12
|
+
format: "esm",
|
|
13
|
+
write: true,
|
|
14
|
+
minify: true,
|
|
15
|
+
sourcemap: false,
|
|
16
|
+
bundle: true,
|
|
17
|
+
treeShaking: true,
|
|
18
|
+
keepNames: true,
|
|
19
|
+
splitting: true,
|
|
20
|
+
logLevel: "silent"
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the esbuild options.
|
|
24
|
+
*
|
|
25
|
+
* @param context - The build context.
|
|
26
|
+
* @returns The resolved esbuild options.
|
|
27
|
+
*/
|
|
28
|
+
function resolveOptions(context) {
|
|
29
|
+
if (context.config.inject && Object.keys(context.config.inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js"), Object.entries(context.config.inject).map(([key, value]) => {
|
|
30
|
+
if (value) if (Array.isArray(value)) {
|
|
31
|
+
if (camelCase(key) !== key) {
|
|
32
|
+
if (value.length === 1) return `
|
|
33
|
+
import ${camelCase(key)} from "${value[0]}";
|
|
34
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
35
|
+
else if (value.length > 1) return `
|
|
36
|
+
import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
|
|
37
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
38
|
+
} else if (value.length === 1) return `
|
|
39
|
+
import ${key} from "${value[0]}";
|
|
40
|
+
export { ${key} };`;
|
|
41
|
+
else if (value.length > 1) return `
|
|
42
|
+
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
43
|
+
export { ${key} };`;
|
|
44
|
+
} else if (camelCase(key) !== key) return `
|
|
45
|
+
import ${camelCase(key)} from "${value[0]}";
|
|
46
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
47
|
+
else return `
|
|
48
|
+
import ${key} from "${value}";
|
|
49
|
+
export { ${key} };`;
|
|
50
|
+
return "";
|
|
51
|
+
}).join("\n"));
|
|
52
|
+
return defu({
|
|
53
|
+
alias: context.alias,
|
|
54
|
+
inject: context.config.inject && Object.keys(context.config.inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.artifactsPath, "inject-shim.js")] : void 0
|
|
55
|
+
}, context.config?.esbuild ? context.config.esbuild : {}, {
|
|
56
|
+
mainFields: context.config.resolve.mainFields,
|
|
57
|
+
conditions: context.config.resolve.conditions,
|
|
58
|
+
define: context.config.define,
|
|
59
|
+
resolveExtensions: context.config.resolve.extensions,
|
|
60
|
+
packages: context.config.resolve.skipNodeModulesBundle ? "external" : context.config?.esbuild ? (context.config?.esbuild).packages : void 0,
|
|
61
|
+
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
62
|
+
platform: context.config.platform,
|
|
63
|
+
outdir: context.config.output.buildPath,
|
|
64
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
65
|
+
minify: context.config.mode !== "development",
|
|
66
|
+
metafile: context.config.mode === "development",
|
|
67
|
+
sourcemap: context.config.mode === "development"
|
|
68
|
+
}, DEFAULT_ESBUILD_CONFIG);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { resolveOptions };
|
|
73
|
+
//# sourceMappingURL=resolve-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-options.mjs","names":["DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions>"],"sources":["../../../../../plugin-esbuild/src/helpers/resolve-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { resolveEntryOutput } from \"@powerlines/core/lib/entry\";\nimport type {\n Context,\n ResolvedEntryTypeDefinition\n} from \"@powerlines/core/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { BuildOptions, Format, LogLevel, Platform } from \"esbuild\";\nimport { EsbuildPluginContext } from \"../types/plugin\";\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<BuildOptions> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): BuildOptions[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[replaceExtension(replacePath(entry, context.config.root))] =\n replacePath(entry, context.config.root);\n } else {\n ret[entry.output || resolveEntryOutput(context, entry)] = entry.file;\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function resolveOptions(context: Context): BuildOptions {\n if (context.config.inject && Object.keys(context.config.inject).length > 0) {\n context.fs.writeSync(\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n ),\n Object.entries(context.config.inject)\n .map(([key, value]) => {\n if (value) {\n if (Array.isArray(value)) {\n if (camelCase(key) !== key) {\n if (value.length === 1) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n }\n } else if (value.length === 1) {\n return `\nimport ${key} from \"${value[0]}\";\nexport { ${key} };`;\n } else if (value.length > 1) {\n return `\nimport ${value[1] === \"*\" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from \"${value[0]}\";\nexport { ${key} };`;\n }\n } else if (camelCase(key) !== key) {\n return `\nimport ${camelCase(key)} from \"${value[0]}\";\nexport { ${camelCase(key)} as \"${key}\" }`;\n } else {\n return `\nimport ${key} from \"${value}\";\nexport { ${key} };`;\n }\n }\n\n return \"\";\n })\n .join(\"\\n\")\n );\n }\n\n return defu(\n {\n alias: context.alias,\n inject:\n context.config.inject && Object.keys(context.config.inject).length > 0\n ? [\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n context.artifactsPath,\n \"inject-shim.js\"\n )\n ]\n : undefined\n },\n (context as EsbuildPluginContext).config?.esbuild\n ? (context as EsbuildPluginContext).config.esbuild\n : {},\n {\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n resolveExtensions: context.config.resolve.extensions,\n packages: context.config.resolve.skipNodeModulesBundle\n ? \"external\"\n : (context as EsbuildPluginContext).config?.esbuild\n ? ((context as EsbuildPluginContext).config?.esbuild as BuildOptions)\n .packages\n : undefined,\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.platform,\n outdir: context.config.output.buildPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n ) as BuildOptions;\n}\n"],"mappings":";;;;;;;;AA+BA,MAAaA,yBAAgD;CAC3D,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,aAAa;CACb,WAAW;CACX,WAAW;CACX,UAAU;CACX;;;;;;;AAkCD,SAAgB,eAAe,SAAgC;AAC7D,KAAI,QAAQ,OAAO,UAAU,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,EACvE,SAAQ,GAAG,UACT,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,QAAQ,eACR,iBACD,EACD,OAAO,QAAQ,QAAQ,OAAO,OAAO,CAClC,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,MACF,KAAI,MAAM,QAAQ,MAAM,EACtB;OAAI,UAAU,IAAI,KAAK,KACrB;QAAI,MAAM,WAAW,EACnB,QAAO;SAChB,UAAU,IAAI,CAAC,SAAS,MAAM,GAAG;WAC/B,UAAU,IAAI,CAAC,OAAO,IAAI;aACV,MAAM,SAAS,EACxB,QAAO;SAChB,MAA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AQ,OAAO,SAAS;EAChC,UAAU,QAAQ,OAAO,SAAS;EAClC,WAAW,QAAQ,OAAO,SAAS;EACpC,EACD,uBACD"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { dtsBundlePlugin } from "../../../plugin-rollup/src/helpers/resolve-options.mjs";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
4
|
+
import { appendPath } from "@stryke/path/append";
|
|
5
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
6
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
7
|
+
import { getBabelInputPlugin } from "@rollup/plugin-babel";
|
|
8
|
+
import inject from "@rollup/plugin-inject";
|
|
9
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
10
|
+
import replace from "@rollup/plugin-replace";
|
|
11
|
+
import { globSync } from "node:fs";
|
|
12
|
+
import typescriptPlugin from "rollup-plugin-typescript2";
|
|
13
|
+
import { viteAliasPlugin } from "rolldown/experimental";
|
|
14
|
+
|
|
15
|
+
//#region ../plugin-rolldown/src/helpers/resolve-options.ts
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the options for [rolldown](https://rolldown.rs).
|
|
18
|
+
*
|
|
19
|
+
* @param context - The build context.
|
|
20
|
+
* @returns The resolved options.
|
|
21
|
+
*/
|
|
22
|
+
function resolveOptions(context) {
|
|
23
|
+
return defu({
|
|
24
|
+
input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
|
|
25
|
+
external: (source) => {
|
|
26
|
+
if (context.config.resolve.external && toArray(context.config.resolve.external).includes(source)) return true;
|
|
27
|
+
if (context.config.resolve.noExternal && toArray(context.config.resolve.noExternal).includes(source)) return false;
|
|
28
|
+
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
29
|
+
return !context.config.resolve.skipNodeModulesBundle;
|
|
30
|
+
},
|
|
31
|
+
plugins: [
|
|
32
|
+
typescriptPlugin({
|
|
33
|
+
check: false,
|
|
34
|
+
tsconfig: context.tsconfig.tsconfigFilePath
|
|
35
|
+
}),
|
|
36
|
+
context.config.define && Object.keys(context.config.define).length > 0 && replace({
|
|
37
|
+
sourceMap: context.config.mode === "development",
|
|
38
|
+
preventAssignment: true,
|
|
39
|
+
...context.config.define ?? {}
|
|
40
|
+
}),
|
|
41
|
+
context.config.inject && Object.keys(context.config.inject).length > 0 && inject({
|
|
42
|
+
sourceMap: context.config.mode === "development",
|
|
43
|
+
...context.config.inject
|
|
44
|
+
}),
|
|
45
|
+
viteAliasPlugin({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
|
|
46
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
47
|
+
find: id,
|
|
48
|
+
replacement: path
|
|
49
|
+
});
|
|
50
|
+
else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
|
|
51
|
+
return ret;
|
|
52
|
+
}, []) }),
|
|
53
|
+
context.config.babel && getBabelInputPlugin(defu(context.config.babel, {
|
|
54
|
+
caller: {
|
|
55
|
+
name: "powerlines",
|
|
56
|
+
supportsStaticESM: true
|
|
57
|
+
},
|
|
58
|
+
cwd: context.config.root,
|
|
59
|
+
babelrc: false,
|
|
60
|
+
extensions: [
|
|
61
|
+
".js",
|
|
62
|
+
".jsx",
|
|
63
|
+
".ts",
|
|
64
|
+
".tsx"
|
|
65
|
+
],
|
|
66
|
+
babelHelpers: "bundled",
|
|
67
|
+
skipPreflightCheck: true,
|
|
68
|
+
exclude: /node_modules/
|
|
69
|
+
})),
|
|
70
|
+
resolve({
|
|
71
|
+
moduleDirectories: ["node_modules"],
|
|
72
|
+
preferBuiltins: true
|
|
73
|
+
}),
|
|
74
|
+
dtsBundlePlugin
|
|
75
|
+
]
|
|
76
|
+
}, context.config?.rolldown ? context.config?.rolldown : {}, context.config?.rollup ? context.config?.rollup : {}, {
|
|
77
|
+
resolve: {
|
|
78
|
+
alias: context.alias,
|
|
79
|
+
mainFields: context.config.resolve.mainFields,
|
|
80
|
+
conditions: context.config.resolve.conditions,
|
|
81
|
+
define: context.config.define,
|
|
82
|
+
extensions: context.config.resolve.extensions
|
|
83
|
+
},
|
|
84
|
+
transform: {
|
|
85
|
+
define: context.config.define,
|
|
86
|
+
inject: context.config.inject
|
|
87
|
+
},
|
|
88
|
+
platform: context.config.platform,
|
|
89
|
+
tsconfig: appendPath(context.tsconfig.tsconfigFilePath, context.workspaceConfig.workspaceRoot),
|
|
90
|
+
cache: !context.config.skipCache ? joinPaths(context.cachePath, "rolldown") : false,
|
|
91
|
+
logLevel: context.config.logLevel,
|
|
92
|
+
onLog(level, log) {
|
|
93
|
+
if (log.message?.trim()) context.log(level === "info" ? "debug" : level, log.message?.trim() ?? "");
|
|
94
|
+
},
|
|
95
|
+
minify: context.config.mode === "production",
|
|
96
|
+
output: [{
|
|
97
|
+
dir: context.config.output.buildPath,
|
|
98
|
+
format: "es",
|
|
99
|
+
preserveModules: true,
|
|
100
|
+
sourcemap: context.config.mode === "development"
|
|
101
|
+
}, {
|
|
102
|
+
dir: context.config.output.buildPath,
|
|
103
|
+
format: "cjs",
|
|
104
|
+
preserveModules: true,
|
|
105
|
+
sourcemap: context.config.mode === "development"
|
|
106
|
+
}]
|
|
107
|
+
}, {
|
|
108
|
+
keepNames: true,
|
|
109
|
+
treeshake: true,
|
|
110
|
+
shimMissingExports: true,
|
|
111
|
+
transform: { target: "esnext" }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { resolveOptions };
|
|
117
|
+
//# sourceMappingURL=resolve-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-options.mjs","names":["alias"],"sources":["../../../../../plugin-rolldown/src/helpers/resolve-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"@powerlines/core/types\";\nimport { BabelPluginResolvedConfig } from \"@powerlines/plugin-babel/types/plugin\";\nimport { dtsBundlePlugin } from \"@powerlines/plugin-rollup/helpers/resolve-options\";\nimport { RollupPluginResolvedConfig } from \"@powerlines/plugin-rollup/types/plugin\";\nimport {\n getBabelInputPlugin,\n RollupBabelInputPluginOptions\n} from \"@rollup/plugin-babel\";\nimport inject from \"@rollup/plugin-inject\";\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport replace from \"@rollup/plugin-replace\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { globSync } from \"node:fs\";\nimport { RolldownOptions, RollupLog } from \"rolldown\";\nimport { viteAliasPlugin as alias } from \"rolldown/experimental\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { RolldownPluginResolvedConfig } from \"../types/plugin\";\n\n/**\n * Resolves the options for [rolldown](https://rolldown.rs).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(context: Context): RolldownOptions {\n return defu<RolldownOptions, any>(\n {\n input: globSync(\n toArray(context.entry).map(entry =>\n isString(entry) ? entry : entry.file\n )\n ).flat(),\n external: (source: string) => {\n if (\n context.config.resolve.external &&\n toArray(context.config.resolve.external).includes(source)\n ) {\n return true;\n }\n\n if (\n context.config.resolve.noExternal &&\n toArray(context.config.resolve.noExternal).includes(source)\n ) {\n return false;\n }\n\n if (context.builtins.includes(source)) {\n return context.config.projectType !== \"application\";\n }\n\n return !context.config.resolve.skipNodeModulesBundle;\n },\n plugins: [\n typescriptPlugin({\n check: false,\n tsconfig: context.tsconfig.tsconfigFilePath\n }),\n context.config.define &&\n Object.keys(context.config.define).length > 0 &&\n replace({\n sourceMap: context.config.mode === \"development\",\n preventAssignment: true,\n ...(context.config.define ?? {})\n }),\n context.config.inject &&\n Object.keys(context.config.inject).length > 0 &&\n inject({\n sourceMap: context.config.mode === \"development\",\n ...context.config.inject\n }),\n alias({\n entries: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n )\n }),\n (context.config as BabelPluginResolvedConfig).babel &&\n getBabelInputPlugin(\n defu((context.config as BabelPluginResolvedConfig).babel, {\n caller: {\n name: \"powerlines\",\n supportsStaticESM: true\n },\n cwd: context.config.root,\n babelrc: false,\n extensions: [\".js\", \".jsx\", \".ts\", \".tsx\"],\n babelHelpers: \"bundled\",\n skipPreflightCheck: true,\n exclude: /node_modules/\n }) as RollupBabelInputPluginOptions\n ),\n resolve({\n moduleDirectories: [\"node_modules\"],\n preferBuiltins: true\n }),\n dtsBundlePlugin\n ]\n },\n (context.config as RolldownPluginResolvedConfig)?.rolldown\n ? (context.config as RolldownPluginResolvedConfig)?.rolldown\n : {},\n (context.config as RollupPluginResolvedConfig)?.rollup\n ? (context.config as RollupPluginResolvedConfig)?.rollup\n : {},\n {\n resolve: {\n alias: context.alias,\n mainFields: context.config.resolve.mainFields,\n conditions: context.config.resolve.conditions,\n define: context.config.define,\n extensions: context.config.resolve.extensions\n },\n transform: {\n define: context.config.define,\n inject: context.config.inject\n },\n platform: context.config.platform,\n tsconfig: appendPath(\n context.tsconfig.tsconfigFilePath,\n context.workspaceConfig.workspaceRoot\n ),\n cache: !context.config.skipCache\n ? joinPaths(context.cachePath, \"rolldown\")\n : false,\n logLevel: context.config.logLevel,\n onLog(level: \"info\" | \"debug\" | \"warn\", log: RollupLog) {\n if (log.message?.trim()) {\n context.log(\n level === \"info\" ? \"debug\" : level,\n log.message?.trim() ?? \"\"\n );\n }\n },\n minify: context.config.mode === \"production\",\n output: [\n {\n dir: context.config.output.buildPath,\n format: \"es\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n },\n {\n dir: context.config.output.buildPath,\n format: \"cjs\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n }\n ]\n },\n {\n keepNames: true,\n treeshake: true,\n shimMissingExports: true,\n transform: {\n target: \"esnext\"\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,eAAe,SAAmC;AAChE,QAAO,KACL;EACE,OAAO,SACL,QAAQ,QAAQ,MAAM,CAAC,KAAI,UACzB,SAAS,MAAM,GAAG,QAAQ,MAAM,KACjC,CACF,CAAC,MAAM;EACR,WAAW,WAAmB;AAC5B,OACE,QAAQ,OAAO,QAAQ,YACvB,QAAQ,QAAQ,OAAO,QAAQ,SAAS,CAAC,SAAS,OAAO,CAEzD,QAAO;AAGT,OACE,QAAQ,OAAO,QAAQ,cACvB,QAAQ,QAAQ,OAAO,QAAQ,WAAW,CAAC,SAAS,OAAO,CAE3D,QAAO;AAGT,OAAI,QAAQ,SAAS,SAAS,OAAO,CACnC,QAAO,QAAQ,OAAO,gBAAgB;AAGxC,UAAO,CAAC,QAAQ,OAAO,QAAQ;;EAEjC,SAAS;GACP,iBAAiB;IACf,OAAO;IACP,UAAU,QAAQ,SAAS;IAC5B,CAAC;GACF,QAAQ,OAAO,UACb,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,KAC5C,QAAQ;IACN,WAAW,QAAQ,OAAO,SAAS;IACnC,mBAAmB;IACnB,GAAI,QAAQ,OAAO,UAAU,EAAE;IAChC,CAAC;GACJ,QAAQ,OAAO,UACb,OAAO,KAAK,QAAQ,OAAO,OAAO,CAAC,SAAS,KAC5C,O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SAAQ,IACN,UAAU,SAAS,UAAU,OAC7B,IAAI,SAAS,MAAM,IAAI,GACxB;;EAGL,QAAQ,QAAQ,OAAO,SAAS;EAChC,QAAQ,CACN;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,EACD;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,CACF;EACF,EACD;EACE,WAAW;EACX,WAAW;EACX,oBAAoB;EACpB,WAAW,EACT,QAAQ,UACT;EACF,CACF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
4
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
5
|
+
import alias from "@rollup/plugin-alias";
|
|
6
|
+
import { getBabelInputPlugin } from "@rollup/plugin-babel";
|
|
7
|
+
import inject from "@rollup/plugin-inject";
|
|
8
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
9
|
+
import replace from "@rollup/plugin-replace";
|
|
10
|
+
import { globSync } from "node:fs";
|
|
11
|
+
import typescriptPlugin from "rollup-plugin-typescript2";
|
|
12
|
+
|
|
13
|
+
//#region ../plugin-rollup/src/helpers/resolve-options.ts
|
|
14
|
+
/**
|
|
15
|
+
* A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.
|
|
19
|
+
*/
|
|
20
|
+
const dtsBundlePlugin = {
|
|
21
|
+
name: "powerlines:dts-bundle",
|
|
22
|
+
async generateBundle(_opts, bundle) {
|
|
23
|
+
for (const [, file] of Object.entries(bundle)) {
|
|
24
|
+
if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) continue;
|
|
25
|
+
const dtsFileName = file.fileName.replace(/(?:\.cjs|\.mjs|\.esm\.js|\.cjs\.js|\.mjs\.js|\.js)$/, ".d.ts");
|
|
26
|
+
const relativeSourceDtsName = JSON.stringify(`./${file.facadeModuleId.replace(/\.[cm]?[jt]sx?$/, "")}`);
|
|
27
|
+
this.emitFile({
|
|
28
|
+
type: "asset",
|
|
29
|
+
fileName: dtsFileName,
|
|
30
|
+
source: file.exports.includes("default") ? `export * from ${relativeSourceDtsName};\nexport { default } from ${relativeSourceDtsName};\n` : `export * from ${relativeSourceDtsName};\n`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the options for [rollup](https://rollupjs.org).
|
|
37
|
+
*
|
|
38
|
+
* @param context - The build context.
|
|
39
|
+
* @returns The resolved options.
|
|
40
|
+
*/
|
|
41
|
+
function resolveOptions(context) {
|
|
42
|
+
return defu({
|
|
43
|
+
input: globSync(toArray(context.entry).map((entry) => isString(entry) ? entry : entry.file)).flat(),
|
|
44
|
+
external: (source) => {
|
|
45
|
+
if (context.config.resolve.external && toArray(context.config.resolve.external).includes(source)) return true;
|
|
46
|
+
if (context.config.resolve.noExternal && toArray(context.config.resolve.noExternal).includes(source)) return false;
|
|
47
|
+
if (context.builtins.includes(source)) return context.config.projectType !== "application";
|
|
48
|
+
return !context.config.resolve.skipNodeModulesBundle;
|
|
49
|
+
},
|
|
50
|
+
plugins: [
|
|
51
|
+
typescriptPlugin({
|
|
52
|
+
check: false,
|
|
53
|
+
tsconfig: context.tsconfig.tsconfigFilePath
|
|
54
|
+
}),
|
|
55
|
+
context.config.define && Object.keys(context.config.define).length > 0 && replace({
|
|
56
|
+
sourceMap: context.config.mode === "development",
|
|
57
|
+
preventAssignment: true,
|
|
58
|
+
...context.config.define ?? {}
|
|
59
|
+
}),
|
|
60
|
+
context.config.inject && Object.keys(context.config.inject).length > 0 && inject({
|
|
61
|
+
sourceMap: context.config.mode === "development",
|
|
62
|
+
...context.config.inject
|
|
63
|
+
}),
|
|
64
|
+
alias({ entries: Object.entries(context.alias).reduce((ret, [id, path]) => {
|
|
65
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
66
|
+
find: id,
|
|
67
|
+
replacement: path
|
|
68
|
+
});
|
|
69
|
+
else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
|
|
70
|
+
return ret;
|
|
71
|
+
}, []) }),
|
|
72
|
+
context.config.babel && getBabelInputPlugin(defu(context.config.babel, {
|
|
73
|
+
caller: {
|
|
74
|
+
name: "powerlines",
|
|
75
|
+
supportsStaticESM: true
|
|
76
|
+
},
|
|
77
|
+
cwd: context.config.root,
|
|
78
|
+
babelrc: false,
|
|
79
|
+
extensions: [
|
|
80
|
+
".js",
|
|
81
|
+
".jsx",
|
|
82
|
+
".ts",
|
|
83
|
+
".tsx"
|
|
84
|
+
],
|
|
85
|
+
babelHelpers: "bundled",
|
|
86
|
+
skipPreflightCheck: true,
|
|
87
|
+
exclude: /node_modules/
|
|
88
|
+
})),
|
|
89
|
+
resolve({
|
|
90
|
+
moduleDirectories: ["node_modules"],
|
|
91
|
+
preferBuiltins: true
|
|
92
|
+
}),
|
|
93
|
+
dtsBundlePlugin
|
|
94
|
+
].filter(Boolean)
|
|
95
|
+
}, context.config?.rollup ? context.config?.rollup : {}, {
|
|
96
|
+
cache: !context.config.skipCache ? joinPaths(context.cachePath, "rollup") : false,
|
|
97
|
+
logLevel: context.config.logLevel,
|
|
98
|
+
output: [{
|
|
99
|
+
dir: context.config.output.buildPath,
|
|
100
|
+
format: "es",
|
|
101
|
+
entryFileNames: "[name].js",
|
|
102
|
+
preserveModules: true,
|
|
103
|
+
sourcemap: context.config.mode === "development"
|
|
104
|
+
}, {
|
|
105
|
+
dir: context.config.output.buildPath,
|
|
106
|
+
format: "cjs",
|
|
107
|
+
entryFileNames: "[name].cjs",
|
|
108
|
+
preserveModules: true,
|
|
109
|
+
sourcemap: context.config.mode === "development"
|
|
110
|
+
}]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { dtsBundlePlugin, resolveOptions };
|
|
116
|
+
//# sourceMappingURL=resolve-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-options.mjs","names":["dtsBundlePlugin: Plugin"],"sources":["../../../../../plugin-rollup/src/helpers/resolve-options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"@powerlines/core/types\";\nimport { BabelPluginResolvedConfig } from \"@powerlines/plugin-babel/types/plugin\";\nimport alias from \"@rollup/plugin-alias\";\nimport {\n getBabelInputPlugin,\n RollupBabelInputPluginOptions\n} from \"@rollup/plugin-babel\";\nimport inject from \"@rollup/plugin-inject\";\nimport resolve from \"@rollup/plugin-node-resolve\";\nimport replace from \"@rollup/plugin-replace\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { globSync } from \"node:fs\";\nimport type { RollupOptions } from \"rollup\";\nimport { Plugin } from \"rollup\";\nimport typescriptPlugin from \"rollup-plugin-typescript2\";\nimport { RollupPluginResolvedConfig } from \"../types/plugin\";\n\n/**\n * A Rollup plugin to bundle TypeScript declaration files (.d.ts) alongside the JavaScript output files.\n *\n * @remarks\n * This plugin generates .d.ts files for each entry point in the bundle, ensuring that type definitions are available for consumers of the library.\n */\nexport const dtsBundlePlugin: Plugin = {\n name: \"powerlines:dts-bundle\",\n async generateBundle(_opts, bundle) {\n for (const [, file] of Object.entries(bundle)) {\n if (\n file.type === \"asset\" ||\n !file.isEntry ||\n file.facadeModuleId == null\n ) {\n continue;\n }\n\n // Replace various JavaScript file extensions (e.g., .js, .cjs, .mjs, .cjs.js, .mjs.js) with .d.ts for generating type definition file names.\n const dtsFileName = file.fileName.replace(\n /(?:\\.cjs|\\.mjs|\\.esm\\.js|\\.cjs\\.js|\\.mjs\\.js|\\.js)$/,\n \".d.ts\"\n );\n\n const relativeSourceDtsName = JSON.stringify(\n `./${file.facadeModuleId.replace(/\\.[cm]?[jt]sx?$/, \"\")}`\n );\n\n this.emitFile({\n type: \"asset\",\n fileName: dtsFileName,\n source: file.exports.includes(\"default\")\n ? `export * from ${relativeSourceDtsName};\\nexport { default } from ${relativeSourceDtsName};\\n`\n : `export * from ${relativeSourceDtsName};\\n`\n });\n }\n }\n};\n\n/**\n * Resolves the options for [rollup](https://rollupjs.org).\n *\n * @param context - The build context.\n * @returns The resolved options.\n */\nexport function resolveOptions(context: Context): RollupOptions {\n const result = defu(\n {\n input: globSync(\n toArray(context.entry).map(entry =>\n isString(entry) ? entry : entry.file\n )\n ).flat(),\n external: (source: string) => {\n if (\n context.config.resolve.external &&\n toArray(context.config.resolve.external).includes(source)\n ) {\n return true;\n }\n\n if (\n context.config.resolve.noExternal &&\n toArray(context.config.resolve.noExternal).includes(source)\n ) {\n return false;\n }\n\n if (context.builtins.includes(source)) {\n return context.config.projectType !== \"application\";\n }\n\n return !context.config.resolve.skipNodeModulesBundle;\n },\n plugins: [\n typescriptPlugin({\n check: false,\n tsconfig: context.tsconfig.tsconfigFilePath\n }),\n context.config.define &&\n Object.keys(context.config.define).length > 0 &&\n replace({\n sourceMap: context.config.mode === \"development\",\n preventAssignment: true,\n ...(context.config.define ?? {})\n }),\n context.config.inject &&\n Object.keys(context.config.inject).length > 0 &&\n inject({\n sourceMap: context.config.mode === \"development\",\n ...context.config.inject\n }),\n alias({\n entries: Object.entries(context.alias).reduce(\n (ret, [id, path]) => {\n if (!ret.find(e => e.find === id)) {\n ret.push({\n find: id,\n replacement: path\n });\n } else {\n context.warn(\n `Duplicate alias entry for '${id}' detected. The first entry will be used.`\n );\n }\n\n return ret;\n },\n [] as { find: string; replacement: string }[]\n )\n }),\n (context.config as BabelPluginResolvedConfig).babel &&\n getBabelInputPlugin(\n defu((context.config as BabelPluginResolvedConfig).babel, {\n caller: {\n name: \"powerlines\",\n supportsStaticESM: true\n },\n cwd: context.config.root,\n babelrc: false,\n extensions: [\".js\", \".jsx\", \".ts\", \".tsx\"],\n babelHelpers: \"bundled\",\n skipPreflightCheck: true,\n exclude: /node_modules/\n }) as RollupBabelInputPluginOptions\n ),\n resolve({\n moduleDirectories: [\"node_modules\"],\n preferBuiltins: true\n }),\n dtsBundlePlugin\n ].filter(Boolean) as Plugin[]\n },\n (context.config as RollupPluginResolvedConfig)?.rollup\n ? (context.config as RollupPluginResolvedConfig)?.rollup\n : {},\n {\n cache: !context.config.skipCache\n ? joinPaths(context.cachePath, \"rollup\")\n : false,\n logLevel: context.config.logLevel,\n output: [\n {\n dir: context.config.output.buildPath,\n format: \"es\",\n entryFileNames: \"[name].js\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n },\n {\n dir: context.config.output.buildPath,\n format: \"cjs\",\n entryFileNames: \"[name].cjs\",\n preserveModules: true,\n sourcemap: context.config.mode === \"development\"\n }\n ]\n }\n ) as RollupOptions;\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,MAAaA,kBAA0B;CACrC,MAAM;CACN,MAAM,eAAe,OAAO,QAAQ;AAClC,OAAK,MAAM,GAAG,SAAS,OAAO,QAAQ,OAAO,EAAE;AAC7C,OACE,KAAK,SAAS,WACd,CAAC,KAAK,WACN,KAAK,kBAAkB,KAEvB;GAIF,MAAM,cAAc,KA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AC,IAAI,UAAU;AACnB,QAAI,CAAC,IAAI,MAAK,MAAK,EAAE,SAAS,GAAG,CAC/B,KAAI,KAAK;KACP,MAAM;KACN,aAAa;KACd,CAAC;QAEF,SAAQ,KACN,8BAA8B,GAAG,2CAClC;AAGH,WAAO;MAET,EAAE,CACH,EACF,CAAC;GACD,QAAQ,OAAqC,SAC5C,oBACE,KAAM,QAAQ,OAAqC,OAAO;IACxD,QAAQ;KACN,MAAM;KACN,mBAAmB;KACpB;IACD,KAAK,QAAQ,OAAO;IACpB,SAAS;IACT,YAAY;KAAC;KAAO;KAAQ;KAAO;KAAO;IAC1C,cAAc;IACd,oBAAoB;IACpB,SAAS;IACV,CAAC,CACH;GACH,QAAQ;IACN,mBAAmB,CAAC,eAAe;IACnC,gBAAgB;IACjB,CAAC;GACF;GACD,CAAC,OAAO,QAAQ;EAClB,EACA,QAAQ,QAAuC,SAC3C,QAAQ,QAAuC,SAChD,EAAE,EACN;EACE,OAAO,CAAC,QAAQ,OAAO,YACnB,UAAU,QAAQ,WAAW,SAAS,GACtC;EACJ,UAAU,QAAQ,OAAO;EACzB,QAAQ,CACN;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,gBAAgB;GAChB,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,EACD;GACE,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,gBAAgB;GAChB,iBAAiB;GACjB,WAAW,QAAQ,OAAO,SAAS;GACpC,CACF;EACF,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VitePluginResolvedConfig } from "./plugin.mjs";
|
|
2
|
-
import { UNSAFE_PluginContext } from "
|
|
2
|
+
import { UNSAFE_PluginContext } from "../core/src/types/_internal.mjs";
|
|
3
3
|
|
|
4
|
-
//#region src/types/
|
|
4
|
+
//#region src/types/_internal.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal fields and methods for internal Vite plugin contexts
|
|
@@ -12,4 +12,4 @@ type UNSAFE_VitePluginContext<TResolvedConfig extends VitePluginResolvedConfig =
|
|
|
12
12
|
declare type __ΩUNSAFE_VitePluginContext = any[];
|
|
13
13
|
//#endregion
|
|
14
14
|
export { UNSAFE_VitePluginContext, __ΩUNSAFE_VitePluginContext };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=_internal.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_internal.d.mts","names":[],"sources":["../../src/types/_internal.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0BA;;;AAEyB,KAFb,wBAEa,CAAA,wBADC,wBACD,GAD4B,wBAC5B,CAAA,GAArB,oBAAqB,CAAA,eAAA,CAAA;AAArB,2CAAA,GAAA,EAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DepOptimizationOptions, UserConfig } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/types/build.d.ts
|
|
4
|
+
type ViteOptions = Omit<UserConfig, "entry" | "entryPoints" | "tsconfig" | "tsconfigRaw" | "environments" | "output" | "platform" | "define" | "external"> & {
|
|
5
|
+
/**
|
|
6
|
+
* Optimize deps config
|
|
7
|
+
*/
|
|
8
|
+
optimizeDeps?: Omit<DepOptimizationOptions, "extensions">;
|
|
9
|
+
};
|
|
10
|
+
declare type __ΩViteOptions = any[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ViteOptions, __ΩViteOptions };
|
|
13
|
+
//# sourceMappingURL=build.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.mts","names":[],"sources":["../../src/types/build.ts"],"sourcesContent":[],"mappings":";;;KAoBY,WAAA,GAAc,KACxB;;AADF;;EAA0B,YAAA,CAAA,EAeT,IAfS,CAeJ,sBAfI,EAAA,YAAA,CAAA;CAeJ;AAAL,8BAAA,GAAA,EAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ViteOptions, __ΩViteOptions } from "./build.mjs";
|
|
2
|
+
import { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, VitePluginUserConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig, __ΩVitePluginUserConfig } from "./plugin.mjs";
|
|
3
|
+
export { ViteOptions, VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, VitePluginUserConfig, __ΩViteOptions, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig, __ΩVitePluginUserConfig };
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConfigEnv } from "
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { PluginContext } from "../core/src/types/context.mjs";
|
|
2
|
+
import { ConfigEnv, ResolvedConfig, UserConfig } from "../core/src/types/config.mjs";
|
|
3
|
+
import "../core/src/types/index.mjs";
|
|
4
|
+
import { ViteOptions } from "./build.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/types/plugin.d.ts
|
|
7
|
-
type VitePluginOptions = Partial<
|
|
8
|
-
|
|
7
|
+
type VitePluginOptions = Partial<ViteOptions>;
|
|
8
|
+
interface VitePluginUserConfig extends UserConfig {
|
|
9
|
+
vite?: VitePluginOptions;
|
|
10
|
+
}
|
|
11
|
+
interface VitePluginResolvedConfig extends ResolvedConfig {
|
|
12
|
+
vite: ViteOptions;
|
|
13
|
+
}
|
|
9
14
|
type VitePluginContext<TResolvedConfig extends VitePluginResolvedConfig = VitePluginResolvedConfig> = PluginContext<TResolvedConfig> & {
|
|
10
15
|
dev: boolean;
|
|
11
16
|
configEnv: ConfigEnv;
|
|
12
17
|
};
|
|
13
18
|
declare type __ΩVitePluginOptions = any[];
|
|
19
|
+
declare type __ΩVitePluginUserConfig = any[];
|
|
14
20
|
declare type __ΩVitePluginResolvedConfig = any[];
|
|
15
21
|
declare type __ΩVitePluginContext = any[];
|
|
16
22
|
//#endregion
|
|
17
|
-
export { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig };
|
|
23
|
+
export { VitePluginContext, VitePluginOptions, VitePluginResolvedConfig, VitePluginUserConfig, __ΩVitePluginContext, __ΩVitePluginOptions, __ΩVitePluginResolvedConfig, __ΩVitePluginUserConfig };
|
|
18
24
|
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;KA0BY,iBAAA,GAAoB,QAAQ;UAEvB,oBAAA,SAA6B;SACrC;;AAHG,UAMK,wBAAA,SAAiC,cANX,CAAA;EAEtB,IAAA,EAKT,WALS;AAIjB;AAIY,KAAA,iBAAiB,CAAA,wBACH,wBADG,GACwB,wBADxB,CAAA,GAEzB,aAFyB,CAEX,eAFW,CAAA,GAAA;EACH,GAAA,EAAA,OAAA;EAA2B,SAAA,EAGxC,SAHwC;CACnC;AAAd,oCAAA,GAAA,EAAA;AAES,uCAAA,GAAA,EAAA;AAAS,2CAAA,GAAA,EAAA"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-vite",
|
|
3
|
-
"version": "0.14.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.14.293",
|
|
4
|
+
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
|
+
"keywords": ["vite", "powerlines", "storm-software", "powerlines-plugin"],
|
|
7
|
+
"homepage": "https://stormsoftware.com",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://stormsoftware.com/support",
|
|
10
|
+
"email": "support@stormsoftware.com"
|
|
11
|
+
},
|
|
6
12
|
"repository": {
|
|
7
13
|
"type": "github",
|
|
8
14
|
"url": "https://github.com/storm-software/powerlines.git",
|
|
9
15
|
"directory": "packages/plugin-vite"
|
|
10
16
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"url": "https://
|
|
14
|
-
"email": "support@stormsoftware.com"
|
|
17
|
+
"funding": {
|
|
18
|
+
"type": "github",
|
|
19
|
+
"url": "https://github.com/sponsors/storm-software"
|
|
15
20
|
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
16
22
|
"author": {
|
|
17
23
|
"name": "Storm Software",
|
|
18
24
|
"email": "contact@stormsoftware.com",
|
|
@@ -32,115 +38,32 @@
|
|
|
32
38
|
"url": "https://stormsoftware.com"
|
|
33
39
|
}
|
|
34
40
|
],
|
|
35
|
-
"
|
|
36
|
-
"type": "github",
|
|
37
|
-
"url": "https://github.com/sponsors/storm-software"
|
|
38
|
-
},
|
|
39
|
-
"license": "Apache-2.0",
|
|
40
|
-
"private": false,
|
|
41
|
-
"main": "./dist/index.cjs",
|
|
42
|
-
"module": "./dist/index.mjs",
|
|
41
|
+
"type": "module",
|
|
43
42
|
"exports": {
|
|
44
|
-
".":
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"default": {
|
|
54
|
-
"types": "./dist/index.d.mts",
|
|
55
|
-
"default": "./dist/index.mjs"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"./helpers": {
|
|
59
|
-
"require": {
|
|
60
|
-
"types": "./dist/helpers/index.d.cts",
|
|
61
|
-
"default": "./dist/helpers/index.cjs"
|
|
62
|
-
},
|
|
63
|
-
"import": {
|
|
64
|
-
"types": "./dist/helpers/index.d.mts",
|
|
65
|
-
"default": "./dist/helpers/index.mjs"
|
|
66
|
-
},
|
|
67
|
-
"default": {
|
|
68
|
-
"types": "./dist/helpers/index.d.mts",
|
|
69
|
-
"default": "./dist/helpers/index.mjs"
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
"./helpers/unplugin": {
|
|
73
|
-
"require": {
|
|
74
|
-
"types": "./dist/helpers/unplugin.d.cts",
|
|
75
|
-
"default": "./dist/helpers/unplugin.cjs"
|
|
76
|
-
},
|
|
77
|
-
"import": {
|
|
78
|
-
"types": "./dist/helpers/unplugin.d.mts",
|
|
79
|
-
"default": "./dist/helpers/unplugin.mjs"
|
|
80
|
-
},
|
|
81
|
-
"default": {
|
|
82
|
-
"types": "./dist/helpers/unplugin.d.mts",
|
|
83
|
-
"default": "./dist/helpers/unplugin.mjs"
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
"./package.json": "./package.json",
|
|
87
|
-
"./types": {
|
|
88
|
-
"require": {
|
|
89
|
-
"types": "./dist/types/index.d.cts",
|
|
90
|
-
"default": "./dist/types/index.cjs"
|
|
91
|
-
},
|
|
92
|
-
"import": {
|
|
93
|
-
"types": "./dist/types/index.d.mts",
|
|
94
|
-
"default": "./dist/types/index.mjs"
|
|
95
|
-
},
|
|
96
|
-
"default": {
|
|
97
|
-
"types": "./dist/types/index.d.mts",
|
|
98
|
-
"default": "./dist/types/index.mjs"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
"./types/internal": {
|
|
102
|
-
"require": {
|
|
103
|
-
"types": "./dist/types/internal.d.cts",
|
|
104
|
-
"default": "./dist/types/internal.cjs"
|
|
105
|
-
},
|
|
106
|
-
"import": {
|
|
107
|
-
"types": "./dist/types/internal.d.mts",
|
|
108
|
-
"default": "./dist/types/internal.mjs"
|
|
109
|
-
},
|
|
110
|
-
"default": {
|
|
111
|
-
"types": "./dist/types/internal.d.mts",
|
|
112
|
-
"default": "./dist/types/internal.mjs"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"./types/plugin": {
|
|
116
|
-
"require": {
|
|
117
|
-
"types": "./dist/types/plugin.d.cts",
|
|
118
|
-
"default": "./dist/types/plugin.cjs"
|
|
119
|
-
},
|
|
120
|
-
"import": {
|
|
121
|
-
"types": "./dist/types/plugin.d.mts",
|
|
122
|
-
"default": "./dist/types/plugin.mjs"
|
|
123
|
-
},
|
|
124
|
-
"default": {
|
|
125
|
-
"types": "./dist/types/plugin.d.mts",
|
|
126
|
-
"default": "./dist/types/plugin.mjs"
|
|
127
|
-
}
|
|
128
|
-
}
|
|
43
|
+
".": "./dist/index.mjs",
|
|
44
|
+
"./helpers": "./dist/helpers/index.mjs",
|
|
45
|
+
"./helpers/resolve-options": "./dist/helpers/resolve-options.mjs",
|
|
46
|
+
"./helpers/unplugin": "./dist/helpers/unplugin.mjs",
|
|
47
|
+
"./types": "./dist/types/index.mjs",
|
|
48
|
+
"./types/_internal": "./dist/types/_internal.mjs",
|
|
49
|
+
"./types/build": "./dist/types/build.mjs",
|
|
50
|
+
"./types/plugin": "./dist/types/plugin.mjs",
|
|
51
|
+
"./*": "./*"
|
|
129
52
|
},
|
|
53
|
+
"main": "./dist/index.mjs",
|
|
54
|
+
"module": "./dist/index.mjs",
|
|
55
|
+
"types": "./dist/index.d.mts",
|
|
130
56
|
"typings": "dist/index.d.mts",
|
|
131
57
|
"files": ["dist/**/*"],
|
|
132
|
-
"keywords": ["vite", "powerlines", "storm-software", "powerlines-plugin"],
|
|
133
58
|
"dependencies": {
|
|
59
|
+
"@powerlines/plugin-rolldown": "^0.7.301",
|
|
60
|
+
"@powerlines/plugin-rollup": "^0.7.301",
|
|
61
|
+
"@powerlines/plugin-esbuild": "^0.13.300",
|
|
134
62
|
"defu": "^6.1.4",
|
|
135
|
-
"powerlines": "^0.38.57",
|
|
136
63
|
"unplugin": "3.0.0-beta.3",
|
|
137
64
|
"vite": "8.0.0-beta.2"
|
|
138
65
|
},
|
|
139
|
-
"devDependencies": {
|
|
140
|
-
"@powerlines/plugin-plugin": "^0.12.241",
|
|
141
|
-
"@types/node": "^25.3.1"
|
|
142
|
-
},
|
|
66
|
+
"devDependencies": { "@types/node": "^25.3.2" },
|
|
143
67
|
"publishConfig": { "access": "public" },
|
|
144
|
-
"
|
|
145
|
-
"gitHead": "eb3dbd19bd153aa5a988bce09a1cf05d985cb04b"
|
|
68
|
+
"gitHead": "0dcb16f054b8a69915b074578e6d4dfa3ecc1529"
|
|
146
69
|
}
|