@powerlines/plugin-babel 0.12.424 → 0.12.425
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/package.json +3 -3
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/helpers/ast-utils.cjs +0 -35
- package/dist/helpers/ast-utils.d.cts +0 -19
- package/dist/helpers/ast-utils.d.cts.map +0 -1
- package/dist/helpers/ast-utils.d.mts +0 -19
- package/dist/helpers/ast-utils.d.mts.map +0 -1
- package/dist/helpers/ast-utils.mjs +0 -32
- package/dist/helpers/ast-utils.mjs.map +0 -1
- package/dist/helpers/create-plugin.cjs +0 -42
- package/dist/helpers/create-plugin.d.cts +0 -15
- package/dist/helpers/create-plugin.d.cts.map +0 -1
- package/dist/helpers/create-plugin.d.mts +0 -15
- package/dist/helpers/create-plugin.d.mts.map +0 -1
- package/dist/helpers/create-plugin.mjs +0 -40
- package/dist/helpers/create-plugin.mjs.map +0 -1
- package/dist/helpers/filters.cjs +0 -74
- package/dist/helpers/filters.d.cts +0 -51
- package/dist/helpers/filters.d.cts.map +0 -1
- package/dist/helpers/filters.d.mts +0 -51
- package/dist/helpers/filters.d.mts.map +0 -1
- package/dist/helpers/filters.mjs +0 -69
- package/dist/helpers/filters.mjs.map +0 -1
- package/dist/helpers/index.cjs +0 -28
- package/dist/helpers/index.d.cts +0 -6
- package/dist/helpers/index.d.mts +0 -6
- package/dist/helpers/index.mjs +0 -7
- package/dist/helpers/module-helpers.cjs +0 -104
- package/dist/helpers/module-helpers.d.cts +0 -49
- package/dist/helpers/module-helpers.d.cts.map +0 -1
- package/dist/helpers/module-helpers.d.mts +0 -49
- package/dist/helpers/module-helpers.d.mts.map +0 -1
- package/dist/helpers/module-helpers.mjs +0 -96
- package/dist/helpers/module-helpers.mjs.map +0 -1
- package/dist/helpers/options.cjs +0 -116
- package/dist/helpers/options.d.cts +0 -44
- package/dist/helpers/options.d.cts.map +0 -1
- package/dist/helpers/options.d.mts +0 -44
- package/dist/helpers/options.d.mts.map +0 -1
- package/dist/helpers/options.mjs +0 -109
- package/dist/helpers/options.mjs.map +0 -1
- package/dist/index.cjs +0 -126
- package/dist/index.d.cts +0 -25
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -25
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -102
- package/dist/index.mjs.map +0 -1
- package/dist/types/config.cjs +0 -0
- package/dist/types/config.d.cts +0 -100
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts +0 -100
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs +0 -1
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +0 -3
- package/dist/types/index.d.mts +0 -3
- package/dist/types/index.mjs +0 -1
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +0 -23
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts +0 -23
- package/dist/types/plugin.d.mts.map +0 -1
- package/dist/types/plugin.mjs +0 -1
package/dist/helpers/index.d.mts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.mjs";
|
|
2
|
-
import { createBabelPlugin } from "./create-plugin.mjs";
|
|
3
|
-
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin, isDuplicatePreset } from "./filters.mjs";
|
|
4
|
-
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.mjs";
|
|
5
|
-
import { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction } from "./options.mjs";
|
|
6
|
-
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, getUniquePlugins, getUniquePresets, isDuplicatePlugin, isDuplicatePreset, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction };
|
package/dist/helpers/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin, isDuplicatePreset } from "./filters.mjs";
|
|
2
|
-
import { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction } 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, getUniquePlugins, getUniquePresets, isDuplicatePlugin, isDuplicatePreset, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction };
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
4
|
-
let _babel_types = require("@babel/types");
|
|
5
|
-
_babel_types = require_runtime.__toESM(_babel_types, 1);
|
|
6
|
-
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
7
|
-
|
|
8
|
-
//#region src/helpers/module-helpers.ts
|
|
9
|
-
/**
|
|
10
|
-
* Finds an export in the given Babel AST program by its key.
|
|
11
|
-
*
|
|
12
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
13
|
-
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
14
|
-
* @returns The declaration of the export if found, otherwise undefined.
|
|
15
|
-
*/
|
|
16
|
-
function findExport(ast, key) {
|
|
17
|
-
const type = key === "default" ? "ExportDefaultDeclaration" : "ExportNamedDeclaration";
|
|
18
|
-
for (const node of ast.program.body) if (node.type === type) {
|
|
19
|
-
if (key === "default") return node.declaration;
|
|
20
|
-
if (node.declaration && "declarations" in node.declaration) {
|
|
21
|
-
const declaration = node.declaration.declarations[0];
|
|
22
|
-
if (declaration && "name" in declaration.id && declaration.id.name === key) return declaration.init;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Lists all exports from the given Babel AST program.
|
|
28
|
-
*
|
|
29
|
-
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
30
|
-
* @returns An array of export names, including "default" for default exports.
|
|
31
|
-
*/
|
|
32
|
-
function listExports(codeOrAst) {
|
|
33
|
-
return ((0, _stryke_type_checks_is_string.isString)(codeOrAst) ? require_helpers_ast_utils.parseAst(codeOrAst) : codeOrAst).program.body.flatMap((i) => {
|
|
34
|
-
if (i.type === "ExportDefaultDeclaration") return ["default"];
|
|
35
|
-
if (i.type === "ExportNamedDeclaration" && i.declaration && "declarations" in i.declaration) return i.declaration.declarations.map((d) => "name" in d.id ? d.id.name : "");
|
|
36
|
-
return [];
|
|
37
|
-
}).filter(Boolean);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Lists all imports from the given Babel AST program.
|
|
41
|
-
*
|
|
42
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
43
|
-
* @returns An array of import names, including "default" for default imports.
|
|
44
|
-
*/
|
|
45
|
-
function listImports(ast) {
|
|
46
|
-
return ast.program.body.flatMap((i) => {
|
|
47
|
-
if (i.type === "ImportDeclaration") return i.specifiers.map((s) => {
|
|
48
|
-
if (s.type === "ImportDefaultSpecifier") return "default";
|
|
49
|
-
if (s.type === "ImportSpecifier" && "imported" in s) return s.imported.type === "Identifier" ? s.imported.name : s.imported.value;
|
|
50
|
-
return "";
|
|
51
|
-
});
|
|
52
|
-
return [];
|
|
53
|
-
}).filter(Boolean);
|
|
54
|
-
}
|
|
55
|
-
function isImportCall(calleePath) {
|
|
56
|
-
return _babel_types.isImport(calleePath.node.callee);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Gets the import declaration for a given name and specifier.
|
|
60
|
-
*
|
|
61
|
-
* @param specifier - The specifier of the import.
|
|
62
|
-
* @param name - The name of the import.
|
|
63
|
-
* @param named - Optional named import.
|
|
64
|
-
* @returns The import declaration.
|
|
65
|
-
*/
|
|
66
|
-
function getImport(specifier, name, named) {
|
|
67
|
-
return _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.stringLiteral(named || name))], _babel_types.stringLiteral(specifier));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Adds an import to the program if it doesn't already exist.
|
|
71
|
-
*
|
|
72
|
-
* @param path - The current NodePath in the AST.
|
|
73
|
-
* @param specifier - The import specifier.
|
|
74
|
-
*/
|
|
75
|
-
function addImport(path, specifier) {
|
|
76
|
-
addImportsToProgram(path.scope.getProgramParent().path, specifier);
|
|
77
|
-
}
|
|
78
|
-
function isNonNamespacedImport(importDeclPath) {
|
|
79
|
-
return importDeclPath.get("specifiers").filter(Boolean).every((specifier) => specifier?.isImportSpecifier()) && importDeclPath.node.importKind !== "type" && importDeclPath.node.importKind !== "typeof";
|
|
80
|
-
}
|
|
81
|
-
function getExistingImports(program) {
|
|
82
|
-
const existingImports = /* @__PURE__ */ new Map();
|
|
83
|
-
program.traverse({ ImportDeclaration(path) {
|
|
84
|
-
if (isNonNamespacedImport(path)) existingImports.set(path.node.source.value, path);
|
|
85
|
-
} });
|
|
86
|
-
return existingImports;
|
|
87
|
-
}
|
|
88
|
-
function addImportsToProgram(path, specifier) {
|
|
89
|
-
/**
|
|
90
|
-
* If an existing import of this module exists (ie \`import \{ ... \} from
|
|
91
|
-
* '<moduleName>'\`), inject new imported specifiers into the list of
|
|
92
|
-
* destructured variables.
|
|
93
|
-
*/
|
|
94
|
-
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)));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
exports.addImport = addImport;
|
|
99
|
-
exports.addImportsToProgram = addImportsToProgram;
|
|
100
|
-
exports.findExport = findExport;
|
|
101
|
-
exports.getImport = getImport;
|
|
102
|
-
exports.isImportCall = isImportCall;
|
|
103
|
-
exports.listExports = listExports;
|
|
104
|
-
exports.listImports = listImports;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ImportSpecifier } from "../types/config.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
|
-
* Finds an export in the given Babel AST program by its key.
|
|
9
|
-
*
|
|
10
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
11
|
-
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
12
|
-
* @returns The declaration of the export if found, otherwise undefined.
|
|
13
|
-
*/
|
|
14
|
-
declare function findExport(ast: ParseResult<t.File>, key: string): any;
|
|
15
|
-
/**
|
|
16
|
-
* Lists all exports from the given Babel AST program.
|
|
17
|
-
*
|
|
18
|
-
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
19
|
-
* @returns An array of export names, including "default" for default exports.
|
|
20
|
-
*/
|
|
21
|
-
declare function listExports(codeOrAst: ParseResult<t.File> | string): string[];
|
|
22
|
-
/**
|
|
23
|
-
* Lists all imports from the given Babel AST program.
|
|
24
|
-
*
|
|
25
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
26
|
-
* @returns An array of import names, including "default" for default imports.
|
|
27
|
-
*/
|
|
28
|
-
declare function listImports(ast: ParseResult<t.File> | t.File): string[];
|
|
29
|
-
declare function isImportCall(calleePath: NodePath<t.CallExpression | t.NewExpression>): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Gets the import declaration for a given name and specifier.
|
|
32
|
-
*
|
|
33
|
-
* @param specifier - The specifier of the import.
|
|
34
|
-
* @param name - The name of the import.
|
|
35
|
-
* @param named - Optional named import.
|
|
36
|
-
* @returns The import declaration.
|
|
37
|
-
*/
|
|
38
|
-
declare function getImport(specifier: string, name: string, named?: string): t.ImportDeclaration;
|
|
39
|
-
/**
|
|
40
|
-
* Adds an import to the program if it doesn't already exist.
|
|
41
|
-
*
|
|
42
|
-
* @param path - The current NodePath in the AST.
|
|
43
|
-
* @param specifier - The import specifier.
|
|
44
|
-
*/
|
|
45
|
-
declare function addImport(path: NodePath<any>, specifier: ImportSpecifier): void;
|
|
46
|
-
declare function addImportsToProgram(path: NodePath<t.Program>, specifier: ImportSpecifier): void;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
49
|
-
//# sourceMappingURL=module-helpers.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-helpers.d.cts","names":[],"sources":["../../src/helpers/module-helpers.ts"],"mappings":";;;;;;;;AAgCA;;;;;iBAAgB,UAAA,CAAW,GAAA,EAAK,WAAA,CAAY,CAAA,CAAE,IAAA,GAAO,GAAA;;;;;;AA6BrD;iBAAgB,WAAA,CAAY,SAAA,EAAW,WAAA,CAAY,CAAA,CAAE,IAAA;;;;;;;iBA4BrC,WAAA,CAAY,GAAA,EAAK,WAAA,CAAY,CAAA,CAAE,IAAA,IAAQ,CAAA,CAAE,IAAA;AAAA,iBAsBzC,YAAA,CACd,UAAA,EAAY,QAAA,CAAS,CAAA,CAAE,cAAA,GAAiB,CAAA,CAAE,aAAA;AAvB5C;;;;;;;;AAAA,iBAoCgB,SAAA,CACd,SAAA,UACA,IAAA,UACA,KAAA,YACC,CAAA,CAAE,iBAAA;;;;;;;iBAaW,SAAA,CAAU,IAAA,EAAM,QAAA,OAAe,SAAA,EAAW,eAAA;AAAA,iBAuC1C,mBAAA,CACd,IAAA,EAAM,QAAA,CAAS,CAAA,CAAE,OAAA,GACjB,SAAA,EAAW,eAAA"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ImportSpecifier } from "../types/config.mjs";
|
|
2
|
-
import { NodePath } from "@babel/core";
|
|
3
|
-
import { ParseResult } from "@babel/parser";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/module-helpers.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Finds an export in the given Babel AST program by its key.
|
|
9
|
-
*
|
|
10
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
11
|
-
* @param key - The name of the export to find (e.g., "default" or a named export).
|
|
12
|
-
* @returns The declaration of the export if found, otherwise undefined.
|
|
13
|
-
*/
|
|
14
|
-
declare function findExport(ast: ParseResult<t.File>, key: string): any;
|
|
15
|
-
/**
|
|
16
|
-
* Lists all exports from the given Babel AST program.
|
|
17
|
-
*
|
|
18
|
-
* @param codeOrAst - The parsed Babel AST result containing the program body.
|
|
19
|
-
* @returns An array of export names, including "default" for default exports.
|
|
20
|
-
*/
|
|
21
|
-
declare function listExports(codeOrAst: ParseResult<t.File> | string): string[];
|
|
22
|
-
/**
|
|
23
|
-
* Lists all imports from the given Babel AST program.
|
|
24
|
-
*
|
|
25
|
-
* @param ast - The parsed Babel AST result containing the program body.
|
|
26
|
-
* @returns An array of import names, including "default" for default imports.
|
|
27
|
-
*/
|
|
28
|
-
declare function listImports(ast: ParseResult<t.File> | t.File): string[];
|
|
29
|
-
declare function isImportCall(calleePath: NodePath<t.CallExpression | t.NewExpression>): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Gets the import declaration for a given name and specifier.
|
|
32
|
-
*
|
|
33
|
-
* @param specifier - The specifier of the import.
|
|
34
|
-
* @param name - The name of the import.
|
|
35
|
-
* @param named - Optional named import.
|
|
36
|
-
* @returns The import declaration.
|
|
37
|
-
*/
|
|
38
|
-
declare function getImport(specifier: string, name: string, named?: string): t.ImportDeclaration;
|
|
39
|
-
/**
|
|
40
|
-
* Adds an import to the program if it doesn't already exist.
|
|
41
|
-
*
|
|
42
|
-
* @param path - The current NodePath in the AST.
|
|
43
|
-
* @param specifier - The import specifier.
|
|
44
|
-
*/
|
|
45
|
-
declare function addImport(path: NodePath<any>, specifier: ImportSpecifier): void;
|
|
46
|
-
declare function addImportsToProgram(path: NodePath<t.Program>, specifier: ImportSpecifier): void;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
49
|
-
//# sourceMappingURL=module-helpers.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-helpers.d.mts","names":[],"sources":["../../src/helpers/module-helpers.ts"],"mappings":";;;;;;;;AAgCA;;;;;iBAAgB,UAAA,CAAW,GAAA,EAAK,WAAA,CAAY,CAAA,CAAE,IAAA,GAAO,GAAA;;;;;;AA6BrD;iBAAgB,WAAA,CAAY,SAAA,EAAW,WAAA,CAAY,CAAA,CAAE,IAAA;;;;;;;iBA4BrC,WAAA,CAAY,GAAA,EAAK,WAAA,CAAY,CAAA,CAAE,IAAA,IAAQ,CAAA,CAAE,IAAA;AAAA,iBAsBzC,YAAA,CACd,UAAA,EAAY,QAAA,CAAS,CAAA,CAAE,cAAA,GAAiB,CAAA,CAAE,aAAA;AAvB5C;;;;;;;;AAAA,iBAoCgB,SAAA,CACd,SAAA,UACA,IAAA,UACA,KAAA,YACC,CAAA,CAAE,iBAAA;;;;;;;iBAaW,SAAA,CAAU,IAAA,EAAM,QAAA,OAAe,SAAA,EAAW,eAAA;AAAA,iBAuC1C,mBAAA,CACd,IAAA,EAAM,QAAA,CAAS,CAAA,CAAE,OAAA,GACjB,SAAA,EAAW,eAAA"}
|
|
@@ -1,96 +0,0 @@
|
|
|
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 };
|
|
96
|
-
//# sourceMappingURL=module-helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-helpers.mjs","names":[],"sources":["../../src/helpers/module-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport { ParseResult } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ImportSpecifier } from \"../types/config\";\nimport { parseAst } from \"./ast-utils\";\n\n/**\n * Finds an export in the given Babel AST program by its key.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @param key - The name of the export to find (e.g., \"default\" or a named export).\n * @returns The declaration of the export if found, otherwise undefined.\n */\nexport function findExport(ast: ParseResult<t.File>, key: string) {\n const type =\n key === \"default\" ? \"ExportDefaultDeclaration\" : \"ExportNamedDeclaration\";\n\n for (const node of ast.program.body) {\n if (node.type === type) {\n if (key === \"default\") {\n return node.declaration;\n }\n if (node.declaration && \"declarations\" in node.declaration) {\n const declaration = node.declaration.declarations[0];\n if (\n declaration &&\n \"name\" in declaration.id &&\n declaration.id.name === key\n ) {\n return declaration.init as any;\n }\n }\n }\n }\n}\n\n/**\n * Lists all exports from the given Babel AST program.\n *\n * @param codeOrAst - The parsed Babel AST result containing the program body.\n * @returns An array of export names, including \"default\" for default exports.\n */\nexport function listExports(codeOrAst: ParseResult<t.File> | string) {\n const ast = isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst;\n\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ExportDefaultDeclaration\") {\n return [\"default\"];\n }\n if (\n i.type === \"ExportNamedDeclaration\" &&\n i.declaration &&\n \"declarations\" in i.declaration\n ) {\n return i.declaration.declarations.map(d =>\n \"name\" in d.id ? d.id.name : \"\"\n );\n }\n return [];\n })\n .filter(Boolean);\n}\n\n/**\n * Lists all imports from the given Babel AST program.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @returns An array of import names, including \"default\" for default imports.\n */\nexport function listImports(ast: ParseResult<t.File> | t.File) {\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ImportDeclaration\") {\n return i.specifiers.map(s => {\n if (s.type === \"ImportDefaultSpecifier\") {\n return \"default\";\n }\n if (s.type === \"ImportSpecifier\" && \"imported\" in s) {\n return s.imported.type === \"Identifier\"\n ? s.imported.name\n : s.imported.value;\n }\n return \"\";\n });\n }\n\n return [];\n })\n .filter(Boolean);\n}\n\nexport function isImportCall(\n calleePath: NodePath<t.CallExpression | t.NewExpression>\n) {\n return t.isImport(calleePath.node.callee);\n}\n\n/**\n * Gets the import declaration for a given name and specifier.\n *\n * @param specifier - The specifier of the import.\n * @param name - The name of the import.\n * @param named - Optional named import.\n * @returns The import declaration.\n */\nexport function getImport(\n specifier: string,\n name: string,\n named?: string\n): t.ImportDeclaration {\n return t.importDeclaration(\n [t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))],\n t.stringLiteral(specifier)\n );\n}\n\n/**\n * Adds an import to the program if it doesn't already exist.\n *\n * @param path - The current NodePath in the AST.\n * @param specifier - The import specifier.\n */\nexport function addImport(path: NodePath<any>, specifier: ImportSpecifier) {\n addImportsToProgram(\n path.scope.getProgramParent().path as NodePath<t.Program>,\n specifier\n );\n}\n\n/*\n * Matches `import { ... } from <moduleName>;`\n * but not `import * as React from <moduleName>;`\n * `import type { Foo } from <moduleName>;`\n */\nfunction isNonNamespacedImport(\n importDeclPath: NodePath<t.ImportDeclaration>\n): boolean {\n return (\n importDeclPath\n .get(\"specifiers\")\n .filter(Boolean)\n .every(specifier => specifier?.isImportSpecifier()) &&\n importDeclPath.node.importKind !== \"type\" &&\n importDeclPath.node.importKind !== \"typeof\"\n );\n}\n\nfunction getExistingImports(\n program: NodePath<t.Program>\n): Map<string, NodePath<t.ImportDeclaration>> {\n const existingImports = new Map<string, NodePath<t.ImportDeclaration>>();\n program.traverse({\n ImportDeclaration(path) {\n if (isNonNamespacedImport(path)) {\n existingImports.set(path.node.source.value, path);\n }\n }\n });\n return existingImports;\n}\n\nexport function addImportsToProgram(\n path: NodePath<t.Program>,\n specifier: ImportSpecifier\n): void {\n const existingImports = getExistingImports(path);\n\n /**\n * If an existing import of this module exists (ie \\`import \\{ ... \\} from\n * '<moduleName>'\\`), inject new imported specifiers into the list of\n * destructured variables.\n */\n if (!existingImports.get(specifier.module)) {\n path.unshiftContainer(\n \"body\",\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(specifier.name || specifier.imported),\n t.identifier(specifier.imported)\n )\n ],\n t.stringLiteral(specifier.module)\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,WAAW,KAA0B,KAAa;CAChE,MAAM,OACJ,QAAQ,YAAY,6BAA6B;AAEnD,MAAK,MAAM,QAAQ,IAAI,QAAQ,KAC7B,KAAI,KAAK,SAAS,MAAM;AACtB,MAAI,QAAQ,UACV,QAAO,KAAK;AAEd,MAAI,KAAK,eAAe,kBAAkB,KAAK,aAAa;GAC1D,MAAM,cAAc,KAAK,YAAY,aAAa;AAClD,OACE,eACA,UAAU,YAAY,MACtB,YAAY,GAAG,SAAS,IAExB,QAAO,YAAY;;;;;;;;;;AAa7B,SAAgB,YAAY,WAAyC;AAGnE,SAFY,SAAS,UAAU,GAAG,SAAS,UAAU,GAAG,WAE7C,QAAQ,KAChB,SAAQ,MAAK;AACZ,MAAI,EAAE,SAAS,2BACb,QAAO,CAAC,UAAU;AAEpB,MACE,EAAE,SAAS,4BACX,EAAE,eACF,kBAAkB,EAAE,YAEpB,QAAO,EAAE,YAAY,aAAa,KAAI,MACpC,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,GAC9B;AAEH,SAAO,EAAE;GACT,CACD,OAAO,QAAQ;;;;;;;;AASpB,SAAgB,YAAY,KAAmC;AAC7D,QAAO,IAAI,QAAQ,KAChB,SAAQ,MAAK;AACZ,MAAI,EAAE,SAAS,oBACb,QAAO,EAAE,WAAW,KAAI,MAAK;AAC3B,OAAI,EAAE,SAAS,yBACb,QAAO;AAET,OAAI,EAAE,SAAS,qBAAqB,cAAc,EAChD,QAAO,EAAE,SAAS,SAAS,eACvB,EAAE,SAAS,OACX,EAAE,SAAS;AAEjB,UAAO;IACP;AAGJ,SAAO,EAAE;GACT,CACD,OAAO,QAAQ;;AAGpB,SAAgB,aACd,YACA;AACA,QAAO,EAAE,SAAS,WAAW,KAAK,OAAO;;;;;;;;;;AAW3C,SAAgB,UACd,WACA,MACA,OACqB;AACrB,QAAO,EAAE,kBACP,CAAC,EAAE,gBAAgB,EAAE,WAAW,KAAK,EAAE,EAAE,cAAc,SAAS,KAAK,CAAC,CAAC,EACvE,EAAE,cAAc,UAAU,CAC3B;;;;;;;;AASH,SAAgB,UAAU,MAAqB,WAA4B;AACzE,qBACE,KAAK,MAAM,kBAAkB,CAAC,MAC9B,UACD;;AAQH,SAAS,sBACP,gBACS;AACT,QACE,eACG,IAAI,aAAa,CACjB,OAAO,QAAQ,CACf,OAAM,cAAa,WAAW,mBAAmB,CAAC,IACrD,eAAe,KAAK,eAAe,UACnC,eAAe,KAAK,eAAe;;AAIvC,SAAS,mBACP,SAC4C;CAC5C,MAAM,kCAAkB,IAAI,KAA4C;AACxE,SAAQ,SAAS,EACf,kBAAkB,MAAM;AACtB,MAAI,sBAAsB,KAAK,CAC7B,iBAAgB,IAAI,KAAK,KAAK,OAAO,OAAO,KAAK;IAGtD,CAAC;AACF,QAAO;;AAGT,SAAgB,oBACd,MACA,WACM;;;;;;AAQN,KAAI,CAPoB,mBAAmB,KAOvB,CAAC,IAAI,UAAU,OAAO,CACxC,MAAK,iBACH,QACA,EAAE,kBACA,CACE,EAAE,gBACA,EAAE,WAAW,UAAU,QAAQ,UAAU,SAAS,EAClD,EAAE,WAAW,UAAU,SAAS,CACjC,CACF,EACD,EAAE,cAAc,UAAU,OAAO,CAClC,CACF"}
|
package/dist/helpers/options.cjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_helpers_filters = require('./filters.cjs');
|
|
4
|
-
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
|
-
let chalk = require("chalk");
|
|
6
|
-
chalk = require_runtime.__toESM(chalk, 1);
|
|
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
|
-
function resolvePresetFunction(context, preset) {
|
|
17
|
-
try {
|
|
18
|
-
return Array.isArray(preset) && preset.length > 0 && preset[0] ? (0, _stryke_type_checks_is_function.isFunction)(preset[0]) ? preset[0](context) : preset[0] : (0, _stryke_type_checks_is_function.isFunction)(preset) ? preset(context) : preset;
|
|
19
|
-
} catch {
|
|
20
|
-
return preset[0];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
25
|
-
*
|
|
26
|
-
* @param context - The context for the transformation.
|
|
27
|
-
* @param code - The code to be transformed.
|
|
28
|
-
* @param id - The ID of the source file.
|
|
29
|
-
* @param plugin - The Babel plugin to resolve.
|
|
30
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
31
|
-
*/
|
|
32
|
-
function resolveBabelPlugin(context, code, id, plugin) {
|
|
33
|
-
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
34
|
-
if (plugin.length > 2 && plugin[2] && (0, _stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
|
|
35
|
-
context.trace(`Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_helpers_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
return plugin.length > 2 ? [
|
|
39
|
-
resolvePluginFunction(context, plugin),
|
|
40
|
-
plugin[1],
|
|
41
|
-
plugin[2]
|
|
42
|
-
] : [
|
|
43
|
-
resolvePluginFunction(context, plugin),
|
|
44
|
-
plugin[1],
|
|
45
|
-
null
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
return [
|
|
49
|
-
resolvePluginFunction(context, plugin),
|
|
50
|
-
{},
|
|
51
|
-
null
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Resolve the [Babel](https://babeljs.io/) preset.
|
|
56
|
-
*
|
|
57
|
-
* @param context - The context for the transformation.
|
|
58
|
-
* @param code - The code to be transformed.
|
|
59
|
-
* @param id - The ID of the source file.
|
|
60
|
-
* @param preset - The Babel preset to resolve.
|
|
61
|
-
* @returns The resolved Babel preset options, or undefined if the preset is filtered out.
|
|
62
|
-
*/
|
|
63
|
-
function resolveBabelPreset(context, code, id, preset) {
|
|
64
|
-
if (Array.isArray(preset) && preset.length > 0 && preset[0]) {
|
|
65
|
-
if (preset.length > 2 && preset[2] && (0, _stryke_type_checks_is_function.isFunction)(preset[2]) && !preset[2](code, id)) {
|
|
66
|
-
context.trace(`Skipping filtered Babel preset ${chalk.default.bold.cyanBright(require_helpers_filters.getPluginName(preset) || "unnamed")} for ${id}`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
return preset.length > 2 ? [
|
|
70
|
-
resolvePresetFunction(context, preset),
|
|
71
|
-
preset[1],
|
|
72
|
-
preset[2]
|
|
73
|
-
] : [
|
|
74
|
-
resolvePresetFunction(context, preset),
|
|
75
|
-
preset[1],
|
|
76
|
-
null
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
return [
|
|
80
|
-
resolvePresetFunction(context, preset),
|
|
81
|
-
{},
|
|
82
|
-
null
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get a list of unique Babel plugins, filtering out duplicates based on their names.
|
|
87
|
-
*
|
|
88
|
-
* @param plugins - The list of Babel plugins to filter for uniqueness.
|
|
89
|
-
* @returns A list of unique Babel plugins.
|
|
90
|
-
*/
|
|
91
|
-
function getUniquePlugins(plugins) {
|
|
92
|
-
return plugins.reduce((ret, plugin) => {
|
|
93
|
-
if (plugin && !require_helpers_filters.isDuplicatePlugin(ret, plugin)) ret.push(plugin);
|
|
94
|
-
return ret;
|
|
95
|
-
}, []);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get a list of unique Babel presets, filtering out duplicates based on their names.
|
|
99
|
-
*
|
|
100
|
-
* @param presets - The list of Babel presets to filter for uniqueness.
|
|
101
|
-
* @returns A list of unique Babel presets.
|
|
102
|
-
*/
|
|
103
|
-
function getUniquePresets(presets) {
|
|
104
|
-
return presets.reduce((ret, preset) => {
|
|
105
|
-
if (preset && !require_helpers_filters.isDuplicatePreset(ret, preset)) ret.push(preset);
|
|
106
|
-
return ret;
|
|
107
|
-
}, []);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//#endregion
|
|
111
|
-
exports.getUniquePlugins = getUniquePlugins;
|
|
112
|
-
exports.getUniquePresets = getUniquePresets;
|
|
113
|
-
exports.resolveBabelPlugin = resolveBabelPlugin;
|
|
114
|
-
exports.resolveBabelPreset = resolveBabelPreset;
|
|
115
|
-
exports.resolvePluginFunction = resolvePluginFunction;
|
|
116
|
-
exports.resolvePresetFunction = resolvePresetFunction;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BabelTransformPluginOptions, BabelTransformPresetOptions, ResolvedBabelTransformPluginOptions, ResolvedBabelTransformPresetOptions } from "../types/config.cjs";
|
|
2
|
-
import { Context } from "@powerlines/core";
|
|
3
|
-
import { PluginItem, PluginTarget, PresetItem, PresetTarget } from "@babel/core";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/options.d.ts
|
|
6
|
-
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginItem] | [PluginTarget, PluginItem, string | undefined]): BabelTransformPluginOptions;
|
|
7
|
-
declare function resolvePresetFunction(context: Context, preset: any | PresetTarget | any[] | [PresetTarget, PresetItem] | [PresetTarget, PresetItem, string | undefined]): BabelTransformPresetOptions;
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
10
|
-
*
|
|
11
|
-
* @param context - The context for the transformation.
|
|
12
|
-
* @param code - The code to be transformed.
|
|
13
|
-
* @param id - The ID of the source file.
|
|
14
|
-
* @param plugin - The Babel plugin to resolve.
|
|
15
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
16
|
-
*/
|
|
17
|
-
declare function resolveBabelPlugin(context: Context, code: string, id: string, plugin: BabelTransformPluginOptions): ResolvedBabelTransformPluginOptions | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Resolve the [Babel](https://babeljs.io/) preset.
|
|
20
|
-
*
|
|
21
|
-
* @param context - The context for the transformation.
|
|
22
|
-
* @param code - The code to be transformed.
|
|
23
|
-
* @param id - The ID of the source file.
|
|
24
|
-
* @param preset - The Babel preset to resolve.
|
|
25
|
-
* @returns The resolved Babel preset options, or undefined if the preset is filtered out.
|
|
26
|
-
*/
|
|
27
|
-
declare function resolveBabelPreset(context: Context, code: string, id: string, preset: BabelTransformPresetOptions): ResolvedBabelTransformPresetOptions | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Get a list of unique Babel plugins, filtering out duplicates based on their names.
|
|
30
|
-
*
|
|
31
|
-
* @param plugins - The list of Babel plugins to filter for uniqueness.
|
|
32
|
-
* @returns A list of unique Babel plugins.
|
|
33
|
-
*/
|
|
34
|
-
declare function getUniquePlugins<T extends BabelTransformPluginOptions | ResolvedBabelTransformPluginOptions>(plugins: T[]): T[];
|
|
35
|
-
/**
|
|
36
|
-
* Get a list of unique Babel presets, filtering out duplicates based on their names.
|
|
37
|
-
*
|
|
38
|
-
* @param presets - The list of Babel presets to filter for uniqueness.
|
|
39
|
-
* @returns A list of unique Babel presets.
|
|
40
|
-
*/
|
|
41
|
-
declare function getUniquePresets<T extends BabelTransformPresetOptions | ResolvedBabelTransformPresetOptions>(presets: T[]): T[];
|
|
42
|
-
//#endregion
|
|
43
|
-
export { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction };
|
|
44
|
-
//# sourceMappingURL=options.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.cts","names":[],"sources":["../../src/helpers/options.ts"],"mappings":";;;;;iBAmCgB,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,UAAA,KACd,YAAA,EAAc,UAAA,wBAClB,2BAAA;AAAA,iBAca,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,UAAA,KACd,YAAA,EAAc,UAAA,wBAClB,2BAAA;AA9BH;;;;;;;;;AAAA,iBAqDgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA;;;;;;;;;;iBAwCa,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA;;;;AAjFH;;;iBAsHgB,gBAAA,WACJ,2BAAA,GAA8B,mCAAA,CAAA,CACxC,OAAA,EAAS,CAAA,KAAM,CAAA;;;;;;;iBAgBD,gBAAA,WACJ,2BAAA,GAA8B,mCAAA,CAAA,CACxC,OAAA,EAAS,CAAA,KAAM,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BabelTransformPluginOptions, BabelTransformPresetOptions, ResolvedBabelTransformPluginOptions, ResolvedBabelTransformPresetOptions } from "../types/config.mjs";
|
|
2
|
-
import { PluginItem, PluginTarget, PresetItem, PresetTarget } from "@babel/core";
|
|
3
|
-
import { Context } from "@powerlines/core";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/options.d.ts
|
|
6
|
-
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginItem] | [PluginTarget, PluginItem, string | undefined]): BabelTransformPluginOptions;
|
|
7
|
-
declare function resolvePresetFunction(context: Context, preset: any | PresetTarget | any[] | [PresetTarget, PresetItem] | [PresetTarget, PresetItem, string | undefined]): BabelTransformPresetOptions;
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
10
|
-
*
|
|
11
|
-
* @param context - The context for the transformation.
|
|
12
|
-
* @param code - The code to be transformed.
|
|
13
|
-
* @param id - The ID of the source file.
|
|
14
|
-
* @param plugin - The Babel plugin to resolve.
|
|
15
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
16
|
-
*/
|
|
17
|
-
declare function resolveBabelPlugin(context: Context, code: string, id: string, plugin: BabelTransformPluginOptions): ResolvedBabelTransformPluginOptions | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* Resolve the [Babel](https://babeljs.io/) preset.
|
|
20
|
-
*
|
|
21
|
-
* @param context - The context for the transformation.
|
|
22
|
-
* @param code - The code to be transformed.
|
|
23
|
-
* @param id - The ID of the source file.
|
|
24
|
-
* @param preset - The Babel preset to resolve.
|
|
25
|
-
* @returns The resolved Babel preset options, or undefined if the preset is filtered out.
|
|
26
|
-
*/
|
|
27
|
-
declare function resolveBabelPreset(context: Context, code: string, id: string, preset: BabelTransformPresetOptions): ResolvedBabelTransformPresetOptions | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Get a list of unique Babel plugins, filtering out duplicates based on their names.
|
|
30
|
-
*
|
|
31
|
-
* @param plugins - The list of Babel plugins to filter for uniqueness.
|
|
32
|
-
* @returns A list of unique Babel plugins.
|
|
33
|
-
*/
|
|
34
|
-
declare function getUniquePlugins<T extends BabelTransformPluginOptions | ResolvedBabelTransformPluginOptions>(plugins: T[]): T[];
|
|
35
|
-
/**
|
|
36
|
-
* Get a list of unique Babel presets, filtering out duplicates based on their names.
|
|
37
|
-
*
|
|
38
|
-
* @param presets - The list of Babel presets to filter for uniqueness.
|
|
39
|
-
* @returns A list of unique Babel presets.
|
|
40
|
-
*/
|
|
41
|
-
declare function getUniquePresets<T extends BabelTransformPresetOptions | ResolvedBabelTransformPresetOptions>(presets: T[]): T[];
|
|
42
|
-
//#endregion
|
|
43
|
-
export { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction };
|
|
44
|
-
//# sourceMappingURL=options.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","names":[],"sources":["../../src/helpers/options.ts"],"mappings":";;;;;iBAmCgB,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,UAAA,KACd,YAAA,EAAc,UAAA,wBAClB,2BAAA;AAAA,iBAca,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,UAAA,KACd,YAAA,EAAc,UAAA,wBAClB,2BAAA;AA9BH;;;;;;;;;AAAA,iBAqDgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA;;;;;;;;;;iBAwCa,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA;;;;AAjFH;;;iBAsHgB,gBAAA,WACJ,2BAAA,GAA8B,mCAAA,CAAA,CACxC,OAAA,EAAS,CAAA,KAAM,CAAA;;;;;;;iBAgBD,gBAAA,WACJ,2BAAA,GAA8B,mCAAA,CAAA,CACxC,OAAA,EAAS,CAAA,KAAM,CAAA"}
|