@powerlines/plugin-unbuild 0.5.126 → 0.5.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/index.cjs +32 -1
- package/dist/index.mjs +29 -1
- package/dist/powerlines/src/lib/build/rollup.cjs +134 -1
- package/dist/powerlines/src/lib/build/rollup.mjs +127 -1
- package/dist/powerlines/src/lib/build/unbuild.cjs +135 -1
- package/dist/powerlines/src/lib/build/unbuild.mjs +132 -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/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/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +9 -9
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_unbuild = require('./powerlines/src/lib/build/unbuild.cjs');
|
|
4
|
+
let __storm_software_unbuild = require("@storm-software/unbuild");
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* A Powerlines plugin to build projects using Unbuild.
|
|
9
|
+
*/
|
|
10
|
+
const plugin = (options = {}) => {
|
|
11
|
+
return {
|
|
12
|
+
name: "unbuild",
|
|
13
|
+
config() {
|
|
14
|
+
return {
|
|
15
|
+
output: { format: ["esm"] },
|
|
16
|
+
build: {
|
|
17
|
+
...require_unbuild.DEFAULT_UNBUILD_CONFIG,
|
|
18
|
+
...options,
|
|
19
|
+
variant: "unbuild"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
async build() {
|
|
24
|
+
await (0, __storm_software_unbuild.build)(require_unbuild.extractUnbuildConfig(this));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
var src_default = plugin;
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.default = src_default;
|
|
32
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import{DEFAULT_UNBUILD_CONFIG
|
|
1
|
+
import { DEFAULT_UNBUILD_CONFIG, extractUnbuildConfig } from "./powerlines/src/lib/build/unbuild.mjs";
|
|
2
|
+
import { build } from "@storm-software/unbuild";
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* A Powerlines plugin to build projects using Unbuild.
|
|
7
|
+
*/
|
|
8
|
+
const plugin = (options = {}) => {
|
|
9
|
+
return {
|
|
10
|
+
name: "unbuild",
|
|
11
|
+
config() {
|
|
12
|
+
return {
|
|
13
|
+
output: { format: ["esm"] },
|
|
14
|
+
build: {
|
|
15
|
+
...DEFAULT_UNBUILD_CONFIG,
|
|
16
|
+
...options,
|
|
17
|
+
variant: "unbuild"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
async build() {
|
|
22
|
+
await build(extractUnbuildConfig(this));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var src_default = plugin;
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { src_default as default, plugin };
|
|
@@ -1 +1,134 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
3
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
4
|
+
let defu = require("defu");
|
|
5
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
6
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
7
|
+
let __rollup_plugin_alias = require("@rollup/plugin-alias");
|
|
8
|
+
__rollup_plugin_alias = require_rolldown_runtime.__toESM(__rollup_plugin_alias);
|
|
9
|
+
let __rollup_plugin_babel = require("@rollup/plugin-babel");
|
|
10
|
+
let __rollup_plugin_inject = require("@rollup/plugin-inject");
|
|
11
|
+
__rollup_plugin_inject = require_rolldown_runtime.__toESM(__rollup_plugin_inject);
|
|
12
|
+
let __rollup_plugin_node_resolve = require("@rollup/plugin-node-resolve");
|
|
13
|
+
__rollup_plugin_node_resolve = require_rolldown_runtime.__toESM(__rollup_plugin_node_resolve);
|
|
14
|
+
let __rollup_plugin_replace = require("@rollup/plugin-replace");
|
|
15
|
+
__rollup_plugin_replace = require_rolldown_runtime.__toESM(__rollup_plugin_replace);
|
|
16
|
+
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
17
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
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: context.builtins.reduce((ret, id) => {
|
|
76
|
+
if (!ret.find((e) => e.find === id)) {
|
|
77
|
+
const path = context.fs.ids[id];
|
|
78
|
+
if (path) ret.push({
|
|
79
|
+
find: id,
|
|
80
|
+
replacement: path
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return ret;
|
|
84
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
85
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
86
|
+
find: id,
|
|
87
|
+
replacement: path
|
|
88
|
+
});
|
|
89
|
+
return ret;
|
|
90
|
+
}, []) : []) }),
|
|
91
|
+
(0, __rollup_plugin_babel.getBabelInputPlugin)((0, defu.default)(context.config.transform.babel, {
|
|
92
|
+
caller: {
|
|
93
|
+
name: "powerlines",
|
|
94
|
+
supportsStaticESM: true
|
|
95
|
+
},
|
|
96
|
+
cwd: context.config.projectRoot,
|
|
97
|
+
babelrc: false,
|
|
98
|
+
extensions: [
|
|
99
|
+
".js",
|
|
100
|
+
".jsx",
|
|
101
|
+
".ts",
|
|
102
|
+
".tsx"
|
|
103
|
+
],
|
|
104
|
+
babelHelpers: "bundled",
|
|
105
|
+
skipPreflightCheck: true,
|
|
106
|
+
exclude: /node_modules/
|
|
107
|
+
})),
|
|
108
|
+
(0, __rollup_plugin_node_resolve.default)({
|
|
109
|
+
moduleDirectories: ["node_modules"],
|
|
110
|
+
preferBuiltins: true
|
|
111
|
+
}),
|
|
112
|
+
dtsBundlePlugin
|
|
113
|
+
].filter(Boolean)
|
|
114
|
+
}, 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 : {}, {
|
|
115
|
+
cache: !context.config.skipCache ? (0, __stryke_path_join_paths.joinPaths)(context.cachePath, "rollup") : false,
|
|
116
|
+
logLevel: context.config.logLevel,
|
|
117
|
+
output: [{
|
|
118
|
+
dir: context.config.output.buildPath,
|
|
119
|
+
format: "es",
|
|
120
|
+
entryFileNames: "[name].js",
|
|
121
|
+
preserveModules: true,
|
|
122
|
+
sourcemap: context.config.mode === "development"
|
|
123
|
+
}, {
|
|
124
|
+
dir: context.config.output.buildPath,
|
|
125
|
+
format: "cjs",
|
|
126
|
+
entryFileNames: "[name].cjs",
|
|
127
|
+
preserveModules: true,
|
|
128
|
+
sourcemap: context.config.mode === "development"
|
|
129
|
+
}]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
exports.extractRollupConfig = extractRollupConfig;
|
|
@@ -1 +1,127 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { omit } from "@stryke/helpers/omit";
|
|
2
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
3
|
+
import defu from "defu";
|
|
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 { toArray } from "@stryke/convert/to-array";
|
|
11
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
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({
|
|
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: context.builtins.reduce((ret, id) => {
|
|
69
|
+
if (!ret.find((e) => e.find === id)) {
|
|
70
|
+
const path = context.fs.ids[id];
|
|
71
|
+
if (path) ret.push({
|
|
72
|
+
find: id,
|
|
73
|
+
replacement: path
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return ret;
|
|
77
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
|
|
78
|
+
if (!ret.find((e) => e.find === id)) ret.push({
|
|
79
|
+
find: id,
|
|
80
|
+
replacement: path
|
|
81
|
+
});
|
|
82
|
+
return ret;
|
|
83
|
+
}, []) : []) }),
|
|
84
|
+
getBabelInputPlugin(defu(context.config.transform.babel, {
|
|
85
|
+
caller: {
|
|
86
|
+
name: "powerlines",
|
|
87
|
+
supportsStaticESM: true
|
|
88
|
+
},
|
|
89
|
+
cwd: context.config.projectRoot,
|
|
90
|
+
babelrc: false,
|
|
91
|
+
extensions: [
|
|
92
|
+
".js",
|
|
93
|
+
".jsx",
|
|
94
|
+
".ts",
|
|
95
|
+
".tsx"
|
|
96
|
+
],
|
|
97
|
+
babelHelpers: "bundled",
|
|
98
|
+
skipPreflightCheck: true,
|
|
99
|
+
exclude: /node_modules/
|
|
100
|
+
})),
|
|
101
|
+
resolve({
|
|
102
|
+
moduleDirectories: ["node_modules"],
|
|
103
|
+
preferBuiltins: true
|
|
104
|
+
}),
|
|
105
|
+
dtsBundlePlugin
|
|
106
|
+
].filter(Boolean)
|
|
107
|
+
}, 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 : {}, {
|
|
108
|
+
cache: !context.config.skipCache ? joinPaths(context.cachePath, "rollup") : false,
|
|
109
|
+
logLevel: context.config.logLevel,
|
|
110
|
+
output: [{
|
|
111
|
+
dir: context.config.output.buildPath,
|
|
112
|
+
format: "es",
|
|
113
|
+
entryFileNames: "[name].js",
|
|
114
|
+
preserveModules: true,
|
|
115
|
+
sourcemap: context.config.mode === "development"
|
|
116
|
+
}, {
|
|
117
|
+
dir: context.config.output.buildPath,
|
|
118
|
+
format: "cjs",
|
|
119
|
+
entryFileNames: "[name].cjs",
|
|
120
|
+
preserveModules: true,
|
|
121
|
+
sourcemap: context.config.mode === "development"
|
|
122
|
+
}]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { extractRollupConfig };
|
|
@@ -1 +1,135 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_source_file = require('../utilities/source-file.cjs');
|
|
3
|
+
const require_rollup = require('./rollup.cjs');
|
|
4
|
+
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
5
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
6
|
+
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
7
|
+
let defu = require("defu");
|
|
8
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
9
|
+
let esbuild = require("esbuild");
|
|
10
|
+
|
|
11
|
+
//#region ../powerlines/src/lib/build/unbuild.ts
|
|
12
|
+
const DEFAULT_UNBUILD_CONFIG = {
|
|
13
|
+
dts: true,
|
|
14
|
+
clean: false,
|
|
15
|
+
includeSrc: false,
|
|
16
|
+
treeShaking: true,
|
|
17
|
+
splitting: true,
|
|
18
|
+
stub: false,
|
|
19
|
+
watchOptions: {},
|
|
20
|
+
outputPath: "dist",
|
|
21
|
+
generatePackageJson: true,
|
|
22
|
+
banner: " ",
|
|
23
|
+
rollup: {
|
|
24
|
+
dts: {},
|
|
25
|
+
emitCJS: true,
|
|
26
|
+
replace: {},
|
|
27
|
+
resolve: {},
|
|
28
|
+
json: {},
|
|
29
|
+
esbuild: { target: "es2020" },
|
|
30
|
+
commonjs: {},
|
|
31
|
+
alias: {}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const unbuildLoader = (context) => {
|
|
35
|
+
return async (input, { options }) => {
|
|
36
|
+
if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
|
|
37
|
+
const output = [];
|
|
38
|
+
let contents = await input.getContents();
|
|
39
|
+
if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
|
|
40
|
+
const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
|
|
41
|
+
output.push({
|
|
42
|
+
contents,
|
|
43
|
+
srcPath: input.srcPath,
|
|
44
|
+
path: input.path,
|
|
45
|
+
extension: extension$1,
|
|
46
|
+
declaration: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
let transformed = contents;
|
|
50
|
+
let result = await context.$$internal.callHook("transform", {
|
|
51
|
+
sequential: true,
|
|
52
|
+
order: "pre"
|
|
53
|
+
}, transformed, input.path);
|
|
54
|
+
if (result) transformed = result;
|
|
55
|
+
result = await context.$$internal.callHook("transform", {
|
|
56
|
+
sequential: true,
|
|
57
|
+
order: "normal"
|
|
58
|
+
}, require_source_file.getString(transformed), input.path);
|
|
59
|
+
if (result) transformed = result;
|
|
60
|
+
result = await context.$$internal.callHook("transform", {
|
|
61
|
+
sequential: true,
|
|
62
|
+
order: "post"
|
|
63
|
+
}, require_source_file.getString(transformed), input.path);
|
|
64
|
+
if (result) transformed = result;
|
|
65
|
+
if ([
|
|
66
|
+
".ts",
|
|
67
|
+
".mts",
|
|
68
|
+
".cts"
|
|
69
|
+
].includes(input.extension)) contents = await (0, esbuild.transform)(require_source_file.getString(transformed), {
|
|
70
|
+
...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
|
|
71
|
+
loader: "ts"
|
|
72
|
+
}).then((r) => r.code);
|
|
73
|
+
else if ([".tsx", ".jsx"].includes(input.extension)) contents = await (0, esbuild.transform)(require_source_file.getString(transformed), {
|
|
74
|
+
loader: input.extension === ".tsx" ? "tsx" : "jsx",
|
|
75
|
+
...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
|
|
76
|
+
}).then((r) => r.code);
|
|
77
|
+
const isCjs = options.format === "cjs";
|
|
78
|
+
if (isCjs) contents = context.resolver.transform({
|
|
79
|
+
source: contents,
|
|
80
|
+
retainLines: false
|
|
81
|
+
}).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
|
|
82
|
+
let extension = isCjs ? ".js" : ".mjs";
|
|
83
|
+
if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
|
|
84
|
+
output.push({
|
|
85
|
+
contents,
|
|
86
|
+
path: input.path,
|
|
87
|
+
extension
|
|
88
|
+
});
|
|
89
|
+
return output;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Extracts the unbuild configuration from the context.
|
|
94
|
+
*
|
|
95
|
+
* @param context - The build context.
|
|
96
|
+
* @returns The resolved unbuild configuration.
|
|
97
|
+
*/
|
|
98
|
+
function extractUnbuildConfig(context) {
|
|
99
|
+
return (0, defu.default)({ alias: context.builtins.reduce((ret, id) => {
|
|
100
|
+
if (!ret[id]) {
|
|
101
|
+
const path = context.fs.ids[id];
|
|
102
|
+
if (path) ret[id] = path;
|
|
103
|
+
}
|
|
104
|
+
return ret;
|
|
105
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
106
|
+
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
107
|
+
return ret;
|
|
108
|
+
}, {}) : context.config.build.alias : {}) }, context.config.build.variant === "unbuild" ? context.config.build.override : {}, context.config.build.variant === "unbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, ["override", "variant"]) : {}, {
|
|
109
|
+
projectName: context.config.name,
|
|
110
|
+
name: context.config.name,
|
|
111
|
+
orgName: (0, __stryke_type_checks_is_object.isObject)(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
|
|
112
|
+
sourceRoot: context.config.sourceRoot,
|
|
113
|
+
projectRoot: context.config.projectRoot,
|
|
114
|
+
outputPath: context.config.output.buildPath || "dist",
|
|
115
|
+
platform: context.config.build.platform,
|
|
116
|
+
external: context.builtins.reduce((ret, id) => {
|
|
117
|
+
if (!ret.includes(id)) ret.push(id);
|
|
118
|
+
return ret;
|
|
119
|
+
}, context.config.build.external ?? []),
|
|
120
|
+
loaders: [unbuildLoader(context)],
|
|
121
|
+
jiti: {
|
|
122
|
+
interopDefault: true,
|
|
123
|
+
fsCache: (0, __stryke_path_join_paths.joinPaths)(context.envPaths.cache, "jiti"),
|
|
124
|
+
moduleCache: true
|
|
125
|
+
},
|
|
126
|
+
rollup: require_rollup.extractRollupConfig(context),
|
|
127
|
+
debug: context.config.mode === "development",
|
|
128
|
+
minify: context.config.mode !== "development",
|
|
129
|
+
sourcemap: context.config.mode === "development"
|
|
130
|
+
}, DEFAULT_UNBUILD_CONFIG);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
exports.DEFAULT_UNBUILD_CONFIG = DEFAULT_UNBUILD_CONFIG;
|
|
135
|
+
exports.extractUnbuildConfig = extractUnbuildConfig;
|
|
@@ -1 +1,132 @@
|
|
|
1
|
-
import{getString
|
|
1
|
+
import { getString } from "../utilities/source-file.mjs";
|
|
2
|
+
import { extractRollupConfig } from "./rollup.mjs";
|
|
3
|
+
import { omit } from "@stryke/helpers/omit";
|
|
4
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
+
import { isObject } from "@stryke/type-checks/is-object";
|
|
6
|
+
import defu from "defu";
|
|
7
|
+
import { transform } from "esbuild";
|
|
8
|
+
|
|
9
|
+
//#region ../powerlines/src/lib/build/unbuild.ts
|
|
10
|
+
const DEFAULT_UNBUILD_CONFIG = {
|
|
11
|
+
dts: true,
|
|
12
|
+
clean: false,
|
|
13
|
+
includeSrc: false,
|
|
14
|
+
treeShaking: true,
|
|
15
|
+
splitting: true,
|
|
16
|
+
stub: false,
|
|
17
|
+
watchOptions: {},
|
|
18
|
+
outputPath: "dist",
|
|
19
|
+
generatePackageJson: true,
|
|
20
|
+
banner: " ",
|
|
21
|
+
rollup: {
|
|
22
|
+
dts: {},
|
|
23
|
+
emitCJS: true,
|
|
24
|
+
replace: {},
|
|
25
|
+
resolve: {},
|
|
26
|
+
json: {},
|
|
27
|
+
esbuild: { target: "es2020" },
|
|
28
|
+
commonjs: {},
|
|
29
|
+
alias: {}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const unbuildLoader = (context) => {
|
|
33
|
+
return async (input, { options }) => {
|
|
34
|
+
if (!/\.(?:c|m)?[jt]sx?$/.test(input.path) || /\.d\.[cm]?ts$/.test(input.path)) return;
|
|
35
|
+
const output = [];
|
|
36
|
+
let contents = await input.getContents();
|
|
37
|
+
if (options.declaration && !input.srcPath?.match(/\.d\.[cm]?ts$/)) {
|
|
38
|
+
const extension$1 = `.d.${input.srcPath?.match(/(?<=\.)(?:c|m)(?=[jt]s$)/)?.[0] || ""}ts`;
|
|
39
|
+
output.push({
|
|
40
|
+
contents,
|
|
41
|
+
srcPath: input.srcPath,
|
|
42
|
+
path: input.path,
|
|
43
|
+
extension: extension$1,
|
|
44
|
+
declaration: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
let transformed = contents;
|
|
48
|
+
let result = await context.$$internal.callHook("transform", {
|
|
49
|
+
sequential: true,
|
|
50
|
+
order: "pre"
|
|
51
|
+
}, transformed, input.path);
|
|
52
|
+
if (result) transformed = result;
|
|
53
|
+
result = await context.$$internal.callHook("transform", {
|
|
54
|
+
sequential: true,
|
|
55
|
+
order: "normal"
|
|
56
|
+
}, getString(transformed), input.path);
|
|
57
|
+
if (result) transformed = result;
|
|
58
|
+
result = await context.$$internal.callHook("transform", {
|
|
59
|
+
sequential: true,
|
|
60
|
+
order: "post"
|
|
61
|
+
}, getString(transformed), input.path);
|
|
62
|
+
if (result) transformed = result;
|
|
63
|
+
if ([
|
|
64
|
+
".ts",
|
|
65
|
+
".mts",
|
|
66
|
+
".cts"
|
|
67
|
+
].includes(input.extension)) contents = await transform(getString(transformed), {
|
|
68
|
+
...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths")),
|
|
69
|
+
loader: "ts"
|
|
70
|
+
}).then((r) => r.code);
|
|
71
|
+
else if ([".tsx", ".jsx"].includes(input.extension)) contents = await transform(getString(transformed), {
|
|
72
|
+
loader: input.extension === ".tsx" ? "tsx" : "jsx",
|
|
73
|
+
...Object.fromEntries(Object.entries(options.esbuild ?? {}).filter(([key]) => key !== "absPaths"))
|
|
74
|
+
}).then((r) => r.code);
|
|
75
|
+
const isCjs = options.format === "cjs";
|
|
76
|
+
if (isCjs) contents = context.resolver.transform({
|
|
77
|
+
source: contents,
|
|
78
|
+
retainLines: false
|
|
79
|
+
}).replace(/^exports.default = /gm, "module.exports = ").replace(/^var _default = exports.default = /gm, "module.exports = ").replace("module.exports = void 0;", "");
|
|
80
|
+
let extension = isCjs ? ".js" : ".mjs";
|
|
81
|
+
if (options.ext) extension = options.ext.startsWith(".") ? options.ext : `.${options.ext}`;
|
|
82
|
+
output.push({
|
|
83
|
+
contents,
|
|
84
|
+
path: input.path,
|
|
85
|
+
extension
|
|
86
|
+
});
|
|
87
|
+
return output;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Extracts the unbuild configuration from the context.
|
|
92
|
+
*
|
|
93
|
+
* @param context - The build context.
|
|
94
|
+
* @returns The resolved unbuild configuration.
|
|
95
|
+
*/
|
|
96
|
+
function extractUnbuildConfig(context) {
|
|
97
|
+
return defu({ alias: context.builtins.reduce((ret, id) => {
|
|
98
|
+
if (!ret[id]) {
|
|
99
|
+
const path = context.fs.ids[id];
|
|
100
|
+
if (path) ret[id] = path;
|
|
101
|
+
}
|
|
102
|
+
return ret;
|
|
103
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
104
|
+
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
105
|
+
return ret;
|
|
106
|
+
}, {}) : context.config.build.alias : {}) }, context.config.build.variant === "unbuild" ? context.config.build.override : {}, context.config.build.variant === "unbuild" ? omit(context.config.build, ["override", "variant"]) : {}, {
|
|
107
|
+
projectName: context.config.name,
|
|
108
|
+
name: context.config.name,
|
|
109
|
+
orgName: isObject(context.workspaceConfig.organization) ? context.workspaceConfig.organization.name : context.workspaceConfig.organization,
|
|
110
|
+
sourceRoot: context.config.sourceRoot,
|
|
111
|
+
projectRoot: context.config.projectRoot,
|
|
112
|
+
outputPath: context.config.output.buildPath || "dist",
|
|
113
|
+
platform: context.config.build.platform,
|
|
114
|
+
external: context.builtins.reduce((ret, id) => {
|
|
115
|
+
if (!ret.includes(id)) ret.push(id);
|
|
116
|
+
return ret;
|
|
117
|
+
}, context.config.build.external ?? []),
|
|
118
|
+
loaders: [unbuildLoader(context)],
|
|
119
|
+
jiti: {
|
|
120
|
+
interopDefault: true,
|
|
121
|
+
fsCache: joinPaths(context.envPaths.cache, "jiti"),
|
|
122
|
+
moduleCache: true
|
|
123
|
+
},
|
|
124
|
+
rollup: extractRollupConfig(context),
|
|
125
|
+
debug: context.config.mode === "development",
|
|
126
|
+
minify: context.config.mode !== "development",
|
|
127
|
+
sourcemap: context.config.mode === "development"
|
|
128
|
+
}, DEFAULT_UNBUILD_CONFIG);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
export { DEFAULT_UNBUILD_CONFIG, extractUnbuildConfig };
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
require("@stryke/fs/read-file");
|
|
3
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
4
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
5
|
+
require("magic-string");
|
|
6
|
+
|
|
7
|
+
//#region ../powerlines/src/lib/utilities/source-file.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get the string from the source.
|
|
10
|
+
*
|
|
11
|
+
* @param code - The source string or magic string.
|
|
12
|
+
* @returns The source string.
|
|
13
|
+
*/
|
|
14
|
+
function getString(code) {
|
|
15
|
+
if (!code) return "";
|
|
16
|
+
if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
|
|
17
|
+
if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
|
|
18
|
+
return code.toString();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getString = getString;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
import"@stryke/fs/read-file";
|
|
1
|
+
import "@stryke/fs/read-file";
|
|
2
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
import "magic-string";
|
|
5
|
+
|
|
6
|
+
//#region ../powerlines/src/lib/utilities/source-file.ts
|
|
7
|
+
/**
|
|
8
|
+
* Get the string from the source.
|
|
9
|
+
*
|
|
10
|
+
* @param code - The source string or magic string.
|
|
11
|
+
* @returns The source string.
|
|
12
|
+
*/
|
|
13
|
+
function getString(code) {
|
|
14
|
+
if (!code) return "";
|
|
15
|
+
if (isString(code)) return code;
|
|
16
|
+
if (isSetObject(code) && "code" in code) return code.code;
|
|
17
|
+
return code.toString();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getString };
|
|
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
allowReturnOutsideFunction?: boolean;
|
|
80
80
|
}
|
|
81
|
+
interface EmitOptions extends WriteOptions {
|
|
82
|
+
/**
|
|
83
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
84
|
+
*/
|
|
85
|
+
emitWithBundler?: boolean;
|
|
86
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
87
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Options for emitting entry virtual files
|
|
83
91
|
*/
|
|
84
|
-
type EmitEntryOptions =
|
|
92
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
85
93
|
/**
|
|
86
94
|
* The unresolved Powerlines context.
|
|
87
95
|
*
|
|
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
292
300
|
* The Powerlines builtin virtual files
|
|
293
301
|
*/
|
|
294
302
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
305
|
+
*
|
|
306
|
+
* @param code - The source code of the file
|
|
307
|
+
* @param path - The path to write the file to
|
|
308
|
+
* @param options - Additional options for writing the file
|
|
309
|
+
*/
|
|
310
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
313
|
+
*
|
|
314
|
+
* @param code - The source code of the file
|
|
315
|
+
* @param path - The path to write the file to
|
|
316
|
+
* @param options - Additional options for writing the file
|
|
317
|
+
*/
|
|
318
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
295
319
|
/**
|
|
296
320
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
297
321
|
*
|
|
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
300
324
|
* @param path - An optional path to write the builtin file to
|
|
301
325
|
* @param options - Additional options for writing the builtin file
|
|
302
326
|
*/
|
|
303
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
330
|
+
*
|
|
331
|
+
* @param code - The source code of the builtin file
|
|
332
|
+
* @param id - The unique identifier of the builtin file
|
|
333
|
+
* @param path - An optional path to write the builtin file to
|
|
334
|
+
* @param options - Additional options for writing the builtin file
|
|
335
|
+
*/
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
304
337
|
/**
|
|
305
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
306
339
|
*
|
|
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
342
|
* @param options - Additional options for writing the entry file
|
|
310
343
|
*/
|
|
311
344
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
347
|
+
*
|
|
348
|
+
* @param code - The source code of the entry file
|
|
349
|
+
* @param path - An optional path to write the entry file to
|
|
350
|
+
* @param options - Additional options for writing the entry file
|
|
351
|
+
*/
|
|
352
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
312
353
|
/**
|
|
313
354
|
* A function to update the context fields using a new user configuration options
|
|
314
355
|
*/
|
|
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
80
80
|
*/
|
|
81
81
|
allowReturnOutsideFunction?: boolean;
|
|
82
82
|
}
|
|
83
|
+
interface EmitOptions extends WriteOptions {
|
|
84
|
+
/**
|
|
85
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
86
|
+
*/
|
|
87
|
+
emitWithBundler?: boolean;
|
|
88
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
89
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
90
|
+
}
|
|
83
91
|
/**
|
|
84
92
|
* Options for emitting entry virtual files
|
|
85
93
|
*/
|
|
86
|
-
type EmitEntryOptions =
|
|
94
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
87
95
|
/**
|
|
88
96
|
* The unresolved Powerlines context.
|
|
89
97
|
*
|
|
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
294
302
|
* The Powerlines builtin virtual files
|
|
295
303
|
*/
|
|
296
304
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
307
|
+
*
|
|
308
|
+
* @param code - The source code of the file
|
|
309
|
+
* @param path - The path to write the file to
|
|
310
|
+
* @param options - Additional options for writing the file
|
|
311
|
+
*/
|
|
312
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
315
|
+
*
|
|
316
|
+
* @param code - The source code of the file
|
|
317
|
+
* @param path - The path to write the file to
|
|
318
|
+
* @param options - Additional options for writing the file
|
|
319
|
+
*/
|
|
320
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
297
321
|
/**
|
|
298
322
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
299
323
|
*
|
|
@@ -302,7 +326,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
302
326
|
* @param path - An optional path to write the builtin file to
|
|
303
327
|
* @param options - Additional options for writing the builtin file
|
|
304
328
|
*/
|
|
305
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
329
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
332
|
+
*
|
|
333
|
+
* @param code - The source code of the builtin file
|
|
334
|
+
* @param id - The unique identifier of the builtin file
|
|
335
|
+
* @param path - An optional path to write the builtin file to
|
|
336
|
+
* @param options - Additional options for writing the builtin file
|
|
337
|
+
*/
|
|
338
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
306
339
|
/**
|
|
307
340
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
308
341
|
*
|
|
@@ -311,6 +344,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
311
344
|
* @param options - Additional options for writing the entry file
|
|
312
345
|
*/
|
|
313
346
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
349
|
+
*
|
|
350
|
+
* @param code - The source code of the entry file
|
|
351
|
+
* @param path - An optional path to write the entry file to
|
|
352
|
+
* @param options - Additional options for writing the entry file
|
|
353
|
+
*/
|
|
354
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
314
355
|
/**
|
|
315
356
|
* A function to update the context fields using a new user configuration options
|
|
316
357
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-unbuild",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.128",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to build projects using Unbuild.",
|
|
6
6
|
"repository": {
|
|
@@ -146,20 +146,20 @@
|
|
|
146
146
|
"keywords": ["unbuild", "powerlines", "storm-software", "powerlines-plugin"],
|
|
147
147
|
"dependencies": {
|
|
148
148
|
"@storm-software/unbuild": "^0.57.74",
|
|
149
|
-
"@stryke/fs": "^0.33.
|
|
150
|
-
"@stryke/path": "^0.24.
|
|
151
|
-
"@stryke/type-checks": "^0.5.
|
|
152
|
-
"@stryke/types": "^0.10.
|
|
149
|
+
"@stryke/fs": "^0.33.27",
|
|
150
|
+
"@stryke/path": "^0.24.1",
|
|
151
|
+
"@stryke/type-checks": "^0.5.15",
|
|
152
|
+
"@stryke/types": "^0.10.29",
|
|
153
153
|
"defu": "^6.1.4",
|
|
154
154
|
"jiti": "^2.6.1",
|
|
155
|
-
"powerlines": "^0.36.
|
|
155
|
+
"powerlines": "^0.36.23",
|
|
156
156
|
"unplugin": "3.0.0-beta.3"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@powerlines/nx": "^0.11.
|
|
160
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
159
|
+
"@powerlines/nx": "^0.11.49",
|
|
160
|
+
"@powerlines/plugin-plugin": "^0.12.70",
|
|
161
161
|
"@types/node": "^24.10.4"
|
|
162
162
|
},
|
|
163
163
|
"publishConfig": { "access": "public" },
|
|
164
|
-
"gitHead": "
|
|
164
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
165
165
|
}
|