@powerlines/plugin-babel 0.12.307 → 0.12.308
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/ast-utils-BcmWaIan.cjs +45 -0
- package/dist/ast-utils-BgcE0CUh.mjs +33 -0
- package/dist/ast-utils-BgcE0CUh.mjs.map +1 -0
- package/dist/ast-utils-BrOP-SXX.d.cts +20 -0
- package/dist/ast-utils-BrOP-SXX.d.cts.map +1 -0
- package/dist/ast-utils-c95WpQzC.d.mts +20 -0
- package/dist/ast-utils-c95WpQzC.d.mts.map +1 -0
- package/dist/{_virtual/rolldown_runtime.cjs → chunk-CbDLau6x.cjs} +6 -1
- package/dist/config-B8fQjuSs.d.cts +86 -0
- package/dist/config-B8fQjuSs.d.cts.map +1 -0
- package/dist/config-BGnCc0aq.d.mts +86 -0
- package/dist/config-BGnCc0aq.d.mts.map +1 -0
- package/dist/config-BLkkDfsC.mjs +1 -0
- package/dist/config-QK0F_KAD.cjs +0 -0
- package/dist/create-plugin-BbG_dRTl.mjs +40 -0
- package/dist/create-plugin-BbG_dRTl.mjs.map +1 -0
- package/dist/create-plugin-D1_rga7H.d.cts +16 -0
- package/dist/create-plugin-D1_rga7H.d.cts.map +1 -0
- package/dist/create-plugin-DaXcRyMI.cjs +46 -0
- package/dist/create-plugin-H35OVSz7.d.mts +16 -0
- package/dist/create-plugin-H35OVSz7.d.mts.map +1 -0
- package/dist/filters-CU0L1nIa.cjs +79 -0
- package/dist/filters-DX-_VLWz.d.mts +43 -0
- package/dist/filters-DX-_VLWz.d.mts.map +1 -0
- package/dist/filters-DjAUc6r9.mjs +56 -0
- package/dist/filters-DjAUc6r9.mjs.map +1 -0
- package/dist/filters-xc5uoxxD.d.cts +43 -0
- package/dist/filters-xc5uoxxD.d.cts.map +1 -0
- package/dist/helpers/ast-utils.cjs +3 -34
- package/dist/helpers/ast-utils.d.cts +2 -20
- package/dist/helpers/ast-utils.d.mts +2 -20
- package/dist/helpers/ast-utils.mjs +2 -32
- package/dist/helpers/create-plugin.cjs +2 -40
- package/dist/helpers/create-plugin.d.cts +3 -16
- package/dist/helpers/create-plugin.d.mts +3 -17
- package/dist/helpers/create-plugin.mjs +2 -39
- package/dist/helpers/filters.cjs +5 -58
- package/dist/helpers/filters.d.cts +3 -43
- package/dist/helpers/filters.d.mts +3 -44
- package/dist/helpers/filters.mjs +2 -55
- package/dist/helpers/index.cjs +22 -21
- package/dist/helpers/index.d.cts +7 -5
- package/dist/helpers/index.d.mts +7 -5
- package/dist/helpers/index.mjs +6 -5
- package/dist/helpers/module-helpers.cjs +9 -102
- package/dist/helpers/module-helpers.d.cts +3 -50
- package/dist/helpers/module-helpers.d.mts +3 -50
- package/dist/helpers/module-helpers.mjs +3 -95
- package/dist/helpers/options.cjs +4 -48
- package/dist/helpers/options.d.cts +3 -19
- package/dist/helpers/options.d.mts +3 -20
- package/dist/helpers/options.mjs +3 -46
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/helpers-DemUUgdw.mjs +1 -0
- package/dist/index-C2gUMYkE.d.cts +1 -0
- package/dist/index-D8dPsry7.d.mts +1 -0
- package/dist/index-OEBbnNdr.d.mts +1 -0
- package/dist/index-uTS5iDq_.d.cts +1 -0
- package/dist/index.cjs +30 -27
- package/dist/index.d.cts +10 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/dist/module-helpers-B913A2FR.d.mts +50 -0
- package/dist/module-helpers-B913A2FR.d.mts.map +1 -0
- package/dist/module-helpers-BBKb6fKg.d.cts +50 -0
- package/dist/module-helpers-BBKb6fKg.d.cts.map +1 -0
- package/dist/module-helpers-DtOc93YQ.mjs +96 -0
- package/dist/module-helpers-DtOc93YQ.mjs.map +1 -0
- package/dist/module-helpers-Non-jHMu.cjs +138 -0
- package/dist/options-2JL6WIXT.cjs +59 -0
- package/dist/options-CNyetWnk.d.cts +19 -0
- package/dist/options-CNyetWnk.d.cts.map +1 -0
- package/dist/options-DT_wvMGu.mjs +47 -0
- package/dist/options-DT_wvMGu.mjs.map +1 -0
- package/dist/options-Z_v0-Y5V.d.mts +19 -0
- package/dist/options-Z_v0-Y5V.d.mts.map +1 -0
- package/dist/plugin-10Y9IjgN.d.cts +19 -0
- package/dist/plugin-10Y9IjgN.d.cts.map +1 -0
- package/dist/plugin-25m6BdNV.d.mts +19 -0
- package/dist/plugin-25m6BdNV.d.mts.map +1 -0
- package/dist/plugin-BX9Q6Mnb.mjs +1 -0
- package/dist/plugin-DkYJiG5m.cjs +0 -0
- package/dist/types/config.cjs +1 -0
- package/dist/types/config.d.cts +2 -87
- package/dist/types/config.d.mts +2 -88
- package/dist/types/config.mjs +2 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.mts +3 -2
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +3 -20
- package/dist/types/plugin.d.mts +3 -21
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-Bjn15Uy6.mjs +1 -0
- package/dist/types-D10T4PdD.cjs +0 -0
- package/package.json +2 -2
- package/dist/core/src/lib/logger.cjs +0 -41
- package/dist/core/src/lib/logger.mjs +0 -40
- package/dist/core/src/lib/logger.mjs.map +0 -1
- package/dist/core/src/types/api.d.cts +0 -103
- package/dist/core/src/types/api.d.cts.map +0 -1
- package/dist/core/src/types/api.d.mts +0 -103
- package/dist/core/src/types/api.d.mts.map +0 -1
- package/dist/core/src/types/commands.d.cts +0 -9
- package/dist/core/src/types/commands.d.cts.map +0 -1
- package/dist/core/src/types/commands.d.mts +0 -10
- package/dist/core/src/types/commands.d.mts.map +0 -1
- package/dist/core/src/types/config.d.cts +0 -551
- package/dist/core/src/types/config.d.cts.map +0 -1
- package/dist/core/src/types/config.d.mts +0 -551
- package/dist/core/src/types/config.d.mts.map +0 -1
- package/dist/core/src/types/context.d.cts +0 -511
- package/dist/core/src/types/context.d.cts.map +0 -1
- package/dist/core/src/types/context.d.mts +0 -511
- package/dist/core/src/types/context.d.mts.map +0 -1
- package/dist/core/src/types/fs.d.cts +0 -487
- package/dist/core/src/types/fs.d.cts.map +0 -1
- package/dist/core/src/types/fs.d.mts +0 -487
- package/dist/core/src/types/fs.d.mts.map +0 -1
- package/dist/core/src/types/hooks.d.cts +0 -99
- package/dist/core/src/types/hooks.d.cts.map +0 -1
- package/dist/core/src/types/hooks.d.mts +0 -99
- package/dist/core/src/types/hooks.d.mts.map +0 -1
- package/dist/core/src/types/index.d.mts +0 -9
- package/dist/core/src/types/plugin.d.cts +0 -204
- package/dist/core/src/types/plugin.d.cts.map +0 -1
- package/dist/core/src/types/plugin.d.mts +0 -204
- package/dist/core/src/types/plugin.d.mts.map +0 -1
- package/dist/core/src/types/tsconfig.d.cts +0 -70
- package/dist/core/src/types/tsconfig.d.cts.map +0 -1
- package/dist/core/src/types/tsconfig.d.mts +0 -70
- package/dist/core/src/types/tsconfig.d.mts.map +0 -1
- package/dist/core/src/types/unplugin.d.cts +0 -24
- package/dist/core/src/types/unplugin.d.cts.map +0 -1
- package/dist/core/src/types/unplugin.d.mts +0 -25
- package/dist/core/src/types/unplugin.d.mts.map +0 -1
- package/dist/helpers/ast-utils.d.cts.map +0 -1
- package/dist/helpers/ast-utils.d.mts.map +0 -1
- package/dist/helpers/ast-utils.mjs.map +0 -1
- package/dist/helpers/create-plugin.d.cts.map +0 -1
- package/dist/helpers/create-plugin.d.mts.map +0 -1
- package/dist/helpers/create-plugin.mjs.map +0 -1
- package/dist/helpers/filters.d.cts.map +0 -1
- package/dist/helpers/filters.d.mts.map +0 -1
- package/dist/helpers/filters.mjs.map +0 -1
- package/dist/helpers/module-helpers.d.cts.map +0 -1
- package/dist/helpers/module-helpers.d.mts.map +0 -1
- package/dist/helpers/module-helpers.mjs.map +0 -1
- package/dist/helpers/options.d.cts.map +0 -1
- package/dist/helpers/options.d.mts.map +0 -1
- package/dist/helpers/options.mjs.map +0 -1
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts.map +0 -1
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_filters = require('../filters-CU0L1nIa.cjs');
|
|
2
|
+
const require_options = require('../options-2JL6WIXT.cjs');
|
|
3
|
+
const require_ast_utils = require('../ast-utils-BcmWaIan.cjs');
|
|
4
|
+
const require_create_plugin = require('../create-plugin-DaXcRyMI.cjs');
|
|
5
|
+
const require_module_helpers = require('../module-helpers-Non-jHMu.cjs');
|
|
6
|
+
require('../helpers-Bx2yBrpn.cjs');
|
|
6
7
|
|
|
7
|
-
exports.addImport =
|
|
8
|
-
exports.addImportsToProgram =
|
|
9
|
-
exports.addPluginFilter =
|
|
10
|
-
exports.createBabelPlugin =
|
|
11
|
-
exports.filterPluginByFileId =
|
|
12
|
-
exports.findExport =
|
|
13
|
-
exports.generateFromAst =
|
|
14
|
-
exports.getImport =
|
|
15
|
-
exports.getPluginName =
|
|
16
|
-
exports.isDuplicatePlugin =
|
|
17
|
-
exports.isImportCall =
|
|
18
|
-
exports.listExports =
|
|
19
|
-
exports.listImports =
|
|
20
|
-
exports.parseAst =
|
|
21
|
-
exports.resolveBabelPlugin =
|
|
22
|
-
exports.resolvePluginFunction =
|
|
8
|
+
exports.addImport = require_module_helpers.addImport;
|
|
9
|
+
exports.addImportsToProgram = require_module_helpers.addImportsToProgram;
|
|
10
|
+
exports.addPluginFilter = require_filters.addPluginFilter;
|
|
11
|
+
exports.createBabelPlugin = require_create_plugin.createBabelPlugin;
|
|
12
|
+
exports.filterPluginByFileId = require_filters.filterPluginByFileId;
|
|
13
|
+
exports.findExport = require_module_helpers.findExport;
|
|
14
|
+
exports.generateFromAst = require_ast_utils.generateFromAst;
|
|
15
|
+
exports.getImport = require_module_helpers.getImport;
|
|
16
|
+
exports.getPluginName = require_filters.getPluginName;
|
|
17
|
+
exports.isDuplicatePlugin = require_filters.isDuplicatePlugin;
|
|
18
|
+
exports.isImportCall = require_module_helpers.isImportCall;
|
|
19
|
+
exports.listExports = require_module_helpers.listExports;
|
|
20
|
+
exports.listImports = require_module_helpers.listImports;
|
|
21
|
+
exports.parseAst = require_ast_utils.parseAst;
|
|
22
|
+
exports.resolveBabelPlugin = require_options.resolveBabelPlugin;
|
|
23
|
+
exports.resolvePluginFunction = require_options.resolvePluginFunction;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-BrOP-SXX.cjs";
|
|
2
|
+
import "../config-B8fQjuSs.cjs";
|
|
3
|
+
import { t as createBabelPlugin } from "../create-plugin-D1_rga7H.cjs";
|
|
4
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-xc5uoxxD.cjs";
|
|
5
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-BBKb6fKg.cjs";
|
|
6
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-CNyetWnk.cjs";
|
|
7
|
+
import "../index-C2gUMYkE.cjs";
|
|
6
8
|
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { a as parseAst, i as generateFromAst, n as GeneratorResult, r as __ΩGenerateFromAstOptions, t as GenerateFromAstOptions } from "../ast-utils-c95WpQzC.mjs";
|
|
2
|
+
import "../config-BGnCc0aq.mjs";
|
|
3
|
+
import { t as createBabelPlugin } from "../create-plugin-H35OVSz7.mjs";
|
|
4
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-DX-_VLWz.mjs";
|
|
5
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-B913A2FR.mjs";
|
|
6
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-Z_v0-Y5V.mjs";
|
|
7
|
+
import "../index-OEBbnNdr.mjs";
|
|
6
8
|
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { createBabelPlugin } from "
|
|
5
|
-
import {
|
|
1
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-DjAUc6r9.mjs";
|
|
2
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-DT_wvMGu.mjs";
|
|
3
|
+
import { n as parseAst, t as generateFromAst } from "../ast-utils-BgcE0CUh.mjs";
|
|
4
|
+
import { t as createBabelPlugin } from "../create-plugin-BbG_dRTl.mjs";
|
|
5
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-DtOc93YQ.mjs";
|
|
6
|
+
import "../helpers-DemUUgdw.mjs";
|
|
6
7
|
|
|
7
8
|
export { addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1,103 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
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");
|
|
1
|
+
require('../ast-utils-BcmWaIan.cjs');
|
|
2
|
+
const require_module_helpers = require('../module-helpers-Non-jHMu.cjs');
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
4
|
+
exports.addImport = require_module_helpers.addImport;
|
|
5
|
+
exports.addImportsToProgram = require_module_helpers.addImportsToProgram;
|
|
6
|
+
exports.findExport = require_module_helpers.findExport;
|
|
7
|
+
exports.getImport = require_module_helpers.getImport;
|
|
8
|
+
exports.isImportCall = require_module_helpers.isImportCall;
|
|
9
|
+
exports.listExports = require_module_helpers.listExports;
|
|
10
|
+
exports.listImports = require_module_helpers.listImports;
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
50
|
-
//# sourceMappingURL=module-helpers.d.cts.map
|
|
1
|
+
import "../config-B8fQjuSs.cjs";
|
|
2
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-BBKb6fKg.cjs";
|
|
3
|
+
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1,50 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import * as t from "@babel/types";
|
|
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 { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
50
|
-
//# sourceMappingURL=module-helpers.d.mts.map
|
|
1
|
+
import "../config-BGnCc0aq.mjs";
|
|
2
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-B913A2FR.mjs";
|
|
3
|
+
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1,96 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
1
|
+
import "../ast-utils-BgcE0CUh.mjs";
|
|
2
|
+
import { a as isImportCall, i as getImport, n as addImportsToProgram, o as listExports, r as findExport, s as listImports, t as addImport } from "../module-helpers-DtOc93YQ.mjs";
|
|
4
3
|
|
|
5
|
-
|
|
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
|
|
4
|
+
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
package/dist/helpers/options.cjs
CHANGED
|
@@ -1,49 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
4
|
-
let chalk = require("chalk");
|
|
5
|
-
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
1
|
+
require('../filters-CU0L1nIa.cjs');
|
|
2
|
+
const require_options = require('../options-2JL6WIXT.cjs');
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
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;
|
|
11
|
-
} catch {
|
|
12
|
-
return plugin[0];
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The context for the transformation.
|
|
19
|
-
* @param code - The code to be transformed.
|
|
20
|
-
* @param id - The ID of the source file.
|
|
21
|
-
* @param plugin - The Babel plugin to resolve.
|
|
22
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
23
|
-
*/
|
|
24
|
-
function resolveBabelPlugin(context, code, id, plugin) {
|
|
25
|
-
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
26
|
-
if (plugin.length > 2 && plugin[2] && (0, __stryke_type_checks_is_function.isFunction)(plugin[2]) && !plugin[2](code, id)) {
|
|
27
|
-
context.trace(`Skipping filtered Babel plugin ${chalk.default.bold.cyanBright(require_helpers_filters.getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
return plugin.length > 2 ? [
|
|
31
|
-
resolvePluginFunction(context, plugin),
|
|
32
|
-
plugin[1],
|
|
33
|
-
plugin[2]
|
|
34
|
-
] : [
|
|
35
|
-
resolvePluginFunction(context, plugin),
|
|
36
|
-
plugin[1],
|
|
37
|
-
null
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
return [
|
|
41
|
-
resolvePluginFunction(context, plugin),
|
|
42
|
-
{},
|
|
43
|
-
null
|
|
44
|
-
];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
exports.resolveBabelPlugin = resolveBabelPlugin;
|
|
49
|
-
exports.resolvePluginFunction = resolvePluginFunction;
|
|
4
|
+
exports.resolveBabelPlugin = require_options.resolveBabelPlugin;
|
|
5
|
+
exports.resolvePluginFunction = require_options.resolvePluginFunction;
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/options.d.ts
|
|
6
|
-
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined]): BabelTransformPluginOptions;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The context for the transformation.
|
|
11
|
-
* @param code - The code to be transformed.
|
|
12
|
-
* @param id - The ID of the source file.
|
|
13
|
-
* @param plugin - The Babel plugin to resolve.
|
|
14
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
15
|
-
*/
|
|
16
|
-
declare function resolveBabelPlugin(context: Context, code: string, id: string, plugin: BabelTransformPluginOptions): ResolvedBabelTransformPluginOptions | undefined;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { resolveBabelPlugin, resolvePluginFunction };
|
|
19
|
-
//# sourceMappingURL=options.d.cts.map
|
|
1
|
+
import "../config-B8fQjuSs.cjs";
|
|
2
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-CNyetWnk.cjs";
|
|
3
|
+
export { resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "../
|
|
3
|
-
|
|
4
|
-
import { PluginOptions, PluginTarget } from "@babel/core";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/options.d.ts
|
|
7
|
-
declare function resolvePluginFunction(context: Context, plugin: any | PluginTarget | any[] | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined]): BabelTransformPluginOptions;
|
|
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
|
-
//#endregion
|
|
19
|
-
export { resolveBabelPlugin, resolvePluginFunction };
|
|
20
|
-
//# sourceMappingURL=options.d.mts.map
|
|
1
|
+
import "../config-BGnCc0aq.mjs";
|
|
2
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-Z_v0-Y5V.mjs";
|
|
3
|
+
export { resolveBabelPlugin, resolvePluginFunction };
|
package/dist/helpers/options.mjs
CHANGED
|
@@ -1,47 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import chalk from "chalk";
|
|
1
|
+
import "../filters-DjAUc6r9.mjs";
|
|
2
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-DT_wvMGu.mjs";
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
function resolvePluginFunction(context, plugin) {
|
|
7
|
-
try {
|
|
8
|
-
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? isFunction(plugin[0]) ? plugin[0](context) : plugin[0] : isFunction(plugin) ? plugin(context) : plugin;
|
|
9
|
-
} catch {
|
|
10
|
-
return plugin[0];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Resolve the [Babel](https://babeljs.io/) plugin.
|
|
15
|
-
*
|
|
16
|
-
* @param context - The context for the transformation.
|
|
17
|
-
* @param code - The code to be transformed.
|
|
18
|
-
* @param id - The ID of the source file.
|
|
19
|
-
* @param plugin - The Babel plugin to resolve.
|
|
20
|
-
* @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.
|
|
21
|
-
*/
|
|
22
|
-
function resolveBabelPlugin(context, code, id, plugin) {
|
|
23
|
-
if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {
|
|
24
|
-
if (plugin.length > 2 && plugin[2] && isFunction(plugin[2]) && !plugin[2](code, id)) {
|
|
25
|
-
context.trace(`Skipping filtered Babel plugin ${chalk.bold.cyanBright(getPluginName(plugin) || "unnamed")} for ${id}`);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
return plugin.length > 2 ? [
|
|
29
|
-
resolvePluginFunction(context, plugin),
|
|
30
|
-
plugin[1],
|
|
31
|
-
plugin[2]
|
|
32
|
-
] : [
|
|
33
|
-
resolvePluginFunction(context, plugin),
|
|
34
|
-
plugin[1],
|
|
35
|
-
null
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
return [
|
|
39
|
-
resolvePluginFunction(context, plugin),
|
|
40
|
-
{},
|
|
41
|
-
null
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { resolveBabelPlugin, resolvePluginFunction };
|
|
47
|
-
//# sourceMappingURL=options.mjs.map
|
|
4
|
+
export { resolveBabelPlugin, resolvePluginFunction };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|