@powerlines/plugin-babel 0.12.349 → 0.12.350
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-C0xms8kb.cjs → _virtual/_rolldown/runtime.cjs} +1 -6
- package/dist/helpers/ast-utils.cjs +2 -2
- package/dist/helpers/ast-utils.d.cts +19 -2
- package/dist/helpers/ast-utils.d.cts.map +1 -0
- package/dist/helpers/ast-utils.d.mts +19 -2
- package/dist/helpers/ast-utils.d.mts.map +1 -0
- package/dist/helpers/create-plugin.cjs +2 -2
- package/dist/helpers/create-plugin.d.cts +15 -2
- package/dist/helpers/create-plugin.d.cts.map +1 -0
- package/dist/helpers/create-plugin.d.mts +15 -2
- package/dist/helpers/create-plugin.d.mts.map +1 -0
- package/dist/helpers/filters.cjs +1 -1
- package/dist/helpers/filters.d.cts +43 -2
- package/dist/helpers/filters.d.cts.map +1 -0
- package/dist/helpers/filters.d.mts +43 -2
- package/dist/helpers/filters.d.mts.map +1 -0
- package/dist/helpers/index.d.cts +5 -5
- package/dist/helpers/index.d.mts +5 -5
- package/dist/helpers/module-helpers.cjs +2 -2
- package/dist/helpers/module-helpers.d.cts +49 -2
- package/dist/helpers/module-helpers.d.cts.map +1 -0
- package/dist/helpers/module-helpers.d.mts +49 -2
- package/dist/helpers/module-helpers.d.mts.map +1 -0
- package/dist/helpers/options.cjs +2 -2
- package/dist/helpers/options.d.cts +19 -2
- package/dist/helpers/options.d.cts.map +1 -0
- package/dist/helpers/options.d.mts +19 -2
- package/dist/helpers/options.d.mts.map +1 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/config.d.cts +86 -2
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +86 -2
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.d.mts +1 -1
- package/package.json +4 -5
- package/dist/ast-utils-BGST1RhV.d.cts +0 -19
- package/dist/ast-utils-BGST1RhV.d.cts.map +0 -1
- package/dist/ast-utils-BeOv3AgV.d.mts +0 -19
- package/dist/ast-utils-BeOv3AgV.d.mts.map +0 -1
- package/dist/config-CuJGOt8R.d.cts +0 -86
- package/dist/config-CuJGOt8R.d.cts.map +0 -1
- package/dist/config-D_d7N-Sl.d.mts +0 -86
- package/dist/config-D_d7N-Sl.d.mts.map +0 -1
- package/dist/create-plugin-BIwCYvvY.d.mts +0 -15
- package/dist/create-plugin-BIwCYvvY.d.mts.map +0 -1
- package/dist/create-plugin-D_a-SigP.d.cts +0 -15
- package/dist/create-plugin-D_a-SigP.d.cts.map +0 -1
- package/dist/filters-CJGhJSwI.d.mts +0 -43
- package/dist/filters-CJGhJSwI.d.mts.map +0 -1
- package/dist/filters-DSaGPmrz.d.cts +0 -43
- package/dist/filters-DSaGPmrz.d.cts.map +0 -1
- package/dist/module-helpers-BeUcHHvL.d.cts +0 -49
- package/dist/module-helpers-BeUcHHvL.d.cts.map +0 -1
- package/dist/module-helpers-BmiPAh2F.d.mts +0 -49
- package/dist/module-helpers-BmiPAh2F.d.mts.map +0 -1
- package/dist/options-CuRFY_V6.d.mts +0 -19
- package/dist/options-CuRFY_V6.d.mts.map +0 -1
- package/dist/options-ku57q3v6.d.cts +0 -19
- package/dist/options-ku57q3v6.d.cts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let _babel_generator = require("@babel/generator");
|
|
4
|
-
_babel_generator =
|
|
4
|
+
_babel_generator = require_runtime.__toESM(_babel_generator);
|
|
5
5
|
let _babel_parser = require("@babel/parser");
|
|
6
6
|
|
|
7
7
|
//#region src/helpers/ast-utils.ts
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GeneratorOptions, GeneratorResult, GeneratorResult as GeneratorResult$1 } from "@babel/generator";
|
|
2
|
+
import { ParseResult, ParserOptions } from "@babel/parser";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/ast-utils.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parse the given code into an AST.
|
|
8
|
+
*
|
|
9
|
+
* @param code - The code to parse.
|
|
10
|
+
* @param opts - The options for parsing.
|
|
11
|
+
* @returns The parsed AST.
|
|
12
|
+
*/
|
|
13
|
+
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
14
|
+
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
15
|
+
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult$1;
|
|
16
|
+
declare type __ΩGenerateFromAstOptions = any[];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { GenerateFromAstOptions, type GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
19
|
+
//# sourceMappingURL=ast-utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-utils.d.cts","names":[],"sources":["../../src/helpers/ast-utils.ts"],"mappings":";;;;;;;AA+BA;;;;;iBAAgB,QAAA,CACd,IAAA,UACA,IAAA,GAAM,aAAA,GACL,WAAA,CAAY,CAAA,CAAE,IAAA;AAAA,KAeL,sBAAA,GAAyB,gBAAA,GACnC,QAAA,CAAS,IAAA,CAAK,gBAAA;AAAA,iBAEA,eAAA,CACd,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,IAAA,GAAO,sBAAA,GACN,iBAAA;AAAA"}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { GeneratorOptions, GeneratorResult, GeneratorResult as GeneratorResult$1 } from "@babel/generator";
|
|
2
|
+
import { ParseResult, ParserOptions } from "@babel/parser";
|
|
3
|
+
import * as t from "@babel/types";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/ast-utils.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Parse the given code into an AST.
|
|
8
|
+
*
|
|
9
|
+
* @param code - The code to parse.
|
|
10
|
+
* @param opts - The options for parsing.
|
|
11
|
+
* @returns The parsed AST.
|
|
12
|
+
*/
|
|
13
|
+
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
14
|
+
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
15
|
+
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult$1;
|
|
16
|
+
declare type __ΩGenerateFromAstOptions = any[];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { GenerateFromAstOptions, type GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst };
|
|
19
|
+
//# sourceMappingURL=ast-utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-utils.d.mts","names":[],"sources":["../../src/helpers/ast-utils.ts"],"mappings":";;;;;;;AA+BA;;;;;iBAAgB,QAAA,CACd,IAAA,UACA,IAAA,GAAM,aAAA,GACL,WAAA,CAAY,CAAA,CAAE,IAAA;AAAA,KAeL,sBAAA,GAAyB,gBAAA,GACnC,QAAA,CAAS,IAAA,CAAK,gBAAA;AAAA,iBAEA,eAAA,CACd,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,IAAA,GAAO,sBAAA,GACN,iBAAA;AAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let chalk = require("chalk");
|
|
4
|
-
chalk =
|
|
4
|
+
chalk = require_runtime.__toESM(chalk);
|
|
5
5
|
let _babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
6
6
|
let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
|
|
7
7
|
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../types/config.cjs";
|
|
2
|
+
import { Context } from "@powerlines/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/create-plugin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create a Babel plugin using the provided builder function.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The name of the plugin.
|
|
9
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
+
* @returns A Babel plugin declaration.
|
|
11
|
+
*/
|
|
12
|
+
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createBabelPlugin };
|
|
15
|
+
//# sourceMappingURL=create-plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.d.cts","names":[],"sources":["../../src/helpers/create-plugin.ts"],"mappings":";;;;;;AAmCA;;;;;iBAAgB,iBAAA,kBACG,OAAA,GAAU,OAAA,mBACV,MAAA,gBAAsB,MAAA,cAAA,CAEvC,IAAA,UACA,OAAA,EAAS,2BAAA,CAA4B,QAAA,EAAU,QAAA,IAC9C,iCAAA,CAAkC,QAAA,EAAU,QAAA"}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "../types/config.mjs";
|
|
2
|
+
import { Context } from "@powerlines/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/create-plugin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create a Babel plugin using the provided builder function.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The name of the plugin.
|
|
9
|
+
* @param builder - The builder function that defines the plugin behavior.
|
|
10
|
+
* @returns A Babel plugin declaration.
|
|
11
|
+
*/
|
|
12
|
+
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createBabelPlugin };
|
|
15
|
+
//# sourceMappingURL=create-plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.d.mts","names":[],"sources":["../../src/helpers/create-plugin.ts"],"mappings":";;;;;;AAmCA;;;;;iBAAgB,iBAAA,kBACG,OAAA,GAAU,OAAA,mBACV,MAAA,gBAAsB,MAAA,cAAA,CAEvC,IAAA,UACA,OAAA,EAAS,2BAAA,CAA4B,QAAA,EAAU,QAAA,IAC9C,iCAAA,CAAkC,QAAA,EAAU,QAAA"}
|
package/dist/helpers/filters.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
4
4
|
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
5
5
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.cjs";
|
|
2
|
+
import { Context } from "@powerlines/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/filters.d.ts
|
|
5
|
+
declare function getPluginName(plugin?: BabelTransformPluginOptions | string | false | object | ((...args: any[]) => any) | undefined): 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
|
|
42
|
+
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
|
43
|
+
//# sourceMappingURL=filters.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.cts","names":[],"sources":["../../src/helpers/filters.ts"],"mappings":";;;;iBA6BgB,aAAA,CACd,MAAA,GACI,2BAAA,kCAIK,IAAA;;AANX;;;;;;iBA2BgB,iBAAA,CACd,OAAA,GAAU,mCAAA,iBACV,MAAA,EAAQ,2BAAA;;;AAFV;;;;;iBAqBgB,oBAAA,kBAAsC,OAAA,GAAU,OAAA,CAAA,CAC9D,OAAA,EAAS,QAAA,EACT,MAAA,WACC,0BAAA;;;;;AAHH;;;;;iBAuBgB,eAAA,CACd,OAAA,EAAS,OAAA,EACT,OAAA,EAAS,2BAAA,IACT,MAAA,EAAQ,0BAAA,qBACR,IAAA,WACC,2BAAA;;;;;;;;;iBAUa,eAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,EAAQ,oBAAA,GAAuB,2BAAA,EAC/B,MAAA,EAAQ,WAAA,CAAY,0BAAA,IACnB,2BAAA"}
|
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPlugin, BabelTransformPluginFilter, BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.mjs";
|
|
2
|
+
import { Context } from "@powerlines/core";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/filters.d.ts
|
|
5
|
+
declare function getPluginName(plugin?: BabelTransformPluginOptions | string | false | object | ((...args: any[]) => any) | undefined): 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
|
|
42
|
+
export { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin };
|
|
43
|
+
//# sourceMappingURL=filters.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.d.mts","names":[],"sources":["../../src/helpers/filters.ts"],"mappings":";;;;iBA6BgB,aAAA,CACd,MAAA,GACI,2BAAA,kCAIK,IAAA;;AANX;;;;;;iBA2BgB,iBAAA,CACd,OAAA,GAAU,mCAAA,iBACV,MAAA,EAAQ,2BAAA;;;AAFV;;;;;iBAqBgB,oBAAA,kBAAsC,OAAA,GAAU,OAAA,CAAA,CAC9D,OAAA,EAAS,QAAA,EACT,MAAA,WACC,0BAAA;;;;;AAHH;;;;;iBAuBgB,eAAA,CACd,OAAA,EAAS,OAAA,EACT,OAAA,EAAS,2BAAA,IACT,MAAA,EAAQ,0BAAA,qBACR,IAAA,WACC,2BAAA;;;;;;;;;iBAUa,eAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,EAAQ,oBAAA,GAAuB,2BAAA,EAC/B,MAAA,EAAQ,WAAA,CAAY,0BAAA,IACnB,2BAAA"}
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.cjs";
|
|
2
|
+
import { createBabelPlugin } from "./create-plugin.cjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.cjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.cjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.cjs";
|
|
6
6
|
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,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./ast-utils.mjs";
|
|
2
|
+
import { createBabelPlugin } from "./create-plugin.mjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./filters.mjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./module-helpers.mjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./options.mjs";
|
|
6
6
|
export { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, addImport, addImportsToProgram, addPluginFilter, createBabelPlugin, filterPluginByFileId, findExport, generateFromAst, getImport, getPluginName, isDuplicatePlugin, isImportCall, listExports, listImports, parseAst, resolveBabelPlugin, resolvePluginFunction };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
4
4
|
let _babel_types = require("@babel/types");
|
|
5
|
-
_babel_types =
|
|
5
|
+
_babel_types = require_runtime.__toESM(_babel_types);
|
|
6
6
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
7
7
|
|
|
8
8
|
//#region src/helpers/module-helpers.ts
|
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,2 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/helpers/options.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_helpers_filters = require('./filters.cjs');
|
|
4
4
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
5
|
let chalk = require("chalk");
|
|
6
|
-
chalk =
|
|
6
|
+
chalk = require_runtime.__toESM(chalk);
|
|
7
7
|
|
|
8
8
|
//#region src/helpers/options.ts
|
|
9
9
|
function resolvePluginFunction(context, plugin) {
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.cjs";
|
|
2
|
+
import { Context } from "@powerlines/core";
|
|
3
|
+
import { PluginOptions, PluginTarget } from "@babel/core";
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.cts","names":[],"sources":["../../src/helpers/options.ts"],"mappings":";;;;;iBA4BgB,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,aAAA,KACd,YAAA,EAAc,aAAA,wBAClB,2BAAA;;AARH;;;;;;;;iBA+BgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA"}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { BabelTransformPluginOptions, ResolvedBabelTransformPluginOptions } from "../types/config.mjs";
|
|
2
|
+
import { PluginOptions, PluginTarget } 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, 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.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.mts","names":[],"sources":["../../src/helpers/options.ts"],"mappings":";;;;;iBA4BgB,qBAAA,CACd,OAAA,EAAS,OAAA,EACT,MAAA,QAEI,YAAA,YAEC,YAAA,EAAc,aAAA,KACd,YAAA,EAAc,aAAA,wBAClB,2BAAA;;AARH;;;;;;;;iBA+BgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,IAAA,UACA,EAAA,UACA,MAAA,EAAQ,2BAAA,GACP,mCAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_helpers_filters = require('./helpers/filters.cjs');
|
|
4
4
|
const require_helpers_options = require('./helpers/options.cjs');
|
|
5
5
|
const require_helpers_ast_utils = require('./helpers/ast-utils.cjs');
|
|
6
6
|
const require_helpers_create_plugin = require('./helpers/create-plugin.cjs');
|
|
7
7
|
const require_helpers_module_helpers = require('./helpers/module-helpers.cjs');
|
|
8
8
|
require('./helpers/index.cjs');
|
|
9
|
-
require('./types/index.cjs');
|
|
10
9
|
let _babel_core = require("@babel/core");
|
|
11
10
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
12
11
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
13
12
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
14
13
|
let defu = require("defu");
|
|
15
|
-
defu =
|
|
14
|
+
defu = require_runtime.__toESM(defu);
|
|
16
15
|
|
|
17
16
|
//#region src/index.ts
|
|
18
17
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.cjs";
|
|
2
|
+
import { BabelPluginPass, BabelResolvedConfig, BabelTransformInput, BabelTransformPlugin, BabelTransformPluginBuilder, BabelTransformPluginBuilderParams, BabelTransformPluginFilter, BabelTransformPluginOptions, BabelUserConfig, DeclareBabelTransformPluginReturn, DefaultImportDefinition, ImportDefinition, ImportSpecifier, NamedImportDefinition, ResolvedBabelTransformPluginOptions, __ΩBabelPluginPass, __ΩBabelResolvedConfig, __ΩBabelTransformInput, __ΩBabelTransformPlugin, __ΩBabelTransformPluginBuilder, __ΩBabelTransformPluginBuilderParams, __ΩBabelTransformPluginFilter, __ΩBabelTransformPluginOptions, __ΩBabelUserConfig, __ΩDeclareBabelTransformPluginReturn, __ΩDefaultImportDefinition, __ΩImportDefinition, __ΩImportSpecifier, __ΩNamedImportDefinition, __ΩResolvedBabelTransformPluginOptions } from "./types/config.cjs";
|
|
3
|
+
import { createBabelPlugin } from "./helpers/create-plugin.cjs";
|
|
4
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.cjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.cjs";
|
|
6
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.cjs";
|
|
7
7
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.cjs";
|
|
8
8
|
import { Plugin } from "@powerlines/core";
|
|
9
9
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
2
|
+
import { BabelPluginPass, BabelResolvedConfig, BabelTransformInput, BabelTransformPlugin, BabelTransformPluginBuilder, BabelTransformPluginBuilderParams, BabelTransformPluginFilter, BabelTransformPluginOptions, BabelUserConfig, DeclareBabelTransformPluginReturn, DefaultImportDefinition, ImportDefinition, ImportSpecifier, NamedImportDefinition, ResolvedBabelTransformPluginOptions, __ΩBabelPluginPass, __ΩBabelResolvedConfig, __ΩBabelTransformInput, __ΩBabelTransformPlugin, __ΩBabelTransformPluginBuilder, __ΩBabelTransformPluginBuilderParams, __ΩBabelTransformPluginFilter, __ΩBabelTransformPluginOptions, __ΩBabelUserConfig, __ΩDeclareBabelTransformPluginReturn, __ΩDefaultImportDefinition, __ΩImportDefinition, __ΩImportSpecifier, __ΩNamedImportDefinition, __ΩResolvedBabelTransformPluginOptions } from "./types/config.mjs";
|
|
3
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
4
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
7
7
|
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.mjs";
|
|
8
8
|
import { Plugin } from "@powerlines/core";
|
|
9
9
|
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
|
4
4
|
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
5
5
|
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
6
|
import "./helpers/index.mjs";
|
|
7
|
-
import "./types/index.mjs";
|
|
8
7
|
import { transformAsync } from "@babel/core";
|
|
9
8
|
import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
10
9
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { transformAsync } from \"@babel/core\";\nimport type { Plugin } from \"@powerlines/core\";\nimport {\n findFileExtension,\n findFileExtensionSafe\n} from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport defu from \"defu\";\nimport { isDuplicatePlugin } from \"./helpers/filters\";\nimport { resolveBabelPlugin } from \"./helpers/options\";\nimport { ResolvedBabelTransformPluginOptions } from \"./types/config\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface Config {\n babel?: BabelPluginOptions;\n }\n}\n\n/**\n * Babel plugin for Powerlines.\n *\n * @param options - The Babel plugin user configuration options.\n * @returns A Powerlines plugin that integrates Babel transformations.\n */\nexport const plugin = <\n TContext extends BabelPluginContext = BabelPluginContext\n>(\n options: BabelPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n babel: options\n };\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.config.babel = defu(this.config.babel ?? {}, {\n plugins: [],\n presets: []\n });\n }\n },\n async transform(code: string, id: string) {\n if (\n isParentPath(id, this.powerlinesPath) ||\n code.includes(\"/* @powerlines-ignore */\") ||\n code.includes(\"/* @powerlines-disable */\")\n ) {\n this.trace(`Skipping Babel transformation for: ${id}`);\n\n return { code, id };\n }\n\n const plugins = this.config.babel.plugins\n .map(plugin => resolveBabelPlugin(this, code, id, plugin))\n .filter(\n (plugin, _, arr) => plugin && !isDuplicatePlugin(arr, plugin)\n ) as ResolvedBabelTransformPluginOptions[];\n const presets = this.config.babel.presets\n .map(preset => resolveBabelPlugin(this, code, id, preset))\n .filter(\n (preset, _, arr) => preset && !isDuplicatePlugin(arr, preset)\n ) as ResolvedBabelTransformPluginOptions[];\n\n if (\n Array.isArray(plugins) &&\n plugins.length === 0 &&\n Array.isArray(presets) &&\n presets.length === 0\n ) {\n return { code, id };\n }\n\n if (\n /^(?:m|c)?tsx?$/.test(\n findFileExtensionSafe(id, {\n fullExtension: true\n })\n ) &&\n !isDuplicatePlugin(plugins, \"@babel/plugin-syntax-typescript\") &&\n !isDuplicatePlugin(presets, \"@babel/preset-typescript\")\n ) {\n plugins.unshift([\n \"@babel/plugin-syntax-typescript\",\n { isTSX: findFileExtension(id) === \"tsx\" }\n ]);\n }\n\n this.trace(\n `Running babel transformations with ${plugins.length} plugins and ${\n presets.length\n } presets for file: ${id}`\n );\n\n const result = await transformAsync(code, {\n highlightCode: true,\n code: true,\n ast: false,\n cloneInputAst: false,\n comments: true,\n sourceType: \"module\",\n configFile: false,\n babelrc: false,\n envName: this.config.mode,\n caller: {\n name: this.config.framework\n },\n ...(this.config.babel ?? {}),\n filename: id,\n plugins: plugins\n .map(plugin => {\n return Array.isArray(plugin) && plugin.length >= 2\n ? [\n plugin[0],\n defu(plugin.length > 1 && plugin[1] ? plugin[1] : {}, {\n options\n })\n ]\n : plugin;\n })\n .filter(Boolean),\n presets: presets\n .map(preset => {\n return Array.isArray(preset) && preset.length >= 2\n ? [\n preset[0],\n defu(preset.length > 1 && preset[1] ? preset[1] : {}, {\n options\n })\n ]\n : preset;\n })\n .filter(Boolean)\n });\n if (!result?.code) {\n throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);\n }\n\n this.trace(`Completed babel transformations for file: ${id}`);\n\n return { code: result.code, id };\n }\n } as Plugin<TContext>;\n};\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.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 { transformAsync } from \"@babel/core\";\nimport type { Plugin } from \"@powerlines/core\";\nimport {\n findFileExtension,\n findFileExtensionSafe\n} from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport defu from \"defu\";\nimport { isDuplicatePlugin } from \"./helpers/filters\";\nimport { resolveBabelPlugin } from \"./helpers/options\";\nimport { ResolvedBabelTransformPluginOptions } from \"./types/config\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface Config {\n babel?: BabelPluginOptions;\n }\n}\n\n/**\n * Babel plugin for Powerlines.\n *\n * @param options - The Babel plugin user configuration options.\n * @returns A Powerlines plugin that integrates Babel transformations.\n */\nexport const plugin = <\n TContext extends BabelPluginContext = BabelPluginContext\n>(\n options: BabelPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n babel: options\n };\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.config.babel = defu(this.config.babel ?? {}, {\n plugins: [],\n presets: []\n });\n }\n },\n async transform(code: string, id: string) {\n if (\n isParentPath(id, this.powerlinesPath) ||\n code.includes(\"/* @powerlines-ignore */\") ||\n code.includes(\"/* @powerlines-disable */\")\n ) {\n this.trace(`Skipping Babel transformation for: ${id}`);\n\n return { code, id };\n }\n\n const plugins = this.config.babel.plugins\n .map(plugin => resolveBabelPlugin(this, code, id, plugin))\n .filter(\n (plugin, _, arr) => plugin && !isDuplicatePlugin(arr, plugin)\n ) as ResolvedBabelTransformPluginOptions[];\n const presets = this.config.babel.presets\n .map(preset => resolveBabelPlugin(this, code, id, preset))\n .filter(\n (preset, _, arr) => preset && !isDuplicatePlugin(arr, preset)\n ) as ResolvedBabelTransformPluginOptions[];\n\n if (\n Array.isArray(plugins) &&\n plugins.length === 0 &&\n Array.isArray(presets) &&\n presets.length === 0\n ) {\n return { code, id };\n }\n\n if (\n /^(?:m|c)?tsx?$/.test(\n findFileExtensionSafe(id, {\n fullExtension: true\n })\n ) &&\n !isDuplicatePlugin(plugins, \"@babel/plugin-syntax-typescript\") &&\n !isDuplicatePlugin(presets, \"@babel/preset-typescript\")\n ) {\n plugins.unshift([\n \"@babel/plugin-syntax-typescript\",\n { isTSX: findFileExtension(id) === \"tsx\" }\n ]);\n }\n\n this.trace(\n `Running babel transformations with ${plugins.length} plugins and ${\n presets.length\n } presets for file: ${id}`\n );\n\n const result = await transformAsync(code, {\n highlightCode: true,\n code: true,\n ast: false,\n cloneInputAst: false,\n comments: true,\n sourceType: \"module\",\n configFile: false,\n babelrc: false,\n envName: this.config.mode,\n caller: {\n name: this.config.framework\n },\n ...(this.config.babel ?? {}),\n filename: id,\n plugins: plugins\n .map(plugin => {\n return Array.isArray(plugin) && plugin.length >= 2\n ? [\n plugin[0],\n defu(plugin.length > 1 && plugin[1] ? plugin[1] : {}, {\n options\n })\n ]\n : plugin;\n })\n .filter(Boolean),\n presets: presets\n .map(preset => {\n return Array.isArray(preset) && preset.length >= 2\n ? [\n preset[0],\n defu(preset.length > 1 && preset[1] ? preset[1] : {}, {\n options\n })\n ]\n : preset;\n })\n .filter(Boolean)\n });\n if (!result?.code) {\n throw new Error(`Powerlines - Babel plugin failed to compile ${id}`);\n }\n\n this.trace(`Completed babel transformations for file: ${id}`);\n\n return { code: result.code, id };\n }\n } as Plugin<TContext>;\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,MAAa,UAGX,UAA8B,EAAE,KACX;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,OAAI,CAAC,YAAY,QAAQ,CACvB;AAGF,UAAO,EACL,OAAO,SACR;;EAEH,gBAAgB;GACd,OAAO;GACP,UAAU;AACR,SAAK,OAAO,QAAQ,KAAK,KAAK,OAAO,SAAS,EAAE,EAAE;KAChD,SAAS,EAAE;KACX,SAAS,EAAE;KACZ,CAAC;;GAEL;EACD,MAAM,UAAU,MAAc,IAAY;AACxC,OACE,aAAa,IAAI,KAAK,eAAe,IACrC,KAAK,SAAS,2BAA2B,IACzC,KAAK,SAAS,4BAA4B,EAC1C;AACA,SAAK,MAAM,sCAAsC,KAAK;AAEtD,WAAO;KAAE;KAAM;KAAI;;GAGrB,MAAM,UAAU,KAAK,OAAO,MAAM,QAC/B,KAAI,WAAU,mBAAmB,MAAM,MAAM,IAAI,OAAO,CAAC,CACzD,QACE,QAAQ,GAAG,QAAQ,UAAU,CAAC,kBAAkB,KAAK,OAAO,CAC9D;GACH,MAAM,UAAU,KAAK,OAAO,MAAM,QAC/B,KAAI,WAAU,mBAAmB,MAAM,MAAM,IAAI,OAAO,CAAC,CACzD,QACE,QAAQ,GAAG,QAAQ,UAAU,CAAC,kBAAkB,KAAK,OAAO,CAC9D;AAEH,OACE,MAAM,QAAQ,QAAQ,IACtB,QAAQ,WAAW,KACnB,MAAM,QAAQ,QAAQ,IACtB,QAAQ,WAAW,EAEnB,QAAO;IAAE;IAAM;IAAI;AAGrB,OACE,iBAAiB,KACf,sBAAsB,IAAI,EACxB,eAAe,MAChB,CAAC,CACH,IACD,CAAC,kBAAkB,SAAS,kCAAkC,IAC9D,CAAC,kBAAkB,SAAS,2BAA2B,CAEvD,SAAQ,QAAQ,CACd,mCACA,EAAE,OAAO,kBAAkB,GAAG,KAAK,OAAO,CAC3C,CAAC;AAGJ,QAAK,MACH,sCAAsC,QAAQ,OAAO,eACnD,QAAQ,OACT,qBAAqB,KACvB;GAED,MAAM,SAAS,MAAM,eAAe,MAAM;IACxC,eAAe;IACf,MAAM;IACN,KAAK;IACL,eAAe;IACf,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,SAAS,KAAK,OAAO;IACrB,QAAQ,EACN,MAAM,KAAK,OAAO,WACnB;IACD,GAAI,KAAK,OAAO,SAAS,EAAE;IAC3B,UAAU;IACV,SAAS,QACN,KAAI,WAAU;AACb,YAAO,MAAM,QAAQ,OAAO,IAAI,OAAO,UAAU,IAC7C,CACE,OAAO,IACP,KAAK,OAAO,SAAS,KAAK,OAAO,KAAK,OAAO,KAAK,EAAE,EAAE,EACpD,SACD,CAAC,CACH,GACD;MACJ,CACD,OAAO,QAAQ;IAClB,SAAS,QACN,KAAI,WAAU;AACb,YAAO,MAAM,QAAQ,OAAO,IAAI,OAAO,UAAU,IAC7C,CACE,OAAO,IACP,KAAK,OAAO,SAAS,KAAK,OAAO,KAAK,OAAO,KAAK,EAAE,EAAE,EACpD,SACD,CAAC,CACH,GACD;MACJ,CACD,OAAO,QAAQ;IACnB,CAAC;AACF,OAAI,CAAC,QAAQ,KACX,OAAM,IAAI,MAAM,+CAA+C,KAAK;AAGtE,QAAK,MAAM,6CAA6C,KAAK;AAE7D,UAAO;IAAE,MAAM,OAAO;IAAM;IAAI;;EAEnC"}
|