@powerlines/unplugin 0.0.80 → 0.0.82
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 +45 -0
- package/dist/{chunk-BUUfjzRC.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
- package/dist/esbuild.cjs +3 -2
- package/dist/esbuild.d.cts +2 -2
- package/dist/esbuild.d.cts.map +1 -1
- package/dist/esbuild.d.mts +1 -1
- package/dist/esbuild.d.mts.map +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.d.cts +2 -2
- package/dist/farm.d.cts.map +1 -1
- package/dist/farm.d.mts +1 -1
- package/dist/farm.d.mts.map +1 -1
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/nuxt.cjs +42 -3
- package/dist/nuxt.mjs +43 -3
- package/dist/nuxt.mjs.map +1 -0
- package/dist/package.cjs +18 -0
- package/dist/package.mjs +7 -0
- package/dist/package.mjs.map +1 -0
- package/dist/rolldown.cjs +6 -5
- package/dist/rolldown.d.cts +2 -2
- package/dist/rolldown.d.cts.map +1 -1
- package/dist/rolldown.d.mts +1 -1
- package/dist/rolldown.d.mts.map +1 -1
- package/dist/rollup.cjs +7 -6
- package/dist/rollup.d.cts +2 -2
- package/dist/rollup.d.cts.map +1 -1
- package/dist/rollup.d.mts +1 -1
- package/dist/rollup.d.mts.map +1 -1
- package/dist/rspack.cjs +3 -2
- package/dist/rspack.d.cts +2 -2
- package/dist/rspack.d.cts.map +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/rspack.d.mts.map +1 -1
- package/dist/tsdown.cjs +2 -2
- package/dist/tsup.cjs +2 -2
- package/dist/types.d.cts +11 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/unloader.cjs +1 -1
- package/dist/unloader.d.cts +2 -2
- package/dist/unloader.d.cts.map +1 -1
- package/dist/unloader.d.mts +1 -1
- package/dist/unloader.d.mts.map +1 -1
- package/dist/unplugin.cjs +232 -2
- package/dist/unplugin.d.cts +1 -1
- package/dist/unplugin.d.cts.map +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/vite.cjs +3 -2
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.cts.map +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.mts.map +1 -1
- package/dist/webpack.cjs +3 -2
- package/dist/webpack.d.cts +2 -2
- package/dist/webpack.d.cts.map +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.mts.map +1 -1
- package/package.json +5 -5
- package/dist/nuxt-DnPulowA.mjs +0 -48
- package/dist/nuxt-DnPulowA.mjs.map +0 -1
- package/dist/nuxt-p97pkRJZ.cjs +0 -52
- package/dist/types-CEaXoKbk.d.cts +0 -13
- package/dist/types-CEaXoKbk.d.cts.map +0 -1
- package/dist/unplugin-WjPT9ECw.cjs +0 -296
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
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 __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) {
|
|
11
|
-
__defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!no_symbols) {
|
|
17
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
24
|
-
key = keys[i];
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
26
|
-
__defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
-
value: mod,
|
|
38
|
-
enumerable: true
|
|
39
|
-
}) : target, mod));
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
let _stryke_path_replace = require("@stryke/path/replace");
|
|
43
|
-
let _powerlines_core = require("@powerlines/core");
|
|
44
|
-
let _powerlines_core_constants = require("@powerlines/core/constants");
|
|
45
|
-
let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
|
|
46
|
-
let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
|
|
47
|
-
let _powerlines_core_lib_environment = require("@powerlines/core/lib/environment");
|
|
48
|
-
let _powerlines_core_lib_utilities_source_file = require("@powerlines/core/lib/utilities/source-file");
|
|
49
|
-
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
50
|
-
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
51
|
-
let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
|
|
52
|
-
let _stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
53
|
-
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
54
|
-
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
55
|
-
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
56
|
-
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
57
|
-
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
58
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
59
|
-
|
|
60
|
-
//#region src/unplugin.ts
|
|
61
|
-
/**
|
|
62
|
-
* Creates a Powerlines unplugin factory that generates a plugin instance.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* The factory will handle loading the Powerlines configuration, resolving the plugin configuration, and executing the appropriate hooks during the build process. It also allows for optional customization of logging and framework identification through the provided options.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts
|
|
69
|
-
* import { createUnpluginFactory } from "@powerlines/unplugin";
|
|
70
|
-
*
|
|
71
|
-
* const factory = createUnpluginFactory({
|
|
72
|
-
* variant: "vite",
|
|
73
|
-
* framework: "my-framework",
|
|
74
|
-
* orgId: "my-org",
|
|
75
|
-
* customLogger: myCustomLogger
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* const plugin = createVitePlugin(factory);
|
|
79
|
-
* export default plugin;
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @param options - The options for the unplugin factory, including the build variant and an optional custom logger.
|
|
83
|
-
* @param decorate - An optional function to decorate the unplugin options.
|
|
84
|
-
* @returns The unplugin factory that generates a plugin instance.
|
|
85
|
-
*/
|
|
86
|
-
function createUnpluginFactory(options, decorate = (options) => options) {
|
|
87
|
-
if (!(0, _powerlines_core.isUnpluginBuilderVariant)(options.variant)) throw new Error(`Invalid unplugin builder variant: ${String(options.variant)}. Expected one of: ${_powerlines_core_constants.UNPLUGIN_BUILDER_VARIANTS.join(", ")}.`);
|
|
88
|
-
const cwd = (0, _stryke_fs_get_workspace_root.getWorkspaceRoot)(process.cwd());
|
|
89
|
-
const virtualModulePrefix = options.virtualModulePrefix ?? "\\0";
|
|
90
|
-
return (params = {}) => {
|
|
91
|
-
let context;
|
|
92
|
-
try {
|
|
93
|
-
const framework = (params.framework?.name ?? options.framework?.name) || "powerlines";
|
|
94
|
-
const orgId = (params.framework?.orgId ?? options.framework?.orgId) || "storm-software";
|
|
95
|
-
const root = (0, _powerlines_core.resolveRoot)(cwd, params.root, params.configFile);
|
|
96
|
-
async function buildStart() {
|
|
97
|
-
const config = await (0, _powerlines_core.loadParsedConfig)(cwd, root, framework, orgId, {
|
|
98
|
-
...params,
|
|
99
|
-
command: "build"
|
|
100
|
-
});
|
|
101
|
-
if (!config) throw new Error("Failed to load configuration");
|
|
102
|
-
const configs = (0, _stryke_convert_to_array.toArray)(config.config);
|
|
103
|
-
if (params.configIndex !== void 0 && params.configIndex >= configs.length) throw new Error(`Invalid execution index: ${params.configIndex}. The configuration file contains ${configs.length} execution(s).`);
|
|
104
|
-
const _options = {
|
|
105
|
-
cwd,
|
|
106
|
-
root,
|
|
107
|
-
...params,
|
|
108
|
-
command: "build",
|
|
109
|
-
configFile: config.configFile,
|
|
110
|
-
executionId: (0, _powerlines_core_plugin_utils.formatExecutionId)(config.config.name || root, "build", 0),
|
|
111
|
-
configIndex: 0
|
|
112
|
-
};
|
|
113
|
-
context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from({
|
|
114
|
-
...options,
|
|
115
|
-
..._options,
|
|
116
|
-
configFile: config.configFile
|
|
117
|
-
}, _options);
|
|
118
|
-
context.logger.info(`Starting ${(0, _stryke_string_format_title_case.titleCase)(framework)} ${(0, _stryke_string_format_title_case.titleCase)(options.variant)} plugin execution`);
|
|
119
|
-
context.logger.debug({
|
|
120
|
-
meta: { category: "config" },
|
|
121
|
-
message: `Invoking ${(0, _stryke_string_format_title_case.titleCase)(framework)} ${(0, _stryke_string_format_title_case.titleCase)(options.variant)} plugin with the following execution parameters: \n --- Execution Options --- \n${(0, _powerlines_core_plugin_utils.formatConfig)(params)}`
|
|
122
|
-
});
|
|
123
|
-
await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
|
|
124
|
-
const timer = context.timer("Preparation");
|
|
125
|
-
await (0, _powerlines_core_lib_environment.executeEnvironments)(context, async (env) => {
|
|
126
|
-
env.debug(`Initializing the processing options for the Powerlines project.`);
|
|
127
|
-
await context.callHook("configResolved", {
|
|
128
|
-
environment: env,
|
|
129
|
-
order: "pre"
|
|
130
|
-
});
|
|
131
|
-
await (0, _powerlines_core.initializeTsconfig)(env);
|
|
132
|
-
await context.callHook("configResolved", {
|
|
133
|
-
environment: env,
|
|
134
|
-
order: "normal"
|
|
135
|
-
});
|
|
136
|
-
if (env.entry.length > 0) {
|
|
137
|
-
const entriesLength = (0, _stryke_type_checks_is_object.isObject)(env.config.input) ? Object.keys(env.config.input).length : (0, _stryke_convert_to_array.toArray)(env.config.input).length;
|
|
138
|
-
env.debug(`The configuration provided ${entriesLength} entry point${entriesLength !== 1 ? "s" : ""}, Powerlines has found ${env.entry.length} entry file${env.entry.length !== 1 ? "s" : ""} for the ${env.config.title} project${env.entry.length > 0 && env.entry.length < 10 ? `: \n${env.entry.map((entry) => `- ${(0, _stryke_path_replace.replacePath)(entry.file, context.config.root)}${entry.output ? ` -> ${(0, _stryke_path_replace.replacePath)(entry.output, context.config.root)}` : ""}`).join(" \n")}` : ""}`);
|
|
139
|
-
} else env.warn(`No entry files were found for the ${env.config.title} project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`);
|
|
140
|
-
await (0, _powerlines_core.resolveTsconfig)(env);
|
|
141
|
-
await (0, _powerlines_core.installDependencies)(env);
|
|
142
|
-
await context.callHook("configResolved", {
|
|
143
|
-
environment: env,
|
|
144
|
-
order: "post"
|
|
145
|
-
});
|
|
146
|
-
env.trace({
|
|
147
|
-
meta: { category: "config" },
|
|
148
|
-
message: `Powerlines configuration after configResolved hook: \n${(0, _powerlines_core_plugin_utils.formatConfig)(env.config)}`
|
|
149
|
-
});
|
|
150
|
-
if (!env.fs.existsSync(env.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(env.cachePath);
|
|
151
|
-
if (!env.fs.existsSync(env.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(env.dataPath);
|
|
152
|
-
await context.callHook("prepare", {
|
|
153
|
-
environment: env,
|
|
154
|
-
order: "pre"
|
|
155
|
-
});
|
|
156
|
-
await context.callHook("prepare", {
|
|
157
|
-
environment: env,
|
|
158
|
-
order: "normal"
|
|
159
|
-
});
|
|
160
|
-
await context.callHook("prepare", {
|
|
161
|
-
environment: env,
|
|
162
|
-
order: "post"
|
|
163
|
-
});
|
|
164
|
-
if (env.config.output.types !== false) await (0, _powerlines_core.handleTypes)(context, env);
|
|
165
|
-
context.debug("Formatting files generated during the prepare step.");
|
|
166
|
-
await Promise.all([(0, _powerlines_core.formatFolder)(env, env.builtinsPath), (0, _powerlines_core.formatFolder)(env, env.entryPath)]);
|
|
167
|
-
await (0, _powerlines_core.writeMetaFile)(env);
|
|
168
|
-
env.persistedMeta = env.meta;
|
|
169
|
-
});
|
|
170
|
-
timer();
|
|
171
|
-
}
|
|
172
|
-
async function resolveId(id, importer, opts = { isEntry: false }) {
|
|
173
|
-
const normalizedId = (0, _powerlines_core_plugin_utils.removeVirtualPrefix)(id);
|
|
174
|
-
const normalizedImporter = importer ? (0, _powerlines_core_plugin_utils.removeVirtualPrefix)(importer) : void 0;
|
|
175
|
-
let result = await context.callHook("resolveId", {
|
|
176
|
-
sequential: true,
|
|
177
|
-
result: "first",
|
|
178
|
-
order: "pre"
|
|
179
|
-
}, normalizedId, normalizedImporter, opts);
|
|
180
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
181
|
-
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
182
|
-
...result,
|
|
183
|
-
id: result.virtual && virtualModulePrefix !== false ? (0, _powerlines_core_plugin_utils.addVirtualPrefix)(result.id) : result.id
|
|
184
|
-
};
|
|
185
|
-
result = await context.callHook("resolveId", {
|
|
186
|
-
sequential: true,
|
|
187
|
-
result: "first",
|
|
188
|
-
order: "normal"
|
|
189
|
-
}, normalizedId, normalizedImporter, opts);
|
|
190
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
191
|
-
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
192
|
-
...result,
|
|
193
|
-
id: result.virtual && virtualModulePrefix !== false ? (0, _powerlines_core_plugin_utils.addVirtualPrefix)(result.id) : result.id
|
|
194
|
-
};
|
|
195
|
-
result = await context.resolve(normalizedId, normalizedImporter, {
|
|
196
|
-
isFile: true,
|
|
197
|
-
...opts
|
|
198
|
-
});
|
|
199
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
200
|
-
...result,
|
|
201
|
-
id: result.virtual && virtualModulePrefix !== false ? (0, _powerlines_core_plugin_utils.addVirtualPrefix)(result.id) : result.id
|
|
202
|
-
};
|
|
203
|
-
result = await context.callHook("resolveId", {
|
|
204
|
-
sequential: true,
|
|
205
|
-
result: "first",
|
|
206
|
-
order: "post"
|
|
207
|
-
}, normalizedId, normalizedImporter, opts);
|
|
208
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) return result;
|
|
209
|
-
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) return {
|
|
210
|
-
...result,
|
|
211
|
-
id: result.virtual && virtualModulePrefix !== false ? (0, _powerlines_core_plugin_utils.addVirtualPrefix)(result.id) : result.id
|
|
212
|
-
};
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
const load = {
|
|
216
|
-
filter: virtualModulePrefix !== false ? { id: _powerlines_core_plugin_utils.VIRTUAL_MODULE_PREFIX_REGEX } : void 0,
|
|
217
|
-
async handler(id) {
|
|
218
|
-
const normalizedId = (0, _powerlines_core_plugin_utils.removeVirtualPrefix)(id);
|
|
219
|
-
let result = await context.callHook("load", {
|
|
220
|
-
sequential: true,
|
|
221
|
-
result: "first",
|
|
222
|
-
order: "pre"
|
|
223
|
-
}, normalizedId);
|
|
224
|
-
if (result) return result;
|
|
225
|
-
result = await context.callHook("load", {
|
|
226
|
-
sequential: true,
|
|
227
|
-
result: "first",
|
|
228
|
-
order: "normal"
|
|
229
|
-
}, normalizedId);
|
|
230
|
-
if (result) return result;
|
|
231
|
-
result = await context.load(normalizedId);
|
|
232
|
-
if (result) return result;
|
|
233
|
-
return context.callHook("load", {
|
|
234
|
-
sequential: true,
|
|
235
|
-
result: "first",
|
|
236
|
-
order: "post"
|
|
237
|
-
}, normalizedId);
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
async function transform(code, id) {
|
|
241
|
-
return context.callHook("transform", {
|
|
242
|
-
environment: await context.getEnvironment(),
|
|
243
|
-
result: "merge",
|
|
244
|
-
asNextParam: (previousResult) => (0, _powerlines_core_lib_utilities_source_file.getString)(previousResult)
|
|
245
|
-
}, (0, _powerlines_core_lib_utilities_source_file.getString)(code), id);
|
|
246
|
-
}
|
|
247
|
-
async function writeBundle() {
|
|
248
|
-
context.logger.debug("Finalizing Powerlines project output...");
|
|
249
|
-
await context.callHook("writeBundle", { environment: await context.getEnvironment() });
|
|
250
|
-
}
|
|
251
|
-
context.logger.debug("Unplugin initialized successfully.");
|
|
252
|
-
const result = {
|
|
253
|
-
name: `${(0, _stryke_string_format_kebab_case.kebabCase)(framework)}:${(0, _stryke_string_format_kebab_case.kebabCase)(options.variant)}-plugin`,
|
|
254
|
-
context,
|
|
255
|
-
resolveId,
|
|
256
|
-
load,
|
|
257
|
-
transform,
|
|
258
|
-
buildStart,
|
|
259
|
-
writeBundle
|
|
260
|
-
};
|
|
261
|
-
return {
|
|
262
|
-
...result,
|
|
263
|
-
...decorate(result)
|
|
264
|
-
};
|
|
265
|
-
} catch (error) {
|
|
266
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(context?.logger?.error)) context.logger.error(error?.message);
|
|
267
|
-
throw error;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
//#endregion
|
|
273
|
-
Object.defineProperty(exports, '__exportAll', {
|
|
274
|
-
enumerable: true,
|
|
275
|
-
get: function () {
|
|
276
|
-
return __exportAll;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
Object.defineProperty(exports, '__reExport', {
|
|
280
|
-
enumerable: true,
|
|
281
|
-
get: function () {
|
|
282
|
-
return __reExport;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(exports, '__toESM', {
|
|
286
|
-
enumerable: true,
|
|
287
|
-
get: function () {
|
|
288
|
-
return __toESM;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
Object.defineProperty(exports, 'createUnpluginFactory', {
|
|
292
|
-
enumerable: true,
|
|
293
|
-
get: function () {
|
|
294
|
-
return createUnpluginFactory;
|
|
295
|
-
}
|
|
296
|
-
});
|