@powerlines/plugin-babel 0.12.129 → 0.12.131
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-Bs6DBkKg.d.mts +19 -0
- package/dist/ast-utils-DU1foCxH.mjs +32 -0
- package/dist/ast-utils-DeuXcuqs.d.cts +19 -0
- package/dist/babel-B9i2IAT_.d.cts +1805 -0
- package/dist/babel-DY_imD3U.d.mts +1805 -0
- package/dist/{_virtual/rolldown_runtime.cjs → chunk-CbDLau6x.cjs} +6 -1
- package/dist/create-plugin-BPSvsem_.mjs +73 -0
- package/dist/create-plugin-CNzMrex8.d.mts +14 -0
- package/dist/create-plugin-CQA6zFdt.d.cts +14 -0
- package/dist/create-plugin-Cs1zZrvI.cjs +80 -0
- package/dist/filters-93Z-7Nov.d.mts +44 -0
- package/dist/filters-C04cfcQR.mjs +55 -0
- package/dist/filters-D6Qe6UbO.d.cts +41 -0
- package/dist/filters-Dl2RKvrm.cjs +79 -0
- package/dist/helpers/ast-utils.cjs +3 -34
- package/dist/helpers/ast-utils.d.cts +2 -19
- package/dist/helpers/ast-utils.d.mts +2 -19
- package/dist/helpers/ast-utils.mjs +1 -30
- package/dist/helpers/create-plugin.cjs +2 -40
- package/dist/helpers/create-plugin.d.cts +2 -14
- package/dist/helpers/create-plugin.d.mts +2 -14
- package/dist/helpers/create-plugin.mjs +1 -37
- package/dist/helpers/filters.cjs +5 -58
- package/dist/helpers/filters.d.cts +2 -41
- package/dist/helpers/filters.d.mts +2 -42
- package/dist/helpers/filters.mjs +1 -53
- 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 +2 -48
- package/dist/helpers/module-helpers.d.mts +2 -48
- package/dist/helpers/module-helpers.mjs +2 -93
- package/dist/helpers/options.cjs +4 -49
- package/dist/helpers/options.d.cts +2 -17
- package/dist/helpers/options.d.mts +2 -17
- package/dist/helpers/options.mjs +2 -45
- package/dist/helpers-BnW_4z5h.mjs +1 -0
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/index-ClXLQ1fw.d.mts +1 -0
- package/dist/index-DeEmP3Jc.d.cts +1 -0
- package/dist/index-QbUkWSLh.d.mts +1 -0
- package/dist/index-zO0Ly4bS.d.cts +1 -0
- package/dist/index.cjs +29 -27
- package/dist/index.d.cts +9 -8
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +8 -6
- package/dist/module-helpers-Ckq8sc4l.mjs +95 -0
- package/dist/module-helpers-DRUocgcq.d.cts +49 -0
- package/dist/module-helpers-DiSYdstQ.d.mts +49 -0
- package/dist/module-helpers-Non-jHMu.cjs +138 -0
- package/dist/options-BQhc80ih.mjs +47 -0
- package/dist/options-CCMyIIWc.d.cts +17 -0
- package/dist/options-DgdPmsbF.d.mts +17 -0
- package/dist/options-u2MhTIFH.cjs +60 -0
- package/dist/plugin-BL8TLixo.mjs +1 -0
- package/dist/plugin-BSBH78mm.cjs +0 -0
- package/dist/plugin-Bc0EOyGF.d.mts +17 -0
- package/dist/plugin-DhjfPNQS.d.cts +17 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +3 -1
- package/dist/types/index.d.mts +3 -1
- package/dist/types/index.mjs +3 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +2 -18
- package/dist/types/plugin.d.mts +2 -18
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CvhspRRt.mjs +1 -0
- package/package.json +5 -5
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -5
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/types/api.d.mts +0 -5
- package/dist/powerlines/src/types/babel.d.cts +0 -50
- package/dist/powerlines/src/types/babel.d.mts +0 -50
- package/dist/powerlines/src/types/build.d.cts +0 -145
- package/dist/powerlines/src/types/build.d.mts +0 -145
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/config.d.cts +0 -380
- package/dist/powerlines/src/types/config.d.mts +0 -380
- package/dist/powerlines/src/types/context.d.cts +0 -403
- package/dist/powerlines/src/types/context.d.mts +0 -405
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/index.d.mts +0 -12
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -82
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
- package/dist/powerlines/src/types/unplugin.d.mts +0 -6
package/dist/helpers/filters.cjs
CHANGED
|
@@ -1,59 +1,6 @@
|
|
|
1
|
-
const
|
|
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");
|
|
1
|
+
const require_filters = require('../filters-Dl2RKvrm.cjs');
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
12
|
-
*
|
|
13
|
-
* @param plugins - The list of existing Babel plugins.
|
|
14
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
15
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
16
|
-
*/
|
|
17
|
-
function isDuplicatePlugin(plugins, plugin) {
|
|
18
|
-
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Filters a Babel plugin by its runtime ID.
|
|
22
|
-
*
|
|
23
|
-
* @param context - The context in which the filter is applied.
|
|
24
|
-
* @param fileId - The file ID to filter by.
|
|
25
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
26
|
-
*/
|
|
27
|
-
function filterPluginByFileId(context, fileId) {
|
|
28
|
-
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
32
|
-
*
|
|
33
|
-
* @param context - The context in which the plugin is being added.
|
|
34
|
-
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
35
|
-
* @param filter - The filter function to apply to the plugins.
|
|
36
|
-
* @param name - The name of the plugin to add the filter to.
|
|
37
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
38
|
-
*/
|
|
39
|
-
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
40
|
-
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && ((0, __stryke_type_checks_is_set_string.isSetString)(pluginOrPlugins[0]) || (0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
41
|
-
pluginOrPlugins[0],
|
|
42
|
-
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
43
|
-
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !(0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
44
|
-
] : [
|
|
45
|
-
pluginOrPlugins,
|
|
46
|
-
{},
|
|
47
|
-
{ filter }
|
|
48
|
-
];
|
|
49
|
-
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
50
|
-
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
51
|
-
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
52
|
-
return pluginOrPlugins;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
exports.addPluginFilter = addPluginFilter;
|
|
57
|
-
exports.filterPluginByFileId = filterPluginByFileId;
|
|
58
|
-
exports.getPluginName = getPluginName;
|
|
59
|
-
exports.isDuplicatePlugin = isDuplicatePlugin;
|
|
3
|
+
exports.addPluginFilter = require_filters.addPluginFilter;
|
|
4
|
+
exports.filterPluginByFileId = require_filters.filterPluginByFileId;
|
|
5
|
+
exports.getPluginName = require_filters.getPluginName;
|
|
6
|
+
exports.isDuplicatePlugin = require_filters.isDuplicatePlugin;
|
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/filters.d.ts
|
|
5
|
-
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
8
|
-
*
|
|
9
|
-
* @param plugins - The list of existing Babel plugins.
|
|
10
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
11
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
12
|
-
*/
|
|
13
|
-
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Filters a Babel plugin by its runtime ID.
|
|
16
|
-
*
|
|
17
|
-
* @param context - The context in which the filter is applied.
|
|
18
|
-
* @param fileId - The file ID to filter by.
|
|
19
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
20
|
-
*/
|
|
21
|
-
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
22
|
-
/**
|
|
23
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
24
|
-
*
|
|
25
|
-
* @param context - The context in which the plugin is being added.
|
|
26
|
-
* @param plugins - The Babel plugins to add the filter to.
|
|
27
|
-
* @param filter - The filter function to apply to the plugins.
|
|
28
|
-
* @param name - The name of the plugin to add the filter to.
|
|
29
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
30
|
-
*/
|
|
31
|
-
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
32
|
-
/**
|
|
33
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
34
|
-
*
|
|
35
|
-
* @param context - The context in which the plugin is being added.
|
|
36
|
-
* @param plugin - The Babel plugin to add the filter to.
|
|
37
|
-
* @param filter - The filter function to apply to the plugin.
|
|
38
|
-
* @returns The updated Babel plugin with the filter applied.
|
|
39
|
-
*/
|
|
40
|
-
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
41
|
-
//#endregion
|
|
1
|
+
import "../babel-B9i2IAT_.cjs";
|
|
2
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-D6Qe6UbO.cjs";
|
|
42
3
|
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import "../powerlines/src/types/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/filters.d.ts
|
|
6
|
-
declare function getPluginName(plugin: BabelTransformPluginOptions): string | undefined;
|
|
7
|
-
/**
|
|
8
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
9
|
-
*
|
|
10
|
-
* @param plugins - The list of existing Babel plugins.
|
|
11
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
12
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
13
|
-
*/
|
|
14
|
-
declare function isDuplicatePlugin(plugins: (ResolvedBabelTransformPluginOptions | undefined)[], plugin: BabelTransformPluginOptions): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Filters a Babel plugin by its runtime ID.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The context in which the filter is applied.
|
|
19
|
-
* @param fileId - The file ID to filter by.
|
|
20
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
21
|
-
*/
|
|
22
|
-
declare function filterPluginByFileId<TContext extends Context = Context>(context: TContext, fileId: string): BabelTransformPluginFilter;
|
|
23
|
-
/**
|
|
24
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
25
|
-
*
|
|
26
|
-
* @param context - The context in which the plugin is being added.
|
|
27
|
-
* @param plugins - The Babel plugins to add the filter to.
|
|
28
|
-
* @param filter - The filter function to apply to the plugins.
|
|
29
|
-
* @param name - The name of the plugin to add the filter to.
|
|
30
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
31
|
-
*/
|
|
32
|
-
declare function addPluginFilter(context: Context, plugins: BabelTransformPluginOptions[], filter: BabelTransformPluginFilter | null | undefined, name: string): BabelTransformPluginOptions[];
|
|
33
|
-
/**
|
|
34
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
35
|
-
*
|
|
36
|
-
* @param context - The context in which the plugin is being added.
|
|
37
|
-
* @param plugin - The Babel plugin to add the filter to.
|
|
38
|
-
* @param filter - The filter function to apply to the plugin.
|
|
39
|
-
* @returns The updated Babel plugin with the filter applied.
|
|
40
|
-
*/
|
|
41
|
-
declare function addPluginFilter(context: Context, plugin: BabelTransformPlugin | BabelTransformPluginOptions, filter: NonNullable<BabelTransformPluginFilter>): BabelTransformPluginOptions;
|
|
42
|
-
//#endregion
|
|
1
|
+
import "../babel-DY_imD3U.mjs";
|
|
2
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-93Z-7Nov.mjs";
|
|
43
3
|
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
package/dist/helpers/filters.mjs
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isObject } from "@stryke/type-checks/is-object";
|
|
3
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
1
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-C04cfcQR.mjs";
|
|
4
2
|
|
|
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
3
|
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
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-Dl2RKvrm.cjs');
|
|
2
|
+
const require_options = require('../options-u2MhTIFH.cjs');
|
|
3
|
+
const require_ast_utils = require('../ast-utils-BcmWaIan.cjs');
|
|
4
|
+
const require_create_plugin = require('../create-plugin-Cs1zZrvI.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-DeuXcuqs.cjs";
|
|
2
|
+
import "../babel-B9i2IAT_.cjs";
|
|
3
|
+
import { t as createBabelPlugin } from "../create-plugin-CQA6zFdt.cjs";
|
|
4
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-D6Qe6UbO.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-DRUocgcq.cjs";
|
|
6
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-CCMyIIWc.cjs";
|
|
7
|
+
import "../index-DeEmP3Jc.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-Bs6DBkKg.mjs";
|
|
2
|
+
import "../babel-DY_imD3U.mjs";
|
|
3
|
+
import { t as createBabelPlugin } from "../create-plugin-CNzMrex8.mjs";
|
|
4
|
+
import { i as isDuplicatePlugin, n as filterPluginByFileId, r as getPluginName, t as addPluginFilter } from "../filters-93Z-7Nov.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-DiSYdstQ.mjs";
|
|
6
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-DgdPmsbF.mjs";
|
|
7
|
+
import "../index-ClXLQ1fw.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-C04cfcQR.mjs";
|
|
2
|
+
import { n as resolvePluginFunction, t as resolveBabelPlugin } from "../options-BQhc80ih.mjs";
|
|
3
|
+
import { n as parseAst, t as generateFromAst } from "../ast-utils-DU1foCxH.mjs";
|
|
4
|
+
import { t as createBabelPlugin } from "../create-plugin-BPSvsem_.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-Ckq8sc4l.mjs";
|
|
6
|
+
import "../helpers-BnW_4z5h.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,49 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
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
|
|
1
|
+
import "../babel-B9i2IAT_.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-DRUocgcq.cjs";
|
|
49
3
|
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { ParseResult } from "@babel/parser";
|
|
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
|
|
1
|
+
import "../babel-DY_imD3U.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-DiSYdstQ.mjs";
|
|
49
3
|
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
@@ -1,95 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
1
|
+
import "../ast-utils-DU1foCxH.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-Ckq8sc4l.mjs";
|
|
4
3
|
|
|
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
4
|
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|