@powerlines/plugin-babel 0.12.132 → 0.12.134
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/{chunk-CbDLau6x.cjs → _virtual/rolldown_runtime.cjs} +1 -6
- package/dist/helpers/ast-utils.cjs +34 -3
- package/dist/helpers/ast-utils.d.cts +19 -2
- package/dist/helpers/ast-utils.d.mts +19 -2
- package/dist/helpers/ast-utils.mjs +30 -1
- package/dist/helpers/create-plugin.cjs +40 -2
- package/dist/helpers/create-plugin.d.cts +14 -2
- package/dist/helpers/create-plugin.d.mts +14 -2
- package/dist/helpers/create-plugin.mjs +37 -1
- package/dist/helpers/filters.cjs +58 -5
- package/dist/helpers/filters.d.cts +41 -2
- package/dist/helpers/filters.d.mts +42 -2
- package/dist/helpers/filters.mjs +53 -1
- package/dist/helpers/index.cjs +21 -22
- package/dist/helpers/index.d.cts +5 -7
- package/dist/helpers/index.d.mts +5 -7
- package/dist/helpers/index.mjs +5 -6
- package/dist/helpers/module-helpers.cjs +102 -9
- package/dist/helpers/module-helpers.d.cts +48 -2
- package/dist/helpers/module-helpers.d.mts +48 -2
- package/dist/helpers/module-helpers.mjs +93 -2
- package/dist/helpers/options.cjs +49 -4
- package/dist/helpers/options.d.cts +17 -2
- package/dist/helpers/options.d.mts +17 -2
- package/dist/helpers/options.mjs +45 -2
- package/dist/index.cjs +27 -29
- package/dist/index.d.cts +8 -9
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +6 -8
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +5 -0
- package/dist/powerlines/src/lib/logger.cjs +41 -0
- package/dist/powerlines/src/lib/logger.mjs +39 -0
- package/dist/powerlines/src/types/api.d.mts +5 -0
- package/dist/powerlines/src/types/babel.d.cts +50 -0
- package/dist/powerlines/src/types/babel.d.mts +50 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +145 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +387 -0
- package/dist/powerlines/src/types/config.d.mts +387 -0
- package/dist/powerlines/src/types/context.d.cts +403 -0
- package/dist/powerlines/src/types/context.d.mts +405 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/index.d.mts +12 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/powerlines/src/types/unplugin.d.mts +6 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -3
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +18 -2
- package/dist/types/plugin.d.mts +18 -2
- package/dist/types/plugin.mjs +0 -2
- package/package.json +5 -5
- package/dist/ast-utils-BcmWaIan.cjs +0 -45
- package/dist/ast-utils-Bs6DBkKg.d.mts +0 -19
- package/dist/ast-utils-DU1foCxH.mjs +0 -32
- package/dist/ast-utils-DeuXcuqs.d.cts +0 -19
- package/dist/babel-BBpAODp3.d.cts +0 -1812
- package/dist/babel-Cbfq7l5M.d.mts +0 -1812
- package/dist/create-plugin-BPSvsem_.mjs +0 -73
- package/dist/create-plugin-Bovo30sw.d.cts +0 -14
- package/dist/create-plugin-C9ijark9.d.mts +0 -14
- package/dist/create-plugin-Cs1zZrvI.cjs +0 -80
- package/dist/filters-BKYGMZeC.d.cts +0 -41
- package/dist/filters-BjswEAwZ.d.mts +0 -44
- package/dist/filters-C04cfcQR.mjs +0 -55
- package/dist/filters-Dl2RKvrm.cjs +0 -79
- package/dist/helpers-BnW_4z5h.mjs +0 -1
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/index-ClXLQ1fw.d.mts +0 -1
- package/dist/index-DeEmP3Jc.d.cts +0 -1
- package/dist/index-QbUkWSLh.d.mts +0 -1
- package/dist/index-zO0Ly4bS.d.cts +0 -1
- package/dist/module-helpers-Ckq8sc4l.mjs +0 -95
- package/dist/module-helpers-CrrcOmWC.d.cts +0 -49
- package/dist/module-helpers-Non-jHMu.cjs +0 -138
- package/dist/module-helpers-R1r-1jnQ.d.mts +0 -49
- package/dist/options-BQhc80ih.mjs +0 -47
- package/dist/options-BR6Dzmpl.d.mts +0 -17
- package/dist/options-jLnSoEkN.d.cts +0 -17
- package/dist/options-u2MhTIFH.cjs +0 -60
- package/dist/plugin-BL8TLixo.mjs +0 -1
- package/dist/plugin-BSBH78mm.cjs +0 -0
- package/dist/plugin-CctoTNv_.d.mts +0 -17
- package/dist/plugin-DzY_qzHo.d.cts +0 -17
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CvhspRRt.mjs +0 -1
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { declare } from "@babel/helper-plugin-utils";
|
|
4
|
-
import "@storm-software/config-tools/logger";
|
|
5
|
-
import "@storm-software/config-tools/utilities/colors";
|
|
6
|
-
import "@stryke/helpers/noop";
|
|
7
|
-
import "@stryke/string-format/kebab-case";
|
|
8
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
9
|
-
|
|
10
|
-
//#region ../powerlines/src/lib/logger.ts
|
|
11
|
-
const BADGE_COLORS = [
|
|
12
|
-
"#00A0DD",
|
|
13
|
-
"#6FCE4E",
|
|
14
|
-
"#FBBF24",
|
|
15
|
-
"#F43F5E",
|
|
16
|
-
"#3B82F6",
|
|
17
|
-
"#A855F7",
|
|
18
|
-
"#469592",
|
|
19
|
-
"#288EDF",
|
|
20
|
-
"#D8B4FE",
|
|
21
|
-
"#10B981",
|
|
22
|
-
"#EF4444",
|
|
23
|
-
"#F0EC56",
|
|
24
|
-
"#F472B6",
|
|
25
|
-
"#22D3EE",
|
|
26
|
-
"#EAB308",
|
|
27
|
-
"#84CC16",
|
|
28
|
-
"#F87171",
|
|
29
|
-
"#0EA5E9",
|
|
30
|
-
"#D946EF",
|
|
31
|
-
"#FACC15",
|
|
32
|
-
"#34D399",
|
|
33
|
-
"#8B5CF6"
|
|
34
|
-
];
|
|
35
|
-
const extendLog = (logFn, name) => {
|
|
36
|
-
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(" ")} `);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/helpers/create-plugin.ts
|
|
41
|
-
/**
|
|
42
|
-
* Create a Babel plugin using the provided builder function.
|
|
43
|
-
*
|
|
44
|
-
* @param name - The name of the plugin.
|
|
45
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
46
|
-
* @returns A Babel plugin declaration.
|
|
47
|
-
*/
|
|
48
|
-
function createBabelPlugin(name, builder) {
|
|
49
|
-
const plugin = (context) => {
|
|
50
|
-
return declare((api, options, dirname) => {
|
|
51
|
-
api.cache.using(() => context.meta.checksum);
|
|
52
|
-
api.assertVersion("^7.0.0-0");
|
|
53
|
-
const log = extendLog(context.log, name);
|
|
54
|
-
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
55
|
-
const result = builder({
|
|
56
|
-
log,
|
|
57
|
-
name,
|
|
58
|
-
api,
|
|
59
|
-
options,
|
|
60
|
-
context,
|
|
61
|
-
dirname
|
|
62
|
-
});
|
|
63
|
-
result.name = name;
|
|
64
|
-
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
65
|
-
return result;
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
plugin.$$name = name;
|
|
69
|
-
return plugin;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
export { createBabelPlugin as t };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { a as DeclareBabelTransformPluginReturn, n as BabelTransformPluginBuilder, u as Context } from "./babel-BBpAODp3.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/create-plugin.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create a Babel plugin using the provided builder function.
|
|
7
|
-
*
|
|
8
|
-
* @param name - The name of the plugin.
|
|
9
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
-
* @returns A Babel plugin declaration.
|
|
11
|
-
*/
|
|
12
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { createBabelPlugin as t };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { a as DeclareBabelTransformPluginReturn, n as BabelTransformPluginBuilder, u as Context } from "./babel-Cbfq7l5M.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/create-plugin.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Create a Babel plugin using the provided builder function.
|
|
7
|
-
*
|
|
8
|
-
* @param name - The name of the plugin.
|
|
9
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
-
* @returns A Babel plugin declaration.
|
|
11
|
-
*/
|
|
12
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { createBabelPlugin as t };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
-
let chalk = require("chalk");
|
|
4
|
-
chalk = require_chunk.__toESM(chalk);
|
|
5
|
-
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
6
|
-
require("@storm-software/config-tools/logger");
|
|
7
|
-
require("@storm-software/config-tools/utilities/colors");
|
|
8
|
-
require("@stryke/helpers/noop");
|
|
9
|
-
require("@stryke/string-format/kebab-case");
|
|
10
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
11
|
-
|
|
12
|
-
//#region ../powerlines/src/lib/logger.ts
|
|
13
|
-
const BADGE_COLORS = [
|
|
14
|
-
"#00A0DD",
|
|
15
|
-
"#6FCE4E",
|
|
16
|
-
"#FBBF24",
|
|
17
|
-
"#F43F5E",
|
|
18
|
-
"#3B82F6",
|
|
19
|
-
"#A855F7",
|
|
20
|
-
"#469592",
|
|
21
|
-
"#288EDF",
|
|
22
|
-
"#D8B4FE",
|
|
23
|
-
"#10B981",
|
|
24
|
-
"#EF4444",
|
|
25
|
-
"#F0EC56",
|
|
26
|
-
"#F472B6",
|
|
27
|
-
"#22D3EE",
|
|
28
|
-
"#EAB308",
|
|
29
|
-
"#84CC16",
|
|
30
|
-
"#F87171",
|
|
31
|
-
"#0EA5E9",
|
|
32
|
-
"#D946EF",
|
|
33
|
-
"#FACC15",
|
|
34
|
-
"#34D399",
|
|
35
|
-
"#8B5CF6"
|
|
36
|
-
];
|
|
37
|
-
const extendLog = (logFn, name) => {
|
|
38
|
-
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(" ")} `);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/helpers/create-plugin.ts
|
|
43
|
-
/**
|
|
44
|
-
* Create a Babel plugin using the provided builder function.
|
|
45
|
-
*
|
|
46
|
-
* @param name - The name of the plugin.
|
|
47
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
48
|
-
* @returns A Babel plugin declaration.
|
|
49
|
-
*/
|
|
50
|
-
function createBabelPlugin(name, builder) {
|
|
51
|
-
const plugin = (context) => {
|
|
52
|
-
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
53
|
-
api.cache.using(() => context.meta.checksum);
|
|
54
|
-
api.assertVersion("^7.0.0-0");
|
|
55
|
-
const log = extendLog(context.log, name);
|
|
56
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
57
|
-
const result = builder({
|
|
58
|
-
log,
|
|
59
|
-
name,
|
|
60
|
-
api,
|
|
61
|
-
options,
|
|
62
|
-
context,
|
|
63
|
-
dirname
|
|
64
|
-
});
|
|
65
|
-
result.name = name;
|
|
66
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
67
|
-
return result;
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
plugin.$$name = name;
|
|
71
|
-
return plugin;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
Object.defineProperty(exports, 'createBabelPlugin', {
|
|
76
|
-
enumerable: true,
|
|
77
|
-
get: function () {
|
|
78
|
-
return createBabelPlugin;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { i as BabelTransformPluginOptions, r as BabelTransformPluginFilter, s as ResolvedBabelTransformPluginOptions, t as BabelTransformPlugin, u as Context } from "./babel-BBpAODp3.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/helpers/filters.d.ts
|
|
4
|
-
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
7
|
-
*
|
|
8
|
-
* @param plugins - The list of existing Babel plugins.
|
|
9
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
10
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Filters a Babel plugin by its runtime ID.
|
|
15
|
-
*
|
|
16
|
-
* @param context - The context in which the filter is applied.
|
|
17
|
-
* @param fileId - The file ID to filter by.
|
|
18
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
19
|
-
*/
|
|
20
|
-
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
21
|
-
/**
|
|
22
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
23
|
-
*
|
|
24
|
-
* @param context - The context in which the plugin is being added.
|
|
25
|
-
* @param plugins - The Babel plugins to add the filter to.
|
|
26
|
-
* @param filter - The filter function to apply to the plugins.
|
|
27
|
-
* @param name - The name of the plugin to add the filter to.
|
|
28
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
29
|
-
*/
|
|
30
|
-
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
31
|
-
/**
|
|
32
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
33
|
-
*
|
|
34
|
-
* @param context - The context in which the plugin is being added.
|
|
35
|
-
* @param plugin - The Babel plugin to add the filter to.
|
|
36
|
-
* @param filter - The filter function to apply to the plugin.
|
|
37
|
-
* @returns The updated Babel plugin with the filter applied.
|
|
38
|
-
*/
|
|
39
|
-
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { i as BabelTransformPluginOptions, r as BabelTransformPluginFilter, s as ResolvedBabelTransformPluginOptions, t as BabelTransformPlugin, u as Context } from "./babel-Cbfq7l5M.mjs";
|
|
2
|
-
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
-
import { UnpluginOptions } from "unplugin";
|
|
4
|
-
import { ArrayValues } from "@stryke/types/array";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/filters.d.ts
|
|
7
|
-
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
10
|
-
*
|
|
11
|
-
* @param plugins - The list of existing Babel plugins.
|
|
12
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
13
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
14
|
-
*/
|
|
15
|
-
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Filters a Babel plugin by its runtime ID.
|
|
18
|
-
*
|
|
19
|
-
* @param context - The context in which the filter is applied.
|
|
20
|
-
* @param fileId - The file ID to filter by.
|
|
21
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
22
|
-
*/
|
|
23
|
-
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
24
|
-
/**
|
|
25
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
26
|
-
*
|
|
27
|
-
* @param context - The context in which the plugin is being added.
|
|
28
|
-
* @param plugins - The Babel plugins to add the filter to.
|
|
29
|
-
* @param filter - The filter function to apply to the plugins.
|
|
30
|
-
* @param name - The name of the plugin to add the filter to.
|
|
31
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
32
|
-
*/
|
|
33
|
-
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
34
|
-
/**
|
|
35
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
36
|
-
*
|
|
37
|
-
* @param context - The context in which the plugin is being added.
|
|
38
|
-
* @param plugin - The Babel plugin to add the filter to.
|
|
39
|
-
* @param filter - The filter function to apply to the plugin.
|
|
40
|
-
* @returns The updated Babel plugin with the filter applied.
|
|
41
|
-
*/
|
|
42
|
-
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
43
|
-
//#endregion
|
|
44
|
-
export { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -1,55 +0,0 @@
|
|
|
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 { isDuplicatePlugin as i, filterPluginByFileId as n, getPluginName as r, addPluginFilter as t };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.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
|
-
Object.defineProperty(exports, 'addPluginFilter', {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return addPluginFilter;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, 'filterPluginByFileId', {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return filterPluginByFileId;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, 'getPluginName', {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return getPluginName;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, 'isDuplicatePlugin', {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return isDuplicatePlugin;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { n as parseAst } from "./ast-utils-DU1foCxH.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 { isImportCall as a, getImport as i, addImportsToProgram as n, listExports as o, findExport as r, listImports as s, addImport as t };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { o as ImportSpecifier } from "./babel-BBpAODp3.cjs";
|
|
2
|
-
import { ParseResult } from "@babel/parser";
|
|
3
|
-
import * as t from "@babel/types";
|
|
4
|
-
import { NodePath } from "@babel/core";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/module-helpers.d.ts
|
|
7
|
-
|
|
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
|
-
declare function findExport(ast: ParseResult<t.File>, key: string): any;
|
|
16
|
-
/**
|
|
17
|
-
* Lists all exports from the given Babel AST program.
|
|
18
|
-
*
|
|
19
|
-
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
20
|
-
* @returns An array of export names, including "default" for default exports.
|
|
21
|
-
*/
|
|
22
|
-
declare function listExports(codeOrAst: ParseResult<t.File> | string): string[];
|
|
23
|
-
/**
|
|
24
|
-
* Lists all imports from the given Babel AST program.
|
|
25
|
-
*
|
|
26
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
27
|
-
* @returns An array of import names, including "default" for default imports.
|
|
28
|
-
*/
|
|
29
|
-
declare function listImports(ast: ParseResult<t.File> | t.File): string[];
|
|
30
|
-
declare function isImportCall(calleePath: NodePath<t.CallExpression | t.NewExpression>): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Gets the import declaration for a given name and specifier.
|
|
33
|
-
*
|
|
34
|
-
* @param specifier - The specifier of the import.
|
|
35
|
-
* @param name - The name of the import.
|
|
36
|
-
* @param named - Optional named import.
|
|
37
|
-
* @returns The import declaration.
|
|
38
|
-
*/
|
|
39
|
-
declare function getImport(specifier: string, name: string, named?: string): t.ImportDeclaration;
|
|
40
|
-
/**
|
|
41
|
-
* Adds an import to the program if it doesn't already exist.
|
|
42
|
-
*
|
|
43
|
-
* @param path - The current NodePath in the AST.
|
|
44
|
-
* @param specifier - The import specifier.
|
|
45
|
-
*/
|
|
46
|
-
declare function addImport(path: NodePath<any>, specifier: ImportSpecifier): void;
|
|
47
|
-
declare function addImportsToProgram(path: NodePath<t.Program>, specifier: ImportSpecifier): void;
|
|
48
|
-
//#endregion
|
|
49
|
-
export { isImportCall as a, getImport as i, addImportsToProgram as n, listExports as o, findExport as r, listImports as s, addImport as t };
|