@powerlines/plugin-babel 0.12.125 → 0.12.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/helpers/ast-utils.cjs +35 -1
- package/dist/helpers/ast-utils.mjs +32 -1
- package/dist/helpers/create-plugin.cjs +41 -1
- package/dist/helpers/create-plugin.mjs +39 -1
- package/dist/helpers/filters.cjs +59 -1
- package/dist/helpers/filters.mjs +55 -1
- package/dist/helpers/index.cjs +22 -1
- package/dist/helpers/index.mjs +7 -1
- package/dist/helpers/module-helpers.cjs +103 -1
- package/dist/helpers/module-helpers.mjs +95 -1
- package/dist/helpers/options.cjs +50 -1
- package/dist/helpers/options.mjs +47 -1
- package/dist/index.cjs +110 -1
- package/dist/index.mjs +90 -1
- package/dist/powerlines/src/lib/logger.cjs +41 -1
- package/dist/powerlines/src/lib/logger.mjs +39 -1
- package/dist/powerlines/src/types/context.d.cts +43 -2
- package/dist/powerlines/src/types/context.d.mts +44 -3
- package/dist/powerlines/src/types/fs.d.cts +14 -0
- package/dist/powerlines/src/types/fs.d.mts +14 -0
- package/dist/powerlines/src/types/index.d.mts +1 -1
- 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;
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __babel_generator = require("@babel/generator");
|
|
3
|
+
__babel_generator = require_rolldown_runtime.__toESM(__babel_generator);
|
|
4
|
+
let __babel_parser = require("@babel/parser");
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/ast-utils.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parse the given code into an AST.
|
|
9
|
+
*
|
|
10
|
+
* @param code - The code to parse.
|
|
11
|
+
* @param opts - The options for parsing.
|
|
12
|
+
* @returns The parsed AST.
|
|
13
|
+
*/
|
|
14
|
+
function parseAst(code, opts = {}) {
|
|
15
|
+
return (0, __babel_parser.parse)(code, {
|
|
16
|
+
plugins: ["typescript"],
|
|
17
|
+
sourceType: "module",
|
|
18
|
+
allowImportExportEverywhere: true,
|
|
19
|
+
allowAwaitOutsideFunction: true,
|
|
20
|
+
...opts
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
let generate = __babel_generator.default;
|
|
24
|
+
if ("default" in generate) generate = generate.default;
|
|
25
|
+
function generateFromAst(ast, opts) {
|
|
26
|
+
return generate(ast, opts ? {
|
|
27
|
+
importAttributesKeyword: "with",
|
|
28
|
+
sourceMaps: true,
|
|
29
|
+
...opts
|
|
30
|
+
} : void 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.generateFromAst = generateFromAst;
|
|
35
|
+
exports.parseAst = parseAst;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _generate from "@babel/generator";
|
|
2
|
+
import { parse } from "@babel/parser";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/ast-utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Parse the given code into an AST.
|
|
7
|
+
*
|
|
8
|
+
* @param code - The code to parse.
|
|
9
|
+
* @param opts - The options for parsing.
|
|
10
|
+
* @returns The parsed AST.
|
|
11
|
+
*/
|
|
12
|
+
function parseAst(code, opts = {}) {
|
|
13
|
+
return parse(code, {
|
|
14
|
+
plugins: ["typescript"],
|
|
15
|
+
sourceType: "module",
|
|
16
|
+
allowImportExportEverywhere: true,
|
|
17
|
+
allowAwaitOutsideFunction: true,
|
|
18
|
+
...opts
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
let generate = _generate;
|
|
22
|
+
if ("default" in generate) generate = generate.default;
|
|
23
|
+
function generateFromAst(ast, opts) {
|
|
24
|
+
return generate(ast, opts ? {
|
|
25
|
+
importAttributesKeyword: "with",
|
|
26
|
+
sourceMaps: true,
|
|
27
|
+
...opts
|
|
28
|
+
} : void 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { generateFromAst, parseAst };
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_logger = require('../powerlines/src/lib/logger.cjs');
|
|
3
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
+
let chalk = require("chalk");
|
|
5
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
6
|
+
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
7
|
+
|
|
8
|
+
//#region src/helpers/create-plugin.ts
|
|
9
|
+
/**
|
|
10
|
+
* Create a Babel plugin using the provided builder function.
|
|
11
|
+
*
|
|
12
|
+
* @param name - The name of the plugin.
|
|
13
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
14
|
+
* @returns A Babel plugin declaration.
|
|
15
|
+
*/
|
|
16
|
+
function createBabelPlugin(name, builder) {
|
|
17
|
+
const plugin = (context) => {
|
|
18
|
+
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
19
|
+
api.cache.using(() => context.meta.checksum);
|
|
20
|
+
api.assertVersion("^7.0.0-0");
|
|
21
|
+
const log = require_logger.extendLog(context.log, name);
|
|
22
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
23
|
+
const result = builder({
|
|
24
|
+
log,
|
|
25
|
+
name,
|
|
26
|
+
api,
|
|
27
|
+
options,
|
|
28
|
+
context,
|
|
29
|
+
dirname
|
|
30
|
+
});
|
|
31
|
+
result.name = name;
|
|
32
|
+
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
33
|
+
return result;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
plugin.$$name = name;
|
|
37
|
+
return plugin;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.createBabelPlugin = createBabelPlugin;
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
import{extendLog
|
|
1
|
+
import { extendLog } from "../powerlines/src/lib/logger.mjs";
|
|
2
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { declare } from "@babel/helper-plugin-utils";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/create-plugin.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create a Babel plugin using the provided builder function.
|
|
9
|
+
*
|
|
10
|
+
* @param name - The name of the plugin.
|
|
11
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
12
|
+
* @returns A Babel plugin declaration.
|
|
13
|
+
*/
|
|
14
|
+
function createBabelPlugin(name, builder) {
|
|
15
|
+
const plugin = (context) => {
|
|
16
|
+
return declare((api, options, dirname) => {
|
|
17
|
+
api.cache.using(() => context.meta.checksum);
|
|
18
|
+
api.assertVersion("^7.0.0-0");
|
|
19
|
+
const log = extendLog(context.log, name);
|
|
20
|
+
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
21
|
+
const result = builder({
|
|
22
|
+
log,
|
|
23
|
+
name,
|
|
24
|
+
api,
|
|
25
|
+
options,
|
|
26
|
+
context,
|
|
27
|
+
dirname
|
|
28
|
+
});
|
|
29
|
+
result.name = name;
|
|
30
|
+
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
31
|
+
return result;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
plugin.$$name = name;
|
|
35
|
+
return plugin;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { createBabelPlugin };
|
package/dist/helpers/filters.cjs
CHANGED
|
@@ -1 +1,59 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
+
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
4
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/filters.ts
|
|
7
|
+
function getPluginName(plugin) {
|
|
8
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
12
|
+
*
|
|
13
|
+
* @param plugins - The list of existing Babel plugins.
|
|
14
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
15
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
18
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Filters a Babel plugin by its runtime ID.
|
|
22
|
+
*
|
|
23
|
+
* @param context - The context in which the filter is applied.
|
|
24
|
+
* @param fileId - The file ID to filter by.
|
|
25
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
26
|
+
*/
|
|
27
|
+
function filterPluginByFileId(context, fileId) {
|
|
28
|
+
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
32
|
+
*
|
|
33
|
+
* @param context - The context in which the plugin is being added.
|
|
34
|
+
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
35
|
+
* @param filter - The filter function to apply to the plugins.
|
|
36
|
+
* @param name - The name of the plugin to add the filter to.
|
|
37
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
38
|
+
*/
|
|
39
|
+
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
40
|
+
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && ((0, __stryke_type_checks_is_set_string.isSetString)(pluginOrPlugins[0]) || (0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
41
|
+
pluginOrPlugins[0],
|
|
42
|
+
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
43
|
+
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !(0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
44
|
+
] : [
|
|
45
|
+
pluginOrPlugins,
|
|
46
|
+
{},
|
|
47
|
+
{ filter }
|
|
48
|
+
];
|
|
49
|
+
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
50
|
+
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
51
|
+
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
52
|
+
return pluginOrPlugins;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.addPluginFilter = addPluginFilter;
|
|
57
|
+
exports.filterPluginByFileId = filterPluginByFileId;
|
|
58
|
+
exports.getPluginName = getPluginName;
|
|
59
|
+
exports.isDuplicatePlugin = isDuplicatePlugin;
|
package/dist/helpers/filters.mjs
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
|
-
import{isFunction
|
|
1
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
2
|
+
import { isObject } from "@stryke/type-checks/is-object";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/filters.ts
|
|
6
|
+
function getPluginName(plugin) {
|
|
7
|
+
return isSetString(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
11
|
+
*
|
|
12
|
+
* @param plugins - The list of existing Babel plugins.
|
|
13
|
+
* @param plugin - The Babel plugin to check for duplicates.
|
|
14
|
+
* @returns True if the plugin is a duplicate, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
function isDuplicatePlugin(plugins, plugin) {
|
|
17
|
+
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Filters a Babel plugin by its runtime ID.
|
|
21
|
+
*
|
|
22
|
+
* @param context - The context in which the filter is applied.
|
|
23
|
+
* @param fileId - The file ID to filter by.
|
|
24
|
+
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
25
|
+
*/
|
|
26
|
+
function filterPluginByFileId(context, fileId) {
|
|
27
|
+
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The context in which the plugin is being added.
|
|
33
|
+
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
34
|
+
* @param filter - The filter function to apply to the plugins.
|
|
35
|
+
* @param name - The name of the plugin to add the filter to.
|
|
36
|
+
* @returns The updated list of Babel plugins with the filter applied.
|
|
37
|
+
*/
|
|
38
|
+
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
39
|
+
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && (isSetString(pluginOrPlugins[0]) || isFunction(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && isObject(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && isObject(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
40
|
+
pluginOrPlugins[0],
|
|
41
|
+
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
42
|
+
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !isFunction(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
43
|
+
] : [
|
|
44
|
+
pluginOrPlugins,
|
|
45
|
+
{},
|
|
46
|
+
{ filter }
|
|
47
|
+
];
|
|
48
|
+
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
49
|
+
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
50
|
+
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
51
|
+
return pluginOrPlugins;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_helpers_filters = require('./filters.cjs');
|
|
2
|
+
const require_helpers_options = require('./options.cjs');
|
|
3
|
+
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
4
|
+
const require_helpers_create_plugin = require('./create-plugin.cjs');
|
|
5
|
+
const require_helpers_module_helpers = require('./module-helpers.cjs');
|
|
6
|
+
|
|
7
|
+
exports.addImport = require_helpers_module_helpers.addImport;
|
|
8
|
+
exports.addImportsToProgram = require_helpers_module_helpers.addImportsToProgram;
|
|
9
|
+
exports.addPluginFilter = require_helpers_filters.addPluginFilter;
|
|
10
|
+
exports.createBabelPlugin = require_helpers_create_plugin.createBabelPlugin;
|
|
11
|
+
exports.filterPluginByFileId = require_helpers_filters.filterPluginByFileId;
|
|
12
|
+
exports.findExport = require_helpers_module_helpers.findExport;
|
|
13
|
+
exports.generateFromAst = require_helpers_ast_utils.generateFromAst;
|
|
14
|
+
exports.getImport = require_helpers_module_helpers.getImport;
|
|
15
|
+
exports.getPluginName = require_helpers_filters.getPluginName;
|
|
16
|
+
exports.isDuplicatePlugin = require_helpers_filters.isDuplicatePlugin;
|
|
17
|
+
exports.isImportCall = require_helpers_module_helpers.isImportCall;
|
|
18
|
+
exports.listExports = require_helpers_module_helpers.listExports;
|
|
19
|
+
exports.listImports = require_helpers_module_helpers.listImports;
|
|
20
|
+
exports.parseAst = require_helpers_ast_utils.parseAst;
|
|
21
|
+
exports.resolveBabelPlugin = require_helpers_options.resolveBabelPlugin;
|
|
22
|
+
exports.resolvePluginFunction = require_helpers_options.resolvePluginFunction;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{addPluginFilter
|
|
1
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.mjs";
|
|
2
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.mjs";
|
|
3
|
+
import { generateFromAst, parseAst } from "./ast-utils.mjs";
|
|
4
|
+
import { createBabelPlugin } from "./create-plugin.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.mjs";
|
|
6
|
+
|
|
7
|
+
export { addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1 +1,103 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
3
|
+
let __babel_types = require("@babel/types");
|
|
4
|
+
__babel_types = require_rolldown_runtime.__toESM(__babel_types);
|
|
5
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
6
|
+
|
|
7
|
+
//#region src/helpers/module-helpers.ts
|
|
8
|
+
/**
|
|
9
|
+
* Finds an export in the given Babel AST program by its key.
|
|
10
|
+
*
|
|
11
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
12
|
+
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
13
|
+
* @returns The declaration of the export if found, otherwise undefined.
|
|
14
|
+
*/
|
|
15
|
+
function findExport(ast, key) {
|
|
16
|
+
const type = key === "default" ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
|
|
17
|
+
for (const node of ast.program.body) if (node.type === type) {
|
|
18
|
+
if (key === "default") return node.declaration;
|
|
19
|
+
if (node.declaration && "declarations" in node.declaration) {
|
|
20
|
+
const declaration = node.declaration.declarations[0];
|
|
21
|
+
if (declaration && "name" in declaration.id && declaration.id.name === key) return declaration.init;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Lists all exports from the given Babel AST program.
|
|
27
|
+
*
|
|
28
|
+
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
29
|
+
* @returns An array of export names, including "default" for default exports.
|
|
30
|
+
*/
|
|
31
|
+
function listExports(codeOrAst) {
|
|
32
|
+
return ((0, __stryke_type_checks_is_string.isString)(codeOrAst) ? require_helpers_ast_utils.parseAst(codeOrAst) : codeOrAst).program.body.flatMap((i) => {
|
|
33
|
+
if (i.type === "ExportDefaultDeclaration") return ["default"];
|
|
34
|
+
if (i.type === "ExportNamedDeclaration" && i.declaration && "declarations" in i.declaration) return i.declaration.declarations.map((d) => "name" in d.id ? d.id.name : "");
|
|
35
|
+
return [];
|
|
36
|
+
}).filter(Boolean);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Lists all imports from the given Babel AST program.
|
|
40
|
+
*
|
|
41
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
42
|
+
* @returns An array of import names, including "default" for default imports.
|
|
43
|
+
*/
|
|
44
|
+
function listImports(ast) {
|
|
45
|
+
return ast.program.body.flatMap((i) => {
|
|
46
|
+
if (i.type === "ImportDeclaration") return i.specifiers.map((s) => {
|
|
47
|
+
if (s.type === "ImportDefaultSpecifier") return "default";
|
|
48
|
+
if (s.type === "ImportSpecifier" && "imported" in s) return s.imported.type === "Identifier" ? s.imported.name : s.imported.value;
|
|
49
|
+
return "";
|
|
50
|
+
});
|
|
51
|
+
return [];
|
|
52
|
+
}).filter(Boolean);
|
|
53
|
+
}
|
|
54
|
+
function isImportCall(calleePath) {
|
|
55
|
+
return __babel_types.isImport(calleePath.node.callee);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets the import declaration for a given name and specifier.
|
|
59
|
+
*
|
|
60
|
+
* @param specifier - The specifier of the import.
|
|
61
|
+
* @param name - The name of the import.
|
|
62
|
+
* @param named - Optional named import.
|
|
63
|
+
* @returns The import declaration.
|
|
64
|
+
*/
|
|
65
|
+
function getImport(specifier, name, named) {
|
|
66
|
+
return __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(name), __babel_types.stringLiteral(named || name))], __babel_types.stringLiteral(specifier));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Adds an import to the program if it doesn't already exist.
|
|
70
|
+
*
|
|
71
|
+
* @param path - The current NodePath in the AST.
|
|
72
|
+
* @param specifier - The import specifier.
|
|
73
|
+
*/
|
|
74
|
+
function addImport(path, specifier) {
|
|
75
|
+
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
76
|
+
}
|
|
77
|
+
function isNonNamespacedImport(importDeclPath) {
|
|
78
|
+
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
79
|
+
}
|
|
80
|
+
function getExistingImports(program) {
|
|
81
|
+
const existingImports = /* @__PURE__ */ new Map();
|
|
82
|
+
program.traverse({ ImportDeclaration(path) {
|
|
83
|
+
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
84
|
+
} });
|
|
85
|
+
return existingImports;
|
|
86
|
+
}
|
|
87
|
+
function addImportsToProgram(path, specifier) {
|
|
88
|
+
/**
|
|
89
|
+
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
90
|
+
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
91
|
+
* destructured variables.
|
|
92
|
+
*/
|
|
93
|
+
if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", __babel_types.importDeclaration([__babel_types.importSpecifier(__babel_types.identifier(specifier.name || specifier.imported), __babel_types.identifier(specifier.imported))], __babel_types.stringLiteral(specifier.module)));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
exports.addImport = addImport;
|
|
98
|
+
exports.addImportsToProgram = addImportsToProgram;
|
|
99
|
+
exports.findExport = findExport;
|
|
100
|
+
exports.getImport = getImport;
|
|
101
|
+
exports.isImportCall = isImportCall;
|
|
102
|
+
exports.listExports = listExports;
|
|
103
|
+
exports.listImports = listImports;
|
|
@@ -1 +1,95 @@
|
|
|
1
|
-
import{parseAst
|
|
1
|
+
import { parseAst } from "./ast-utils.mjs";
|
|
2
|
+
import * as t from "@babel/types";
|
|
3
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/module-helpers.ts
|
|
6
|
+
/**
|
|
7
|
+
* Finds an export in the given Babel AST program by its key.
|
|
8
|
+
*
|
|
9
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
10
|
+
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
11
|
+
* @returns The declaration of the export if found, otherwise undefined.
|
|
12
|
+
*/
|
|
13
|
+
function findExport(ast, key) {
|
|
14
|
+
const type = key === "default" ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
|
|
15
|
+
for (const node of ast.program.body) if (node.type === type) {
|
|
16
|
+
if (key === "default") return node.declaration;
|
|
17
|
+
if (node.declaration && "declarations" in node.declaration) {
|
|
18
|
+
const declaration = node.declaration.declarations[0];
|
|
19
|
+
if (declaration && "name" in declaration.id && declaration.id.name === key) return declaration.init;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Lists all exports from the given Babel AST program.
|
|
25
|
+
*
|
|
26
|
+
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
27
|
+
* @returns An array of export names, including "default" for default exports.
|
|
28
|
+
*/
|
|
29
|
+
function listExports(codeOrAst) {
|
|
30
|
+
return (isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst).program.body.flatMap((i) => {
|
|
31
|
+
if (i.type === "ExportDefaultDeclaration") return ["default"];
|
|
32
|
+
if (i.type === "ExportNamedDeclaration" && i.declaration && "declarations" in i.declaration) return i.declaration.declarations.map((d) => "name" in d.id ? d.id.name : "");
|
|
33
|
+
return [];
|
|
34
|
+
}).filter(Boolean);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists all imports from the given Babel AST program.
|
|
38
|
+
*
|
|
39
|
+
* @param ast - The parsed Babel AST result containing the program body.
|
|
40
|
+
* @returns An array of import names, including "default" for default imports.
|
|
41
|
+
*/
|
|
42
|
+
function listImports(ast) {
|
|
43
|
+
return ast.program.body.flatMap((i) => {
|
|
44
|
+
if (i.type === "ImportDeclaration") return i.specifiers.map((s) => {
|
|
45
|
+
if (s.type === "ImportDefaultSpecifier") return "default";
|
|
46
|
+
if (s.type === "ImportSpecifier" && "imported" in s) return s.imported.type === "Identifier" ? s.imported.name : s.imported.value;
|
|
47
|
+
return "";
|
|
48
|
+
});
|
|
49
|
+
return [];
|
|
50
|
+
}).filter(Boolean);
|
|
51
|
+
}
|
|
52
|
+
function isImportCall(calleePath) {
|
|
53
|
+
return t.isImport(calleePath.node.callee);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the import declaration for a given name and specifier.
|
|
57
|
+
*
|
|
58
|
+
* @param specifier - The specifier of the import.
|
|
59
|
+
* @param name - The name of the import.
|
|
60
|
+
* @param named - Optional named import.
|
|
61
|
+
* @returns The import declaration.
|
|
62
|
+
*/
|
|
63
|
+
function getImport(specifier, name, named) {
|
|
64
|
+
return t.importDeclaration([t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))], t.stringLiteral(specifier));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Adds an import to the program if it doesn't already exist.
|
|
68
|
+
*
|
|
69
|
+
* @param path - The current NodePath in the AST.
|
|
70
|
+
* @param specifier - The import specifier.
|
|
71
|
+
*/
|
|
72
|
+
function addImport(path, specifier) {
|
|
73
|
+
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
74
|
+
}
|
|
75
|
+
function isNonNamespacedImport(importDeclPath) {
|
|
76
|
+
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
77
|
+
}
|
|
78
|
+
function getExistingImports(program) {
|
|
79
|
+
const existingImports = /* @__PURE__ */ new Map();
|
|
80
|
+
program.traverse({ ImportDeclaration(path) {
|
|
81
|
+
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
82
|
+
} });
|
|
83
|
+
return existingImports;
|
|
84
|
+
}
|
|
85
|
+
function addImportsToProgram(path, specifier) {
|
|
86
|
+
/**
|
|
87
|
+
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
88
|
+
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
89
|
+
* destructured variables.
|
|
90
|
+
*/
|
|
91
|
+
if (!getExistingImports(path).get(specifier.module)) path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(t.identifier(specifier.name || specifier.imported), t.identifier(specifier.imported))], t.stringLiteral(specifier.module)));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
package/dist/helpers/options.cjs
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_helpers_filters = require('./filters.cjs');
|
|
3
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
+
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
|
+
let chalk = require("chalk");
|
|
6
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
7
|
+
|
|
8
|
+
//#region src/helpers/options.ts
|
|
9
|
+
function resolvePluginFunction(context, plugin) {
|
|
10
|
+
try {
|
|
11
|
+
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? (0, __stryke_type_checks_is_function.isFunction)(plugin[0]) ? plugin[0](context) : plugin[0] : (0, __stryke_type_checks_is_function.isFunction)(plugin) ? plugin(context) : plugin;
|
|
12
|
+
} catch {
|
|
13
|
+
return plugin[0];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
18
|
+
*
|
|
19
|
+
* @param context - The context for the transformation.
|
|
20
|
+
* @param code - The code to be transformed.
|
|
21
|
+
* @param id - The ID of the source file.
|
|
22
|
+
* @param plugin - The Babel plugin to resolve.
|
|
23
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
24
|
+
*/
|
|
25
|
+
function resolveBabelPlugin(context, code, id, plugin) {
|
|
26
|
+
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
27
|
+
if (plugin.length > 2 && plugin[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
|
|
28
|
+
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_helpers_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return plugin.length > 2 ? [
|
|
32
|
+
resolvePluginFunction(context, plugin),
|
|
33
|
+
plugin[1],
|
|
34
|
+
plugin[2]
|
|
35
|
+
] : [
|
|
36
|
+
resolvePluginFunction(context, plugin),
|
|
37
|
+
plugin[1],
|
|
38
|
+
null
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return [
|
|
42
|
+
resolvePluginFunction(context, plugin),
|
|
43
|
+
{},
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.resolveBabelPlugin = resolveBabelPlugin;
|
|
50
|
+
exports.resolvePluginFunction = resolvePluginFunction;
|
package/dist/helpers/options.mjs
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import{getPluginName
|
|
1
|
+
import { getPluginName } from "./filters.mjs";
|
|
2
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers/options.ts
|
|
7
|
+
function resolvePluginFunction(context, plugin) {
|
|
8
|
+
try {
|
|
9
|
+
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? isFunction(plugin[0]) ? plugin[0](context) : plugin[0] : isFunction(plugin) ? plugin(context) : plugin;
|
|
10
|
+
} catch {
|
|
11
|
+
return plugin[0];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The context for the transformation.
|
|
18
|
+
* @param code - The code to be transformed.
|
|
19
|
+
* @param id - The ID of the source file.
|
|
20
|
+
* @param plugin - The Babel plugin to resolve.
|
|
21
|
+
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
22
|
+
*/
|
|
23
|
+
function resolveBabelPlugin(context, code, id, plugin) {
|
|
24
|
+
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
25
|
+
if (plugin.length > 2 && plugin[2] && isFunction(plugin[2]) && !plugin[2](code, id)) {
|
|
26
|
+
context.log(LogLevelLabel.TRACE, `Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return plugin.length > 2 ? [
|
|
30
|
+
resolvePluginFunction(context, plugin),
|
|
31
|
+
plugin[1],
|
|
32
|
+
plugin[2]
|
|
33
|
+
] : [
|
|
34
|
+
resolvePluginFunction(context, plugin),
|
|
35
|
+
plugin[1],
|
|
36
|
+
null
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
resolvePluginFunction(context, plugin),
|
|
41
|
+
{},
|
|
42
|
+
null
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { resolveBabelPlugin, resolvePluginFunction };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,110 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_helpers_filters = require('./helpers/filters.cjs');
|
|
4
|
+
const require_helpers_options = require('./helpers/options.cjs');
|
|
5
|
+
const require_helpers_ast_utils = require('./helpers/ast-utils.cjs');
|
|
6
|
+
const require_helpers_create_plugin = require('./helpers/create-plugin.cjs');
|
|
7
|
+
const require_helpers_module_helpers = require('./helpers/module-helpers.cjs');
|
|
8
|
+
require('./helpers/index.cjs');
|
|
9
|
+
let __babel_core = require("@babel/core");
|
|
10
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
11
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
12
|
+
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
13
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
14
|
+
let defu = require("defu");
|
|
15
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
16
|
+
|
|
17
|
+
//#region src/index.ts
|
|
18
|
+
/**
|
|
19
|
+
* Babel plugin for Powerlines.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The Babel plugin user configuration options.
|
|
22
|
+
* @returns A Powerlines plugin that integrates Babel transformations.
|
|
23
|
+
*/
|
|
24
|
+
const plugin = (options = {}) => {
|
|
25
|
+
return {
|
|
26
|
+
name: "babel",
|
|
27
|
+
config() {
|
|
28
|
+
if (!(0, __stryke_type_checks_is_set_object.isSetObject)(options)) return;
|
|
29
|
+
return { transform: { babel: options } };
|
|
30
|
+
},
|
|
31
|
+
configResolved: {
|
|
32
|
+
order: "pre",
|
|
33
|
+
handler() {
|
|
34
|
+
this.devDependencies["@babel/core"] = "^7.28.4";
|
|
35
|
+
this.config.transform.babel = (0, defu.default)(this.config.transform.babel ?? {}, {
|
|
36
|
+
plugins: [],
|
|
37
|
+
presets: []
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async transform(code, id) {
|
|
42
|
+
if ((0, __stryke_path_is_parent_path.isParentPath)(id, this.powerlinesPath) || code.includes("/* @storm-ignore */") || code.includes("/* @storm-disable */")) {
|
|
43
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
|
|
44
|
+
return {
|
|
45
|
+
code,
|
|
46
|
+
id
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
|
|
50
|
+
const plugins = this.config.transform.babel.plugins.map((plugin$1) => require_helpers_options.resolveBabelPlugin(this, code, id, plugin$1)).filter((plugin$1, _, arr) => plugin$1 && !require_helpers_filters.isDuplicatePlugin(arr, plugin$1));
|
|
51
|
+
const presets = this.config.transform.babel.presets.map((preset) => require_helpers_options.resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !require_helpers_filters.isDuplicatePlugin(arr, preset));
|
|
52
|
+
if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
|
|
53
|
+
code,
|
|
54
|
+
id
|
|
55
|
+
};
|
|
56
|
+
if ([
|
|
57
|
+
"ts",
|
|
58
|
+
"cts",
|
|
59
|
+
"mts",
|
|
60
|
+
"tsx"
|
|
61
|
+
].includes((0, __stryke_path_file_path_fns.findFileExtensionSafe)(id)) && !require_helpers_filters.isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !require_helpers_filters.isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: (0, __stryke_path_file_path_fns.findFileExtension)(id) === ".tsx" }]);
|
|
62
|
+
const result = await (0, __babel_core.transformAsync)(code, {
|
|
63
|
+
highlightCode: true,
|
|
64
|
+
code: true,
|
|
65
|
+
ast: false,
|
|
66
|
+
cloneInputAst: false,
|
|
67
|
+
comments: true,
|
|
68
|
+
sourceType: "module",
|
|
69
|
+
configFile: false,
|
|
70
|
+
babelrc: false,
|
|
71
|
+
envName: this.config.mode,
|
|
72
|
+
caller: { name: this.config.framework },
|
|
73
|
+
...this.config.transform.babel ?? {},
|
|
74
|
+
filename: id,
|
|
75
|
+
plugins: plugins.map((plugin$1) => {
|
|
76
|
+
return Array.isArray(plugin$1) && plugin$1.length >= 2 ? [plugin$1[0], (0, defu.default)(plugin$1.length > 1 && plugin$1[1] ? plugin$1[1] : {}, { options })] : plugin$1;
|
|
77
|
+
}).filter(Boolean),
|
|
78
|
+
presets: presets.map((preset) => {
|
|
79
|
+
return Array.isArray(preset) && preset.length >= 2 ? [preset[0], (0, defu.default)(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
|
|
80
|
+
}).filter(Boolean)
|
|
81
|
+
});
|
|
82
|
+
if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
|
|
83
|
+
return {
|
|
84
|
+
code: result.code,
|
|
85
|
+
id
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var src_default = plugin;
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.addImport = require_helpers_module_helpers.addImport;
|
|
94
|
+
exports.addImportsToProgram = require_helpers_module_helpers.addImportsToProgram;
|
|
95
|
+
exports.addPluginFilter = require_helpers_filters.addPluginFilter;
|
|
96
|
+
exports.createBabelPlugin = require_helpers_create_plugin.createBabelPlugin;
|
|
97
|
+
exports.default = src_default;
|
|
98
|
+
exports.filterPluginByFileId = require_helpers_filters.filterPluginByFileId;
|
|
99
|
+
exports.findExport = require_helpers_module_helpers.findExport;
|
|
100
|
+
exports.generateFromAst = require_helpers_ast_utils.generateFromAst;
|
|
101
|
+
exports.getImport = require_helpers_module_helpers.getImport;
|
|
102
|
+
exports.getPluginName = require_helpers_filters.getPluginName;
|
|
103
|
+
exports.isDuplicatePlugin = require_helpers_filters.isDuplicatePlugin;
|
|
104
|
+
exports.isImportCall = require_helpers_module_helpers.isImportCall;
|
|
105
|
+
exports.listExports = require_helpers_module_helpers.listExports;
|
|
106
|
+
exports.listImports = require_helpers_module_helpers.listImports;
|
|
107
|
+
exports.parseAst = require_helpers_ast_utils.parseAst;
|
|
108
|
+
exports.plugin = plugin;
|
|
109
|
+
exports.resolveBabelPlugin = require_helpers_options.resolveBabelPlugin;
|
|
110
|
+
exports.resolvePluginFunction = require_helpers_options.resolvePluginFunction;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,90 @@
|
|
|
1
|
-
import{addPluginFilter
|
|
1
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
2
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
3
|
+
import { generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
4
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
|
+
import "./helpers/index.mjs";
|
|
7
|
+
import { transformAsync } from "@babel/core";
|
|
8
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
9
|
+
import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
10
|
+
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
11
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
12
|
+
import defu from "defu";
|
|
13
|
+
|
|
14
|
+
//#region src/index.ts
|
|
15
|
+
/**
|
|
16
|
+
* Babel plugin for Powerlines.
|
|
17
|
+
*
|
|
18
|
+
* @param options - The Babel plugin user configuration options.
|
|
19
|
+
* @returns A Powerlines plugin that integrates Babel transformations.
|
|
20
|
+
*/
|
|
21
|
+
const plugin = (options = {}) => {
|
|
22
|
+
return {
|
|
23
|
+
name: "babel",
|
|
24
|
+
config() {
|
|
25
|
+
if (!isSetObject(options)) return;
|
|
26
|
+
return { transform: { babel: options } };
|
|
27
|
+
},
|
|
28
|
+
configResolved: {
|
|
29
|
+
order: "pre",
|
|
30
|
+
handler() {
|
|
31
|
+
this.devDependencies["@babel/core"] = "^7.28.4";
|
|
32
|
+
this.config.transform.babel = defu(this.config.transform.babel ?? {}, {
|
|
33
|
+
plugins: [],
|
|
34
|
+
presets: []
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async transform(code, id) {
|
|
39
|
+
if (isParentPath(id, this.powerlinesPath) || code.includes("/* @storm-ignore */") || code.includes("/* @storm-disable */")) {
|
|
40
|
+
this.log(LogLevelLabel.TRACE, `Skipping Babel transformation for: ${id}`);
|
|
41
|
+
return {
|
|
42
|
+
code,
|
|
43
|
+
id
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
this.log(LogLevelLabel.TRACE, `Babel transforming file: ${id}`);
|
|
47
|
+
const plugins = this.config.transform.babel.plugins.map((plugin$1) => resolveBabelPlugin(this, code, id, plugin$1)).filter((plugin$1, _, arr) => plugin$1 && !isDuplicatePlugin(arr, plugin$1));
|
|
48
|
+
const presets = this.config.transform.babel.presets.map((preset) => resolveBabelPlugin(this, code, id, preset)).filter((preset, _, arr) => preset && !isDuplicatePlugin(arr, preset));
|
|
49
|
+
if (Array.isArray(plugins) && plugins.length === 0 && Array.isArray(presets) && presets.length === 0) return {
|
|
50
|
+
code,
|
|
51
|
+
id
|
|
52
|
+
};
|
|
53
|
+
if ([
|
|
54
|
+
"ts",
|
|
55
|
+
"cts",
|
|
56
|
+
"mts",
|
|
57
|
+
"tsx"
|
|
58
|
+
].includes(findFileExtensionSafe(id)) && !isDuplicatePlugin(plugins, "@babel/plugin-syntax-typescript") && !isDuplicatePlugin(presets, "@babel/preset-typescript")) plugins.unshift(["@babel/plugin-syntax-typescript", { isTSX: findFileExtension(id) === ".tsx" }]);
|
|
59
|
+
const result = await transformAsync(code, {
|
|
60
|
+
highlightCode: true,
|
|
61
|
+
code: true,
|
|
62
|
+
ast: false,
|
|
63
|
+
cloneInputAst: false,
|
|
64
|
+
comments: true,
|
|
65
|
+
sourceType: "module",
|
|
66
|
+
configFile: false,
|
|
67
|
+
babelrc: false,
|
|
68
|
+
envName: this.config.mode,
|
|
69
|
+
caller: { name: this.config.framework },
|
|
70
|
+
...this.config.transform.babel ?? {},
|
|
71
|
+
filename: id,
|
|
72
|
+
plugins: plugins.map((plugin$1) => {
|
|
73
|
+
return Array.isArray(plugin$1) && plugin$1.length >= 2 ? [plugin$1[0], defu(plugin$1.length > 1 && plugin$1[1] ? plugin$1[1] : {}, { options })] : plugin$1;
|
|
74
|
+
}).filter(Boolean),
|
|
75
|
+
presets: presets.map((preset) => {
|
|
76
|
+
return Array.isArray(preset) && preset.length >= 2 ? [preset[0], defu(preset.length > 1 && preset[1] ? preset[1] : {}, { options })] : preset;
|
|
77
|
+
}).filter(Boolean)
|
|
78
|
+
});
|
|
79
|
+
if (!result?.code) throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);
|
|
80
|
+
return {
|
|
81
|
+
code: result.code,
|
|
82
|
+
id
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var src_default = plugin;
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, src_default as default, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, plugin, resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1 +1,41 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
+
let chalk = require("chalk");
|
|
4
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
5
|
+
require("@storm-software/config-tools/logger");
|
|
6
|
+
require("@storm-software/config-tools/utilities/colors");
|
|
7
|
+
require("@stryke/helpers/noop");
|
|
8
|
+
require("@stryke/string-format/kebab-case");
|
|
9
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
10
|
+
|
|
11
|
+
//#region ../powerlines/src/lib/logger.ts
|
|
12
|
+
const BADGE_COLORS = [
|
|
13
|
+
"#00A0DD",
|
|
14
|
+
"#6FCE4E",
|
|
15
|
+
"#FBBF24",
|
|
16
|
+
"#F43F5E",
|
|
17
|
+
"#3B82F6",
|
|
18
|
+
"#A855F7",
|
|
19
|
+
"#469592",
|
|
20
|
+
"#288EDF",
|
|
21
|
+
"#D8B4FE",
|
|
22
|
+
"#10B981",
|
|
23
|
+
"#EF4444",
|
|
24
|
+
"#F0EC56",
|
|
25
|
+
"#F472B6",
|
|
26
|
+
"#22D3EE",
|
|
27
|
+
"#EAB308",
|
|
28
|
+
"#84CC16",
|
|
29
|
+
"#F87171",
|
|
30
|
+
"#0EA5E9",
|
|
31
|
+
"#D946EF",
|
|
32
|
+
"#FACC15",
|
|
33
|
+
"#34D399",
|
|
34
|
+
"#8B5CF6"
|
|
35
|
+
];
|
|
36
|
+
const extendLog = (logFn, name) => {
|
|
37
|
+
return (type, ...args) => logFn(type, ` ${chalk.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${(0, __stryke_string_format_title_case.titleCase)(name)} `)} ${args.join(" ")} `);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.extendLog = extendLog;
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
import{LogLevelLabel
|
|
1
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import "@storm-software/config-tools/logger";
|
|
4
|
+
import "@storm-software/config-tools/utilities/colors";
|
|
5
|
+
import "@stryke/helpers/noop";
|
|
6
|
+
import "@stryke/string-format/kebab-case";
|
|
7
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
8
|
+
|
|
9
|
+
//#region ../powerlines/src/lib/logger.ts
|
|
10
|
+
const BADGE_COLORS = [
|
|
11
|
+
"#00A0DD",
|
|
12
|
+
"#6FCE4E",
|
|
13
|
+
"#FBBF24",
|
|
14
|
+
"#F43F5E",
|
|
15
|
+
"#3B82F6",
|
|
16
|
+
"#A855F7",
|
|
17
|
+
"#469592",
|
|
18
|
+
"#288EDF",
|
|
19
|
+
"#D8B4FE",
|
|
20
|
+
"#10B981",
|
|
21
|
+
"#EF4444",
|
|
22
|
+
"#F0EC56",
|
|
23
|
+
"#F472B6",
|
|
24
|
+
"#22D3EE",
|
|
25
|
+
"#EAB308",
|
|
26
|
+
"#84CC16",
|
|
27
|
+
"#F87171",
|
|
28
|
+
"#0EA5E9",
|
|
29
|
+
"#D946EF",
|
|
30
|
+
"#FACC15",
|
|
31
|
+
"#34D399",
|
|
32
|
+
"#8B5CF6"
|
|
33
|
+
];
|
|
34
|
+
const extendLog = (logFn, name) => {
|
|
35
|
+
return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { extendLog };
|
|
@@ -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
|
*/
|
|
@@ -361,4 +402,4 @@ interface PluginContext<out TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
361
402
|
}
|
|
362
403
|
type BuildPluginContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig> = UnpluginBuildContext & PluginContext<TResolvedConfig>;
|
|
363
404
|
//#endregion
|
|
364
|
-
export { BuildPluginContext, Context, EmitEntryOptions, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, Resolver, TransformResult$1 as TransformResult, UnresolvedContext };
|
|
405
|
+
export { BuildPluginContext, Context, EmitEntryOptions, EmitOptions, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, Resolver, TransformResult$1 as TransformResult, UnresolvedContext };
|
|
@@ -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
|
*/
|
|
@@ -5,7 +5,7 @@ import { BabelResolvedConfig, EnvironmentResolvedConfig, OutputResolvedConfig, R
|
|
|
5
5
|
import { BasePluginHookFunctions, BuildPlugin, ConfigResult, Plugin, PluginBuildPlugins, PluginHook, PluginHookObject, PluginHooks, TypesResult } from "./plugin.mjs";
|
|
6
6
|
import "./hooks.mjs";
|
|
7
7
|
import { DeepkitOptions, ParsedTypeScriptConfig, RawReflectionMode, ReflectionLevel, ReflectionMode, TSCompilerOptions, TSConfig } from "./tsconfig.mjs";
|
|
8
|
-
import { BuildPluginContext, Context, EmitEntryOptions, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, Resolver, TransformResult, UnresolvedContext } from "./context.mjs";
|
|
8
|
+
import { BuildPluginContext, Context, EmitEntryOptions, EmitOptions, FetchOptions, InitContextOptions, MetaInfo, ParseOptions, PluginContext, Resolver, TransformResult, UnresolvedContext } from "./context.mjs";
|
|
9
9
|
import { BabelUserConfig, BaseConfig, CommonUserConfig, DeployConfig, EnvironmentConfig, InlineConfig, LogFn, OutputConfig, PluginConfig, PluginConfigObject, PluginConfigTuple, PluginFactory, PowerlinesCommand, ProjectType, UserConfig, WorkspaceConfig } from "./config.mjs";
|
|
10
10
|
import { BabelPluginPass, BabelTransformPlugin, BabelTransformPluginBuilder, BabelTransformPluginBuilderParams, BabelTransformPluginFilter, BabelTransformPluginOptions, DeclareBabelTransformPluginReturn, ImportSpecifier, ResolvedBabelTransformPluginOptions } from "./babel.mjs";
|
|
11
11
|
import "./api.mjs";
|
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-babel",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.127",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -155,22 +155,22 @@
|
|
|
155
155
|
"@babel/parser": "^7.28.5",
|
|
156
156
|
"@babel/types": "^7.28.5",
|
|
157
157
|
"@storm-software/config-tools": "^1.188.74",
|
|
158
|
-
"@stryke/fs": "^0.33.
|
|
159
|
-
"@stryke/path": "^0.24.
|
|
160
|
-
"@stryke/type-checks": "^0.5.
|
|
161
|
-
"@stryke/types": "^0.10.
|
|
158
|
+
"@stryke/fs": "^0.33.27",
|
|
159
|
+
"@stryke/path": "^0.24.1",
|
|
160
|
+
"@stryke/type-checks": "^0.5.15",
|
|
161
|
+
"@stryke/types": "^0.10.29",
|
|
162
162
|
"chalk": "5.6.2",
|
|
163
163
|
"defu": "^6.1.4",
|
|
164
164
|
"jiti": "^2.6.1",
|
|
165
|
-
"powerlines": "^0.36.
|
|
165
|
+
"powerlines": "^0.36.23",
|
|
166
166
|
"unplugin": "3.0.0-beta.3"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
169
169
|
"@babel/plugin-syntax-typescript": "^7.27.1",
|
|
170
|
-
"@powerlines/nx": "^0.11.
|
|
171
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
170
|
+
"@powerlines/nx": "^0.11.49",
|
|
171
|
+
"@powerlines/plugin-plugin": "^0.12.70",
|
|
172
172
|
"@types/node": "^24.10.4"
|
|
173
173
|
},
|
|
174
174
|
"publishConfig": { "access": "public" },
|
|
175
|
-
"gitHead": "
|
|
175
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
176
176
|
}
|