@powerlines/plugin-babel 0.13.94 → 0.13.96
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-CEeaYzDW.cjs → chunk-C_NdSu1c.cjs} +0 -19
- package/dist/helpers/ast-utils.cjs +1 -11
- package/dist/helpers/ast-utils.mjs +1 -6
- package/dist/helpers/ast-utils.mjs.map +1 -1
- package/dist/helpers/create-plugin.cjs +2 -9
- package/dist/helpers/create-plugin.mjs +1 -3
- package/dist/helpers/create-plugin.mjs.map +1 -1
- package/dist/helpers/module-helpers.cjs +2 -17
- package/dist/helpers/module-helpers.mjs +1 -11
- package/dist/helpers/module-helpers.mjs.map +1 -1
- package/dist/helpers/options.cjs +1 -15
- package/dist/helpers/options.mjs +1 -10
- package/dist/helpers/options.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/package.json +5 -5
- package/dist/chunk-w6R9maHv.mjs +0 -18
- package/dist/helpers/ast-utils.test.cjs +0 -15
- package/dist/helpers/ast-utils.test.d.cts +0 -1
- package/dist/helpers/ast-utils.test.d.mts +0 -1
- package/dist/helpers/ast-utils.test.mjs +0 -17
- package/dist/helpers/ast-utils.test.mjs.map +0 -1
- package/dist/helpers/create-plugin.test.cjs +0 -15
- package/dist/helpers/create-plugin.test.d.cts +0 -1
- package/dist/helpers/create-plugin.test.d.mts +0 -1
- package/dist/helpers/create-plugin.test.mjs +0 -17
- package/dist/helpers/create-plugin.test.mjs.map +0 -1
- package/dist/helpers/filters.test.cjs +0 -40
- package/dist/helpers/filters.test.d.cts +0 -1
- package/dist/helpers/filters.test.d.mts +0 -1
- package/dist/helpers/filters.test.mjs +0 -42
- package/dist/helpers/filters.test.mjs.map +0 -1
- package/dist/helpers/module-helpers.test.cjs +0 -15
- package/dist/helpers/module-helpers.test.d.cts +0 -1
- package/dist/helpers/module-helpers.test.d.mts +0 -1
- package/dist/helpers/module-helpers.test.mjs +0 -17
- package/dist/helpers/module-helpers.test.mjs.map +0 -1
- package/dist/helpers/options.test.cjs +0 -15
- package/dist/helpers/options.test.d.cts +0 -1
- package/dist/helpers/options.test.d.mts +0 -1
- package/dist/helpers/options.test.mjs +0 -17
- package/dist/helpers/options.test.mjs.map +0 -1
|
@@ -5,19 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) {
|
|
11
|
-
__defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!no_symbols) {
|
|
17
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
8
|
var __copyProps = (to, from, except, desc) => {
|
|
22
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
10
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -39,12 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
26
|
|
|
40
27
|
//#endregion
|
|
41
28
|
|
|
42
|
-
Object.defineProperty(exports, '__exportAll', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return __exportAll;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
29
|
Object.defineProperty(exports, '__toESM', {
|
|
49
30
|
enumerable: true,
|
|
50
31
|
get: function () {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-
|
|
2
|
+
const require_chunk = require('../chunk-C_NdSu1c.cjs');
|
|
3
3
|
let _babel_generator = require("@babel/generator");
|
|
4
4
|
_babel_generator = require_chunk.__toESM(_babel_generator, 1);
|
|
5
5
|
let _babel_parser = require("@babel/parser");
|
|
6
6
|
|
|
7
7
|
//#region src/helpers/ast-utils.ts
|
|
8
|
-
var ast_utils_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
9
|
-
generateFromAst: () => generateFromAst,
|
|
10
|
-
parseAst: () => parseAst
|
|
11
|
-
});
|
|
12
8
|
/**
|
|
13
9
|
* Parse the given code into an AST.
|
|
14
10
|
*
|
|
@@ -35,11 +31,5 @@ function generateFromAst(ast, opts) {
|
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
//#endregion
|
|
38
|
-
Object.defineProperty(exports, 'ast_utils_exports', {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return ast_utils_exports;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
34
|
exports.generateFromAst = generateFromAst;
|
|
45
35
|
exports.parseAst = parseAst;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-w6R9maHv.mjs";
|
|
2
1
|
import _generate from "@babel/generator";
|
|
3
2
|
import { parse } from "@babel/parser";
|
|
4
3
|
|
|
5
4
|
//#region src/helpers/ast-utils.ts
|
|
6
|
-
var ast_utils_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
generateFromAst: () => generateFromAst,
|
|
8
|
-
parseAst: () => parseAst
|
|
9
|
-
});
|
|
10
5
|
/**
|
|
11
6
|
* Parse the given code into an AST.
|
|
12
7
|
*
|
|
@@ -33,5 +28,5 @@ function generateFromAst(ast, opts) {
|
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
//#endregion
|
|
36
|
-
export { generateFromAst, parseAst
|
|
31
|
+
export { generateFromAst, parseAst };
|
|
37
32
|
//# sourceMappingURL=ast-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.mjs","names":[],"sources":["../../src/helpers/ast-utils.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 type { GeneratorOptions, GeneratorResult } from \"@babel/generator\";\nimport _generate from \"@babel/generator\";\nimport type { ParseResult, ParserOptions } from \"@babel/parser\";\nimport { parse } from \"@babel/parser\";\nimport type * as t from \"@babel/types\";\n\n/**\n * Parse the given code into an AST.\n *\n * @param code - The code to parse.\n * @param opts - The options for parsing.\n * @returns The parsed AST.\n */\nexport function parseAst(\n code: string,\n opts: ParserOptions = {}\n): ParseResult<t.File> {\n return parse(code, {\n plugins: [\"typescript\"],\n sourceType: \"module\",\n allowImportExportEverywhere: true,\n allowAwaitOutsideFunction: true,\n ...opts\n });\n}\n\nlet generate = _generate;\nif (\"default\" in generate) {\n generate = generate.default as typeof generate;\n}\n\nexport type GenerateFromAstOptions = GeneratorOptions &\n Required<Pick<GeneratorOptions, \"sourceFileName\" | \"filename\">>;\n\nexport function generateFromAst(\n ast: t.Node,\n opts?: GenerateFromAstOptions\n): GeneratorResult {\n return generate(ast, opts ? { sourceMaps: true, ...opts } : undefined);\n}\n\nexport type { GeneratorResult } from \"@babel/generator\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast-utils.mjs","names":[],"sources":["../../src/helpers/ast-utils.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 type { GeneratorOptions, GeneratorResult } from \"@babel/generator\";\nimport _generate from \"@babel/generator\";\nimport type { ParseResult, ParserOptions } from \"@babel/parser\";\nimport { parse } from \"@babel/parser\";\nimport type * as t from \"@babel/types\";\n\n/**\n * Parse the given code into an AST.\n *\n * @param code - The code to parse.\n * @param opts - The options for parsing.\n * @returns The parsed AST.\n */\nexport function parseAst(\n code: string,\n opts: ParserOptions = {}\n): ParseResult<t.File> {\n return parse(code, {\n plugins: [\"typescript\"],\n sourceType: \"module\",\n allowImportExportEverywhere: true,\n allowAwaitOutsideFunction: true,\n ...opts\n });\n}\n\nlet generate = _generate;\nif (\"default\" in generate) {\n generate = generate.default as typeof generate;\n}\n\nexport type GenerateFromAstOptions = GeneratorOptions &\n Required<Pick<GeneratorOptions, \"sourceFileName\" | \"filename\">>;\n\nexport function generateFromAst(\n ast: t.Node,\n opts?: GenerateFromAstOptions\n): GeneratorResult {\n return generate(ast, opts ? { sourceMaps: true, ...opts } : undefined);\n}\n\nexport type { GeneratorResult } from \"@babel/generator\";\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,SACd,MACA,OAAsB,CAAC,GACF;CACrB,OAAO,MAAM,MAAM;EACjB,SAAS,CAAC,YAAY;EACtB,YAAY;EACZ,6BAA6B;EAC7B,2BAA2B;EAC3B,GAAG;CACL,CAAC;AACH;AAEA,IAAI,WAAW;AACf,IAAI,aAAa,UACf,WAAW,SAAS;AAMtB,SAAgB,gBACd,KACA,MACiB;CACjB,OAAO,SAAS,KAAK,OAAO;EAAE,YAAY;EAAM,GAAG;CAAK,IAAI,MAAS;AACvE"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-
|
|
2
|
+
const require_chunk = require('../chunk-C_NdSu1c.cjs');
|
|
3
3
|
let chalk = require("chalk");
|
|
4
4
|
chalk = require_chunk.__toESM(chalk, 1);
|
|
5
5
|
let _babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
6
6
|
|
|
7
7
|
//#region src/helpers/create-plugin.ts
|
|
8
|
-
var create_plugin_exports = /* @__PURE__ */ require_chunk.__exportAll({ createBabelPlugin: () => createBabelPlugin });
|
|
9
8
|
/**
|
|
10
9
|
* Create a Babel plugin using the provided builder function.
|
|
11
10
|
*
|
|
@@ -38,10 +37,4 @@ function createBabelPlugin(name, builder) {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
//#endregion
|
|
41
|
-
exports.createBabelPlugin = createBabelPlugin;
|
|
42
|
-
Object.defineProperty(exports, 'create_plugin_exports', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return create_plugin_exports;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
40
|
+
exports.createBabelPlugin = createBabelPlugin;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-w6R9maHv.mjs";
|
|
2
1
|
import chalk from "chalk";
|
|
3
2
|
import { declare } from "@babel/helper-plugin-utils";
|
|
4
3
|
|
|
5
4
|
//#region src/helpers/create-plugin.ts
|
|
6
|
-
var create_plugin_exports = /* @__PURE__ */ __exportAll({ createBabelPlugin: () => createBabelPlugin });
|
|
7
5
|
/**
|
|
8
6
|
* Create a Babel plugin using the provided builder function.
|
|
9
7
|
*
|
|
@@ -36,5 +34,5 @@ function createBabelPlugin(name, builder) {
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
//#endregion
|
|
39
|
-
export { createBabelPlugin
|
|
37
|
+
export { createBabelPlugin };
|
|
40
38
|
//# sourceMappingURL=create-plugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin.mjs","names":[],"sources":["../../src/helpers/create-plugin.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 { declare } from \"@babel/helper-plugin-utils\";\nimport chalk from \"chalk\";\nimport type { Context } from \"powerlines\";\nimport type {\n BabelTransformPluginBuilder,\n DeclareBabelTransformPluginReturn\n} from \"../types/config\";\n\n/**\n * Create a Babel plugin using the provided builder function.\n *\n * @param name - The name of the plugin.\n * @param builder - The builder function that defines the plugin behavior.\n * @returns A Babel plugin declaration.\n */\nexport function createBabelPlugin<\n TContext extends Context = Context,\n TOptions extends object = object\n>(\n name: string,\n builder: BabelTransformPluginBuilder<TContext, TOptions>\n): DeclareBabelTransformPluginReturn<TContext, TOptions> {\n const plugin = (context: TContext) => {\n return declare<TOptions>((api, options, dirname) => {\n api.cache.using(() => context.meta.checksum);\n api.assertVersion(\"^8.0.0-0\");\n\n const logger = context.extendLogger({ category: \"babel\" });\n logger.trace(\n `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`\n );\n\n const result = builder({\n logger,\n name,\n api,\n options: options as TOptions,\n context,\n dirname\n });\n result.name = name;\n\n logger.trace(\n `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`\n );\n\n return result;\n });\n };\n plugin.$$name = name;\n\n return plugin;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-plugin.mjs","names":[],"sources":["../../src/helpers/create-plugin.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 { declare } from \"@babel/helper-plugin-utils\";\nimport chalk from \"chalk\";\nimport type { Context } from \"powerlines\";\nimport type {\n BabelTransformPluginBuilder,\n DeclareBabelTransformPluginReturn\n} from \"../types/config\";\n\n/**\n * Create a Babel plugin using the provided builder function.\n *\n * @param name - The name of the plugin.\n * @param builder - The builder function that defines the plugin behavior.\n * @returns A Babel plugin declaration.\n */\nexport function createBabelPlugin<\n TContext extends Context = Context,\n TOptions extends object = object\n>(\n name: string,\n builder: BabelTransformPluginBuilder<TContext, TOptions>\n): DeclareBabelTransformPluginReturn<TContext, TOptions> {\n const plugin = (context: TContext) => {\n return declare<TOptions>((api, options, dirname) => {\n api.cache.using(() => context.meta.checksum);\n api.assertVersion(\"^8.0.0-0\");\n\n const logger = context.extendLogger({ category: \"babel\" });\n logger.trace(\n `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`\n );\n\n const result = builder({\n logger,\n name,\n api,\n options: options as TOptions,\n context,\n dirname\n });\n result.name = name;\n\n logger.trace(\n `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`\n );\n\n return result;\n });\n };\n plugin.$$name = name;\n\n return plugin;\n}\n"],"mappings":";;;;;;;;;;;AAiCA,SAAgB,kBAId,MACA,SACuD;CACvD,MAAM,UAAU,YAAsB;EACpC,OAAO,SAAmB,KAAK,SAAS,YAAY;GAClD,IAAI,MAAM,YAAY,QAAQ,KAAK,QAAQ;GAC3C,IAAI,cAAc,UAAU;GAE5B,MAAM,SAAS,QAAQ,aAAa,EAAE,UAAU,QAAQ,CAAC;GACzD,OAAO,MACL,oBAAoB,MAAM,KAAK,WAAW,IAAI,EAAE,cAClD;GAEA,MAAM,SAAS,QAAQ;IACrB;IACA;IACA;IACS;IACT;IACA;GACF,CAAC;GACD,OAAO,OAAO;GAEd,OAAO,MACL,mCAAmC,MAAM,KAAK,WAAW,IAAI,EAAE,cACjE;GAEA,OAAO;EACT,CAAC;CACH;CACA,OAAO,SAAS;CAEhB,OAAO;AACT"}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-
|
|
2
|
+
const require_chunk = require('../chunk-C_NdSu1c.cjs');
|
|
3
3
|
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
4
4
|
let _babel_types = require("@babel/types");
|
|
5
5
|
_babel_types = require_chunk.__toESM(_babel_types, 1);
|
|
6
6
|
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
7
7
|
|
|
8
8
|
//#region src/helpers/module-helpers.ts
|
|
9
|
-
var module_helpers_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
10
|
-
addImport: () => addImport,
|
|
11
|
-
addImportsToProgram: () => addImportsToProgram,
|
|
12
|
-
findExport: () => findExport,
|
|
13
|
-
getImport: () => getImport,
|
|
14
|
-
isImportCall: () => isImportCall,
|
|
15
|
-
listExports: () => listExports,
|
|
16
|
-
listImports: () => listImports
|
|
17
|
-
});
|
|
18
9
|
/**
|
|
19
10
|
* Finds an export in the given Babel AST program by its key.
|
|
20
11
|
*
|
|
@@ -110,10 +101,4 @@ exports.findExport = findExport;
|
|
|
110
101
|
exports.getImport = getImport;
|
|
111
102
|
exports.isImportCall = isImportCall;
|
|
112
103
|
exports.listExports = listExports;
|
|
113
|
-
exports.listImports = listImports;
|
|
114
|
-
Object.defineProperty(exports, 'module_helpers_exports', {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: function () {
|
|
117
|
-
return module_helpers_exports;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
104
|
+
exports.listImports = listImports;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-w6R9maHv.mjs";
|
|
2
1
|
import { parseAst } from "./ast-utils.mjs";
|
|
3
2
|
import * as t from "@babel/types";
|
|
4
3
|
import { isString } from "@stryke/type-checks/is-string";
|
|
5
4
|
|
|
6
5
|
//#region src/helpers/module-helpers.ts
|
|
7
|
-
var module_helpers_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
addImport: () => addImport,
|
|
9
|
-
addImportsToProgram: () => addImportsToProgram,
|
|
10
|
-
findExport: () => findExport,
|
|
11
|
-
getImport: () => getImport,
|
|
12
|
-
isImportCall: () => isImportCall,
|
|
13
|
-
listExports: () => listExports,
|
|
14
|
-
listImports: () => listImports
|
|
15
|
-
});
|
|
16
6
|
/**
|
|
17
7
|
* Finds an export in the given Babel AST program by its key.
|
|
18
8
|
*
|
|
@@ -102,5 +92,5 @@ function addImportsToProgram(path, specifier) {
|
|
|
102
92
|
}
|
|
103
93
|
|
|
104
94
|
//#endregion
|
|
105
|
-
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports
|
|
95
|
+
export { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports };
|
|
106
96
|
//# sourceMappingURL=module-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-helpers.mjs","names":[],"sources":["../../src/helpers/module-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport { ParseResult } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ImportSpecifier } from \"../types/config\";\nimport { parseAst } from \"./ast-utils\";\n\n/**\n * Finds an export in the given Babel AST program by its key.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @param key - The name of the export to find (e.g., \"default\" or a named export).\n * @returns The declaration of the export if found, otherwise undefined.\n */\nexport function findExport(ast: ParseResult<t.File>, key: string) {\n const type =\n key === \"default\" ? \"ExportDefaultDeclaration\" : \"ExportNamedDeclaration\";\n\n for (const node of ast.program.body) {\n if (node.type === type) {\n if (key === \"default\") {\n return node.declaration;\n }\n if (node.declaration && \"declarations\" in node.declaration) {\n const declaration = node.declaration.declarations[0];\n if (\n declaration &&\n \"name\" in declaration.id &&\n declaration.id.name === key\n ) {\n return declaration.init as any;\n }\n }\n }\n }\n}\n\n/**\n * Lists all exports from the given Babel AST program.\n *\n * @param codeOrAst - The parsed Babel AST result containing the program body.\n * @returns An array of export names, including \"default\" for default exports.\n */\nexport function listExports(codeOrAst: ParseResult<t.File> | string) {\n const ast = isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst;\n\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ExportDefaultDeclaration\") {\n return [\"default\"];\n }\n if (\n i.type === \"ExportNamedDeclaration\" &&\n i.declaration &&\n \"declarations\" in i.declaration\n ) {\n return i.declaration.declarations.map(d =>\n \"name\" in d.id ? d.id.name : \"\"\n );\n }\n return [];\n })\n .filter(Boolean);\n}\n\n/**\n * Lists all imports from the given Babel AST program.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @returns An array of import names, including \"default\" for default imports.\n */\nexport function listImports(ast: ParseResult<t.File> | t.File) {\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ImportDeclaration\") {\n return i.specifiers.map(s => {\n if (s.type === \"ImportDefaultSpecifier\") {\n return \"default\";\n }\n if (s.type === \"ImportSpecifier\" && \"imported\" in s) {\n return s.imported.type === \"Identifier\"\n ? s.imported.name\n : s.imported.value;\n }\n return \"\";\n });\n }\n\n return [];\n })\n .filter(Boolean);\n}\n\nexport function isImportCall(\n calleePath: NodePath<t.CallExpression | t.NewExpression>\n) {\n return t.isImport(calleePath.node.callee);\n}\n\n/**\n * Gets the import declaration for a given name and specifier.\n *\n * @param specifier - The specifier of the import.\n * @param name - The name of the import.\n * @param named - Optional named import.\n * @returns The import declaration.\n */\nexport function getImport(\n specifier: string,\n name: string,\n named?: string\n): t.ImportDeclaration {\n return t.importDeclaration(\n [t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))],\n t.stringLiteral(specifier)\n );\n}\n\n/**\n * Adds an import to the program if it doesn't already exist.\n *\n * @param path - The current NodePath in the AST.\n * @param specifier - The import specifier.\n */\nexport function addImport(path: NodePath<any>, specifier: ImportSpecifier) {\n addImportsToProgram(\n path.scope.getProgramParent().path as NodePath<t.Program>,\n specifier\n );\n}\n\n/*\n * Matches `import { ... } from <moduleName>;`\n * but not `import * as React from <moduleName>;`\n * `import type { Foo } from <moduleName>;`\n */\nfunction isNonNamespacedImport(\n importDeclPath: NodePath<t.ImportDeclaration>\n): boolean {\n return (\n importDeclPath\n .get(\"specifiers\")\n .filter(Boolean)\n .every(specifier => specifier?.isImportSpecifier()) &&\n importDeclPath.node.importKind !== \"type\" &&\n importDeclPath.node.importKind !== \"typeof\"\n );\n}\n\nfunction getExistingImports(\n program: NodePath<t.Program>\n): Map<string, NodePath<t.ImportDeclaration>> {\n const existingImports = new Map<string, NodePath<t.ImportDeclaration>>();\n program.traverse({\n ImportDeclaration(path) {\n if (isNonNamespacedImport(path)) {\n existingImports.set(path.node.source.value, path);\n }\n }\n });\n return existingImports;\n}\n\nexport function addImportsToProgram(\n path: NodePath<t.Program>,\n specifier: ImportSpecifier\n): void {\n const existingImports = getExistingImports(path);\n\n /**\n * If an existing import of this module exists (ie \\`import \\{ ... \\} from\n * '<moduleName>'\\`), inject new imported specifiers into the list of\n * destructured variables.\n */\n if (!existingImports.get(specifier.module)) {\n path.unshiftContainer(\n \"body\",\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(specifier.name || specifier.imported),\n t.identifier(specifier.imported)\n )\n ],\n t.stringLiteral(specifier.module)\n )\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-helpers.mjs","names":[],"sources":["../../src/helpers/module-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { NodePath } from \"@babel/core\";\nimport { ParseResult } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { ImportSpecifier } from \"../types/config\";\nimport { parseAst } from \"./ast-utils\";\n\n/**\n * Finds an export in the given Babel AST program by its key.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @param key - The name of the export to find (e.g., \"default\" or a named export).\n * @returns The declaration of the export if found, otherwise undefined.\n */\nexport function findExport(ast: ParseResult<t.File>, key: string) {\n const type =\n key === \"default\" ? \"ExportDefaultDeclaration\" : \"ExportNamedDeclaration\";\n\n for (const node of ast.program.body) {\n if (node.type === type) {\n if (key === \"default\") {\n return node.declaration;\n }\n if (node.declaration && \"declarations\" in node.declaration) {\n const declaration = node.declaration.declarations[0];\n if (\n declaration &&\n \"name\" in declaration.id &&\n declaration.id.name === key\n ) {\n return declaration.init as any;\n }\n }\n }\n }\n}\n\n/**\n * Lists all exports from the given Babel AST program.\n *\n * @param codeOrAst - The parsed Babel AST result containing the program body.\n * @returns An array of export names, including \"default\" for default exports.\n */\nexport function listExports(codeOrAst: ParseResult<t.File> | string) {\n const ast = isString(codeOrAst) ? parseAst(codeOrAst) : codeOrAst;\n\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ExportDefaultDeclaration\") {\n return [\"default\"];\n }\n if (\n i.type === \"ExportNamedDeclaration\" &&\n i.declaration &&\n \"declarations\" in i.declaration\n ) {\n return i.declaration.declarations.map(d =>\n \"name\" in d.id ? d.id.name : \"\"\n );\n }\n return [];\n })\n .filter(Boolean);\n}\n\n/**\n * Lists all imports from the given Babel AST program.\n *\n * @param ast - The parsed Babel AST result containing the program body.\n * @returns An array of import names, including \"default\" for default imports.\n */\nexport function listImports(ast: ParseResult<t.File> | t.File) {\n return ast.program.body\n .flatMap(i => {\n if (i.type === \"ImportDeclaration\") {\n return i.specifiers.map(s => {\n if (s.type === \"ImportDefaultSpecifier\") {\n return \"default\";\n }\n if (s.type === \"ImportSpecifier\" && \"imported\" in s) {\n return s.imported.type === \"Identifier\"\n ? s.imported.name\n : s.imported.value;\n }\n return \"\";\n });\n }\n\n return [];\n })\n .filter(Boolean);\n}\n\nexport function isImportCall(\n calleePath: NodePath<t.CallExpression | t.NewExpression>\n) {\n return t.isImport(calleePath.node.callee);\n}\n\n/**\n * Gets the import declaration for a given name and specifier.\n *\n * @param specifier - The specifier of the import.\n * @param name - The name of the import.\n * @param named - Optional named import.\n * @returns The import declaration.\n */\nexport function getImport(\n specifier: string,\n name: string,\n named?: string\n): t.ImportDeclaration {\n return t.importDeclaration(\n [t.importSpecifier(t.identifier(name), t.stringLiteral(named || name))],\n t.stringLiteral(specifier)\n );\n}\n\n/**\n * Adds an import to the program if it doesn't already exist.\n *\n * @param path - The current NodePath in the AST.\n * @param specifier - The import specifier.\n */\nexport function addImport(path: NodePath<any>, specifier: ImportSpecifier) {\n addImportsToProgram(\n path.scope.getProgramParent().path as NodePath<t.Program>,\n specifier\n );\n}\n\n/*\n * Matches `import { ... } from <moduleName>;`\n * but not `import * as React from <moduleName>;`\n * `import type { Foo } from <moduleName>;`\n */\nfunction isNonNamespacedImport(\n importDeclPath: NodePath<t.ImportDeclaration>\n): boolean {\n return (\n importDeclPath\n .get(\"specifiers\")\n .filter(Boolean)\n .every(specifier => specifier?.isImportSpecifier()) &&\n importDeclPath.node.importKind !== \"type\" &&\n importDeclPath.node.importKind !== \"typeof\"\n );\n}\n\nfunction getExistingImports(\n program: NodePath<t.Program>\n): Map<string, NodePath<t.ImportDeclaration>> {\n const existingImports = new Map<string, NodePath<t.ImportDeclaration>>();\n program.traverse({\n ImportDeclaration(path) {\n if (isNonNamespacedImport(path)) {\n existingImports.set(path.node.source.value, path);\n }\n }\n });\n return existingImports;\n}\n\nexport function addImportsToProgram(\n path: NodePath<t.Program>,\n specifier: ImportSpecifier\n): void {\n const existingImports = getExistingImports(path);\n\n /**\n * If an existing import of this module exists (ie \\`import \\{ ... \\} from\n * '<moduleName>'\\`), inject new imported specifiers into the list of\n * destructured variables.\n */\n if (!existingImports.get(specifier.module)) {\n path.unshiftContainer(\n \"body\",\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(specifier.name || specifier.imported),\n t.identifier(specifier.imported)\n )\n ],\n t.stringLiteral(specifier.module)\n )\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,WAAW,KAA0B,KAAa;CAChE,MAAM,OACJ,QAAQ,YAAY,6BAA6B;CAEnD,KAAK,MAAM,QAAQ,IAAI,QAAQ,MAC7B,IAAI,KAAK,SAAS,MAAM;EACtB,IAAI,QAAQ,WACV,OAAO,KAAK;EAEd,IAAI,KAAK,eAAe,kBAAkB,KAAK,aAAa;GAC1D,MAAM,cAAc,KAAK,YAAY,aAAa;GAClD,IACE,eACA,UAAU,YAAY,MACtB,YAAY,GAAG,SAAS,KAExB,OAAO,YAAY;EAEvB;CACF;AAEJ;;;;;;;AAQA,SAAgB,YAAY,WAAyC;CAGnE,QAFY,SAAS,SAAS,IAAI,SAAS,SAAS,IAAI,WAE7C,QAAQ,KAChB,SAAQ,MAAK;EACZ,IAAI,EAAE,SAAS,4BACb,OAAO,CAAC,SAAS;EAEnB,IACE,EAAE,SAAS,4BACX,EAAE,eACF,kBAAkB,EAAE,aAEpB,OAAO,EAAE,YAAY,aAAa,KAAI,MACpC,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,EAC/B;EAEF,OAAO,CAAC;CACV,CAAC,EACA,OAAO,OAAO;AACnB;;;;;;;AAQA,SAAgB,YAAY,KAAmC;CAC7D,OAAO,IAAI,QAAQ,KAChB,SAAQ,MAAK;EACZ,IAAI,EAAE,SAAS,qBACb,OAAO,EAAE,WAAW,KAAI,MAAK;GAC3B,IAAI,EAAE,SAAS,0BACb,OAAO;GAET,IAAI,EAAE,SAAS,qBAAqB,cAAc,GAChD,OAAO,EAAE,SAAS,SAAS,eACvB,EAAE,SAAS,OACX,EAAE,SAAS;GAEjB,OAAO;EACT,CAAC;EAGH,OAAO,CAAC;CACV,CAAC,EACA,OAAO,OAAO;AACnB;AAEA,SAAgB,aACd,YACA;CACA,OAAO,EAAE,SAAS,WAAW,KAAK,MAAM;AAC1C;;;;;;;;;AAUA,SAAgB,UACd,WACA,MACA,OACqB;CACrB,OAAO,EAAE,kBACP,CAAC,EAAE,gBAAgB,EAAE,WAAW,IAAI,GAAG,EAAE,cAAc,SAAS,IAAI,CAAC,CAAC,GACtE,EAAE,cAAc,SAAS,CAC3B;AACF;;;;;;;AAQA,SAAgB,UAAU,MAAqB,WAA4B;CACzE,oBACE,KAAK,MAAM,iBAAiB,EAAE,MAC9B,SACF;AACF;AAOA,SAAS,sBACP,gBACS;CACT,OACE,eACG,IAAI,YAAY,EAChB,OAAO,OAAO,EACd,OAAM,cAAa,WAAW,kBAAkB,CAAC,KACpD,eAAe,KAAK,eAAe,UACnC,eAAe,KAAK,eAAe;AAEvC;AAEA,SAAS,mBACP,SAC4C;CAC5C,MAAM,kCAAkB,IAAI,IAA2C;CACvE,QAAQ,SAAS,EACf,kBAAkB,MAAM;EACtB,IAAI,sBAAsB,IAAI,GAC5B,gBAAgB,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI;CAEpD,EACF,CAAC;CACD,OAAO;AACT;AAEA,SAAgB,oBACd,MACA,WACM;;;;;;CAQN,IAAI,CAPoB,mBAAmB,IAOxB,EAAE,IAAI,UAAU,MAAM,GACvC,KAAK,iBACH,QACA,EAAE,kBACA,CACE,EAAE,gBACA,EAAE,WAAW,UAAU,QAAQ,UAAU,QAAQ,GACjD,EAAE,WAAW,UAAU,QAAQ,CACjC,CACF,GACA,EAAE,cAAc,UAAU,MAAM,CAClC,CACF;AAEJ"}
|
package/dist/helpers/options.cjs
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_chunk = require('../chunk-
|
|
2
|
+
const require_chunk = require('../chunk-C_NdSu1c.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
6
|
chalk = require_chunk.__toESM(chalk, 1);
|
|
7
7
|
|
|
8
8
|
//#region src/helpers/options.ts
|
|
9
|
-
var options_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
10
|
-
getUniquePlugins: () => getUniquePlugins,
|
|
11
|
-
getUniquePresets: () => getUniquePresets,
|
|
12
|
-
resolveBabelPlugin: () => resolveBabelPlugin,
|
|
13
|
-
resolveBabelPreset: () => resolveBabelPreset,
|
|
14
|
-
resolvePluginFunction: () => resolvePluginFunction,
|
|
15
|
-
resolvePresetFunction: () => resolvePresetFunction
|
|
16
|
-
});
|
|
17
9
|
function resolvePluginFunction(context, plugin) {
|
|
18
10
|
try {
|
|
19
11
|
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? (0, _stryke_type_checks_is_function.isFunction)(plugin[0]) ? plugin[0](context) : plugin[0] : (0, _stryke_type_checks_is_function.isFunction)(plugin) ? plugin(context) : plugin;
|
|
@@ -118,12 +110,6 @@ function getUniquePresets(presets) {
|
|
|
118
110
|
//#endregion
|
|
119
111
|
exports.getUniquePlugins = getUniquePlugins;
|
|
120
112
|
exports.getUniquePresets = getUniquePresets;
|
|
121
|
-
Object.defineProperty(exports, 'options_exports', {
|
|
122
|
-
enumerable: true,
|
|
123
|
-
get: function () {
|
|
124
|
-
return options_exports;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
113
|
exports.resolveBabelPlugin = resolveBabelPlugin;
|
|
128
114
|
exports.resolveBabelPreset = resolveBabelPreset;
|
|
129
115
|
exports.resolvePluginFunction = resolvePluginFunction;
|
package/dist/helpers/options.mjs
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { t as __exportAll } from "../chunk-w6R9maHv.mjs";
|
|
2
1
|
import { getPluginName, includesPlugin, includesPreset } from "./filters.mjs";
|
|
3
2
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
4
3
|
import chalk from "chalk";
|
|
5
4
|
|
|
6
5
|
//#region src/helpers/options.ts
|
|
7
|
-
var options_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
getUniquePlugins: () => getUniquePlugins,
|
|
9
|
-
getUniquePresets: () => getUniquePresets,
|
|
10
|
-
resolveBabelPlugin: () => resolveBabelPlugin,
|
|
11
|
-
resolveBabelPreset: () => resolveBabelPreset,
|
|
12
|
-
resolvePluginFunction: () => resolvePluginFunction,
|
|
13
|
-
resolvePresetFunction: () => resolvePresetFunction
|
|
14
|
-
});
|
|
15
6
|
function resolvePluginFunction(context, plugin) {
|
|
16
7
|
try {
|
|
17
8
|
return Array.isArray(plugin) && plugin.length > 0 && plugin[0] ? isFunction(plugin[0]) ? plugin[0](context) : plugin[0] : isFunction(plugin) ? plugin(context) : plugin;
|
|
@@ -114,5 +105,5 @@ function getUniquePresets(presets) {
|
|
|
114
105
|
}
|
|
115
106
|
|
|
116
107
|
//#endregion
|
|
117
|
-
export { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction
|
|
108
|
+
export { getUniquePlugins, getUniquePresets, resolveBabelPlugin, resolveBabelPreset, resolvePluginFunction, resolvePresetFunction };
|
|
118
109
|
//# sourceMappingURL=options.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/helpers/options.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 {\n PluginItem,\n PluginTarget,\n PresetItem,\n PresetTarget\n} from \"@babel/core\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport chalk from \"chalk\";\nimport { Context } from \"powerlines\";\nimport {\n BabelTransformPluginOptions,\n BabelTransformPresetOptions,\n ResolvedBabelTransformPluginOptions,\n ResolvedBabelTransformPresetOptions\n} from \"../types/config\";\nimport { getPluginName, includesPlugin, includesPreset } from \"./filters\";\n\nexport function resolvePluginFunction(\n context: Context,\n plugin:\n | any\n | PluginTarget\n | any[]\n | [PluginTarget, PluginItem]\n | [PluginTarget, PluginItem, string | undefined]\n): BabelTransformPluginOptions {\n try {\n return Array.isArray(plugin) && plugin.length > 0 && plugin[0]\n ? isFunction(plugin[0])\n ? plugin[0](context)\n : plugin[0]\n : isFunction(plugin)\n ? plugin(context)\n : plugin;\n } catch {\n return plugin[0];\n }\n}\n\nexport function resolvePresetFunction(\n context: Context,\n preset:\n | any\n | PresetTarget\n | any[]\n | [PresetTarget, PresetItem]\n | [PresetTarget, PresetItem, string | undefined]\n): BabelTransformPresetOptions {\n try {\n return Array.isArray(preset) && preset.length > 0 && preset[0]\n ? isFunction(preset[0])\n ? preset[0](context)\n : preset[0]\n : isFunction(preset)\n ? preset(context)\n : preset;\n } catch {\n return preset[0];\n }\n}\n\n/**\n * Resolve the [Babel](https://babeljs.io/) plugin.\n *\n * @param context - The context for the transformation.\n * @param code - The code to be transformed.\n * @param id - The ID of the source file.\n * @param plugin - The Babel plugin to resolve.\n * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.\n */\nexport function resolveBabelPlugin(\n context: Context,\n code: string,\n id: string,\n plugin: BabelTransformPluginOptions\n): ResolvedBabelTransformPluginOptions | undefined {\n if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {\n if (\n plugin.length > 2 &&\n plugin[2] &&\n isFunction(plugin[2]) &&\n !plugin[2](code, id)\n ) {\n context.trace(\n `Skipping filtered Babel plugin ${chalk.bold.cyanBright(\n getPluginName(plugin) || \"unnamed\"\n )} for ${id}`\n );\n\n return undefined;\n }\n\n return (\n plugin.length > 2\n ? [resolvePluginFunction(context, plugin), plugin[1], plugin[2]]\n : [resolvePluginFunction(context, plugin), plugin[1], null]\n ) as ResolvedBabelTransformPluginOptions;\n }\n\n return [\n resolvePluginFunction(context, plugin),\n {},\n null\n ] as ResolvedBabelTransformPluginOptions;\n}\n\n/**\n * Resolve the [Babel](https://babeljs.io/) preset.\n *\n * @param context - The context for the transformation.\n * @param code - The code to be transformed.\n * @param id - The ID of the source file.\n * @param preset - The Babel preset to resolve.\n * @returns The resolved Babel preset options, or undefined if the preset is filtered out.\n */\nexport function resolveBabelPreset(\n context: Context,\n code: string,\n id: string,\n preset: BabelTransformPresetOptions\n): ResolvedBabelTransformPresetOptions | undefined {\n if (Array.isArray(preset) && preset.length > 0 && preset[0]) {\n if (\n preset.length > 2 &&\n preset[2] &&\n isFunction(preset[2]) &&\n !preset[2](code, id)\n ) {\n context.trace(\n `Skipping filtered Babel preset ${chalk.bold.cyanBright(\n getPluginName(preset) || \"unnamed\"\n )} for ${id}`\n );\n\n return undefined;\n }\n\n return (\n preset.length > 2\n ? [resolvePresetFunction(context, preset), preset[1], preset[2]]\n : [resolvePresetFunction(context, preset), preset[1], null]\n ) as ResolvedBabelTransformPresetOptions;\n }\n\n return [\n resolvePresetFunction(context, preset),\n {},\n null\n ] as ResolvedBabelTransformPresetOptions;\n}\n\n/**\n * Get a list of unique Babel plugins, filtering out duplicates based on their names.\n *\n * @param plugins - The list of Babel plugins to filter for uniqueness.\n * @returns A list of unique Babel plugins.\n */\nexport function getUniquePlugins<\n T extends BabelTransformPluginOptions | ResolvedBabelTransformPluginOptions\n>(plugins: T[]): T[] {\n return plugins.reduce((ret: T[], plugin: T) => {\n if (plugin && !includesPlugin(ret, plugin)) {\n ret.push(plugin);\n }\n\n return ret;\n }, []);\n}\n\n/**\n * Get a list of unique Babel presets, filtering out duplicates based on their names.\n *\n * @param presets - The list of Babel presets to filter for uniqueness.\n * @returns A list of unique Babel presets.\n */\nexport function getUniquePresets<\n T extends BabelTransformPresetOptions | ResolvedBabelTransformPresetOptions\n>(presets: T[]): T[] {\n return presets.reduce((ret: T[], preset: T) => {\n if (preset && !includesPreset(ret, preset)) {\n ret.push(preset);\n }\n\n return ret;\n }, []);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/helpers/options.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 {\n PluginItem,\n PluginTarget,\n PresetItem,\n PresetTarget\n} from \"@babel/core\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport chalk from \"chalk\";\nimport { Context } from \"powerlines\";\nimport {\n BabelTransformPluginOptions,\n BabelTransformPresetOptions,\n ResolvedBabelTransformPluginOptions,\n ResolvedBabelTransformPresetOptions\n} from \"../types/config\";\nimport { getPluginName, includesPlugin, includesPreset } from \"./filters\";\n\nexport function resolvePluginFunction(\n context: Context,\n plugin:\n | any\n | PluginTarget\n | any[]\n | [PluginTarget, PluginItem]\n | [PluginTarget, PluginItem, string | undefined]\n): BabelTransformPluginOptions {\n try {\n return Array.isArray(plugin) && plugin.length > 0 && plugin[0]\n ? isFunction(plugin[0])\n ? plugin[0](context)\n : plugin[0]\n : isFunction(plugin)\n ? plugin(context)\n : plugin;\n } catch {\n return plugin[0];\n }\n}\n\nexport function resolvePresetFunction(\n context: Context,\n preset:\n | any\n | PresetTarget\n | any[]\n | [PresetTarget, PresetItem]\n | [PresetTarget, PresetItem, string | undefined]\n): BabelTransformPresetOptions {\n try {\n return Array.isArray(preset) && preset.length > 0 && preset[0]\n ? isFunction(preset[0])\n ? preset[0](context)\n : preset[0]\n : isFunction(preset)\n ? preset(context)\n : preset;\n } catch {\n return preset[0];\n }\n}\n\n/**\n * Resolve the [Babel](https://babeljs.io/) plugin.\n *\n * @param context - The context for the transformation.\n * @param code - The code to be transformed.\n * @param id - The ID of the source file.\n * @param plugin - The Babel plugin to resolve.\n * @returns The resolved Babel plugin options, or undefined if the plugin is filtered out.\n */\nexport function resolveBabelPlugin(\n context: Context,\n code: string,\n id: string,\n plugin: BabelTransformPluginOptions\n): ResolvedBabelTransformPluginOptions | undefined {\n if (Array.isArray(plugin) && plugin.length > 0 && plugin[0]) {\n if (\n plugin.length > 2 &&\n plugin[2] &&\n isFunction(plugin[2]) &&\n !plugin[2](code, id)\n ) {\n context.trace(\n `Skipping filtered Babel plugin ${chalk.bold.cyanBright(\n getPluginName(plugin) || \"unnamed\"\n )} for ${id}`\n );\n\n return undefined;\n }\n\n return (\n plugin.length > 2\n ? [resolvePluginFunction(context, plugin), plugin[1], plugin[2]]\n : [resolvePluginFunction(context, plugin), plugin[1], null]\n ) as ResolvedBabelTransformPluginOptions;\n }\n\n return [\n resolvePluginFunction(context, plugin),\n {},\n null\n ] as ResolvedBabelTransformPluginOptions;\n}\n\n/**\n * Resolve the [Babel](https://babeljs.io/) preset.\n *\n * @param context - The context for the transformation.\n * @param code - The code to be transformed.\n * @param id - The ID of the source file.\n * @param preset - The Babel preset to resolve.\n * @returns The resolved Babel preset options, or undefined if the preset is filtered out.\n */\nexport function resolveBabelPreset(\n context: Context,\n code: string,\n id: string,\n preset: BabelTransformPresetOptions\n): ResolvedBabelTransformPresetOptions | undefined {\n if (Array.isArray(preset) && preset.length > 0 && preset[0]) {\n if (\n preset.length > 2 &&\n preset[2] &&\n isFunction(preset[2]) &&\n !preset[2](code, id)\n ) {\n context.trace(\n `Skipping filtered Babel preset ${chalk.bold.cyanBright(\n getPluginName(preset) || \"unnamed\"\n )} for ${id}`\n );\n\n return undefined;\n }\n\n return (\n preset.length > 2\n ? [resolvePresetFunction(context, preset), preset[1], preset[2]]\n : [resolvePresetFunction(context, preset), preset[1], null]\n ) as ResolvedBabelTransformPresetOptions;\n }\n\n return [\n resolvePresetFunction(context, preset),\n {},\n null\n ] as ResolvedBabelTransformPresetOptions;\n}\n\n/**\n * Get a list of unique Babel plugins, filtering out duplicates based on their names.\n *\n * @param plugins - The list of Babel plugins to filter for uniqueness.\n * @returns A list of unique Babel plugins.\n */\nexport function getUniquePlugins<\n T extends BabelTransformPluginOptions | ResolvedBabelTransformPluginOptions\n>(plugins: T[]): T[] {\n return plugins.reduce((ret: T[], plugin: T) => {\n if (plugin && !includesPlugin(ret, plugin)) {\n ret.push(plugin);\n }\n\n return ret;\n }, []);\n}\n\n/**\n * Get a list of unique Babel presets, filtering out duplicates based on their names.\n *\n * @param presets - The list of Babel presets to filter for uniqueness.\n * @returns A list of unique Babel presets.\n */\nexport function getUniquePresets<\n T extends BabelTransformPresetOptions | ResolvedBabelTransformPresetOptions\n>(presets: T[]): T[] {\n return presets.reduce((ret: T[], preset: T) => {\n if (preset && !includesPreset(ret, preset)) {\n ret.push(preset);\n }\n\n return ret;\n }, []);\n}\n"],"mappings":";;;;;AAmCA,SAAgB,sBACd,SACA,QAM6B;CAC7B,IAAI;EACF,OAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,KAAK,OAAO,KACxD,WAAW,OAAO,EAAE,IAClB,OAAO,GAAG,OAAO,IACjB,OAAO,KACT,WAAW,MAAM,IACf,OAAO,OAAO,IACd;CACR,QAAQ;EACN,OAAO,OAAO;CAChB;AACF;AAEA,SAAgB,sBACd,SACA,QAM6B;CAC7B,IAAI;EACF,OAAO,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,KAAK,OAAO,KACxD,WAAW,OAAO,EAAE,IAClB,OAAO,GAAG,OAAO,IACjB,OAAO,KACT,WAAW,MAAM,IACf,OAAO,OAAO,IACd;CACR,QAAQ;EACN,OAAO,OAAO;CAChB;AACF;;;;;;;;;;AAWA,SAAgB,mBACd,SACA,MACA,IACA,QACiD;CACjD,IAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,KAAK,OAAO,IAAI;EAC3D,IACE,OAAO,SAAS,KAChB,OAAO,MACP,WAAW,OAAO,EAAE,KACpB,CAAC,OAAO,GAAG,MAAM,EAAE,GACnB;GACA,QAAQ,MACN,kCAAkC,MAAM,KAAK,WAC3C,cAAc,MAAM,KAAK,SAC3B,EAAE,OAAO,IACX;GAEA;EACF;EAEA,OACE,OAAO,SAAS,IACZ;GAAC,sBAAsB,SAAS,MAAM;GAAG,OAAO;GAAI,OAAO;EAAE,IAC7D;GAAC,sBAAsB,SAAS,MAAM;GAAG,OAAO;GAAI;EAAI;CAEhE;CAEA,OAAO;EACL,sBAAsB,SAAS,MAAM;EACrC,CAAC;EACD;CACF;AACF;;;;;;;;;;AAWA,SAAgB,mBACd,SACA,MACA,IACA,QACiD;CACjD,IAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,KAAK,OAAO,IAAI;EAC3D,IACE,OAAO,SAAS,KAChB,OAAO,MACP,WAAW,OAAO,EAAE,KACpB,CAAC,OAAO,GAAG,MAAM,EAAE,GACnB;GACA,QAAQ,MACN,kCAAkC,MAAM,KAAK,WAC3C,cAAc,MAAM,KAAK,SAC3B,EAAE,OAAO,IACX;GAEA;EACF;EAEA,OACE,OAAO,SAAS,IACZ;GAAC,sBAAsB,SAAS,MAAM;GAAG,OAAO;GAAI,OAAO;EAAE,IAC7D;GAAC,sBAAsB,SAAS,MAAM;GAAG,OAAO;GAAI;EAAI;CAEhE;CAEA,OAAO;EACL,sBAAsB,SAAS,MAAM;EACrC,CAAC;EACD;CACF;AACF;;;;;;;AAQA,SAAgB,iBAEd,SAAmB;CACnB,OAAO,QAAQ,QAAQ,KAAU,WAAc;EAC7C,IAAI,UAAU,CAAC,eAAe,KAAK,MAAM,GACvC,IAAI,KAAK,MAAM;EAGjB,OAAO;CACT,GAAG,CAAC,CAAC;AACP;;;;;;;AAQA,SAAgB,iBAEd,SAAmB;CACnB,OAAO,QAAQ,QAAQ,KAAU,WAAc;EAC7C,IAAI,UAAU,CAAC,eAAe,KAAK,MAAM,GACvC,IAAI,KAAK,MAAM;EAGjB,OAAO;CACT,GAAG,CAAC,CAAC;AACP"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_chunk = require('./chunk-
|
|
2
|
+
const require_chunk = require('./chunk-C_NdSu1c.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');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-babel",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.96",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"keywords": ["babel", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -90,16 +90,16 @@
|
|
|
90
90
|
"@babel/helper-plugin-utils": "8.0.0-rc.6",
|
|
91
91
|
"@babel/parser": "8.0.0-rc.6",
|
|
92
92
|
"@babel/types": "8.0.0-rc.6",
|
|
93
|
-
"@powerlines/core": "^0.48.
|
|
93
|
+
"@powerlines/core": "^0.48.33",
|
|
94
94
|
"@storm-software/config-tools": "^1.190.37",
|
|
95
|
-
"@stryke/fs": "^0.33.
|
|
95
|
+
"@stryke/fs": "^0.33.83",
|
|
96
96
|
"@stryke/path": "^0.29.9",
|
|
97
97
|
"@stryke/type-checks": "^0.6.15",
|
|
98
98
|
"@stryke/types": "^0.12.10",
|
|
99
99
|
"chalk": "5.6.2",
|
|
100
100
|
"defu": "^6.1.7",
|
|
101
101
|
"jiti": "^2.7.0",
|
|
102
|
-
"powerlines": "^0.47.
|
|
102
|
+
"powerlines": "^0.47.100"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@types/babel__helper-plugin-utils": "^7.10.3",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"@babel/plugin-transform-json-modules": { "optional": false }
|
|
117
117
|
},
|
|
118
118
|
"publishConfig": { "access": "public" },
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "f4ad7ee552b89cc860cb1cc2e56b20a5b779620d"
|
|
120
120
|
}
|
package/dist/chunk-w6R9maHv.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!no_symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll as t };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const require_helpers_ast_utils = require('./ast-utils.cjs');
|
|
2
|
-
let vitest = require("vitest");
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/ast-utils.test.ts
|
|
5
|
-
(0, vitest.describe)("plugins/plugin-babel/src/helpers/ast-utils.ts", () => {
|
|
6
|
-
(0, vitest.it)("loads module exports", () => {
|
|
7
|
-
(0, vitest.expect)(require_helpers_ast_utils.ast_utils_exports).toBeDefined();
|
|
8
|
-
(0, vitest.expect)(typeof require_helpers_ast_utils.ast_utils_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
(0, vitest.it)("has at least one runtime export", () => {
|
|
11
|
-
(0, vitest.expect)(Object.keys(require_helpers_ast_utils.ast_utils_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { t as ast_utils_exports } from "./ast-utils.mjs";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/ast-utils.test.ts
|
|
5
|
-
describe("plugins/plugin-babel/src/helpers/ast-utils.ts", () => {
|
|
6
|
-
it("loads module exports", () => {
|
|
7
|
-
expect(ast_utils_exports).toBeDefined();
|
|
8
|
-
expect(typeof ast_utils_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
it("has at least one runtime export", () => {
|
|
11
|
-
expect(Object.keys(ast_utils_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=ast-utils.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.test.mjs","names":["moduleExports"],"sources":["../../src/helpers/ast-utils.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./ast-utils\";\n\ndescribe(\"plugins/plugin-babel/src/helpers/ast-utils.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;AAGA,SAAS,uDAAuD;CAC9D,GAAG,8BAA8B;EAC/B,OAAOA,iBAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,iBAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,iBAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const require_helpers_create_plugin = require('./create-plugin.cjs');
|
|
2
|
-
let vitest = require("vitest");
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.test.ts
|
|
5
|
-
(0, vitest.describe)("plugins/plugin-babel/src/helpers/create-plugin.ts", () => {
|
|
6
|
-
(0, vitest.it)("loads module exports", () => {
|
|
7
|
-
(0, vitest.expect)(require_helpers_create_plugin.create_plugin_exports).toBeDefined();
|
|
8
|
-
(0, vitest.expect)(typeof require_helpers_create_plugin.create_plugin_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
(0, vitest.it)("has at least one runtime export", () => {
|
|
11
|
-
(0, vitest.expect)(Object.keys(require_helpers_create_plugin.create_plugin_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { t as create_plugin_exports } from "./create-plugin.mjs";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.test.ts
|
|
5
|
-
describe("plugins/plugin-babel/src/helpers/create-plugin.ts", () => {
|
|
6
|
-
it("loads module exports", () => {
|
|
7
|
-
expect(create_plugin_exports).toBeDefined();
|
|
8
|
-
expect(typeof create_plugin_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
it("has at least one runtime export", () => {
|
|
11
|
-
expect(Object.keys(create_plugin_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=create-plugin.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin.test.mjs","names":["moduleExports"],"sources":["../../src/helpers/create-plugin.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./create-plugin\";\n\ndescribe(\"plugins/plugin-babel/src/helpers/create-plugin.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;AAGA,SAAS,2DAA2D;CAClE,GAAG,8BAA8B;EAC/B,OAAOA,qBAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,qBAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,qBAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const require_helpers_filters = require('./filters.cjs');
|
|
2
|
-
let vitest = require("vitest");
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/filters.test.ts
|
|
5
|
-
(0, vitest.describe)("getPluginName", () => {
|
|
6
|
-
(0, vitest.it)("returns undefined for undefined input", () => {
|
|
7
|
-
(0, vitest.expect)(require_helpers_filters.getPluginName(void 0)).toBeUndefined();
|
|
8
|
-
});
|
|
9
|
-
(0, vitest.it)("returns the string when given a string", () => {
|
|
10
|
-
(0, vitest.expect)(require_helpers_filters.getPluginName("my-plugin")).toBe("my-plugin");
|
|
11
|
-
});
|
|
12
|
-
(0, vitest.it)("returns the plugin name from a named function", () => {
|
|
13
|
-
function myPlugin() {}
|
|
14
|
-
(0, vitest.expect)(require_helpers_filters.getPluginName(myPlugin)).toBe("myPlugin");
|
|
15
|
-
});
|
|
16
|
-
(0, vitest.it)("returns the name property from an object", () => {
|
|
17
|
-
(0, vitest.expect)(require_helpers_filters.getPluginName({
|
|
18
|
-
name: "test-plugin",
|
|
19
|
-
apply: () => {}
|
|
20
|
-
})).toBe("test-plugin");
|
|
21
|
-
});
|
|
22
|
-
(0, vitest.it)("extracts name from the first element of an array", () => {
|
|
23
|
-
(0, vitest.expect)(require_helpers_filters.getPluginName(["my-plugin", {}])).toBe("my-plugin");
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
(0, vitest.describe)("includesPlugin", () => {
|
|
27
|
-
(0, vitest.it)("returns false when plugin name is not found in list", () => {
|
|
28
|
-
(0, vitest.expect)(require_helpers_filters.includesPlugin([["other-plugin", {}]], ["my-plugin", {}])).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
(0, vitest.it)("returns false when plugin has no name", () => {
|
|
31
|
-
(0, vitest.expect)(require_helpers_filters.includesPlugin([[{}]], [{}])).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
(0, vitest.describe)("includesPreset", () => {
|
|
35
|
-
(0, vitest.it)("is a function", () => {
|
|
36
|
-
(0, vitest.expect)(typeof require_helpers_filters.includesPreset).toBe("function");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getPluginName, includesPlugin, includesPreset } from "./filters.mjs";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/filters.test.ts
|
|
5
|
-
describe("getPluginName", () => {
|
|
6
|
-
it("returns undefined for undefined input", () => {
|
|
7
|
-
expect(getPluginName(void 0)).toBeUndefined();
|
|
8
|
-
});
|
|
9
|
-
it("returns the string when given a string", () => {
|
|
10
|
-
expect(getPluginName("my-plugin")).toBe("my-plugin");
|
|
11
|
-
});
|
|
12
|
-
it("returns the plugin name from a named function", () => {
|
|
13
|
-
function myPlugin() {}
|
|
14
|
-
expect(getPluginName(myPlugin)).toBe("myPlugin");
|
|
15
|
-
});
|
|
16
|
-
it("returns the name property from an object", () => {
|
|
17
|
-
expect(getPluginName({
|
|
18
|
-
name: "test-plugin",
|
|
19
|
-
apply: () => {}
|
|
20
|
-
})).toBe("test-plugin");
|
|
21
|
-
});
|
|
22
|
-
it("extracts name from the first element of an array", () => {
|
|
23
|
-
expect(getPluginName(["my-plugin", {}])).toBe("my-plugin");
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe("includesPlugin", () => {
|
|
27
|
-
it("returns false when plugin name is not found in list", () => {
|
|
28
|
-
expect(includesPlugin([["other-plugin", {}]], ["my-plugin", {}])).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
it("returns false when plugin has no name", () => {
|
|
31
|
-
expect(includesPlugin([[{}]], [{}])).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe("includesPreset", () => {
|
|
35
|
-
it("is a function", () => {
|
|
36
|
-
expect(typeof includesPreset).toBe("function");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { };
|
|
42
|
-
//# sourceMappingURL=filters.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.test.mjs","names":[],"sources":["../../src/helpers/filters.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { getPluginName, includesPlugin, includesPreset } from \"./filters\";\n\ndescribe(\"getPluginName\", () => {\n it(\"returns undefined for undefined input\", () => {\n expect(getPluginName(undefined)).toBeUndefined();\n });\n\n it(\"returns the string when given a string\", () => {\n expect(getPluginName(\"my-plugin\")).toBe(\"my-plugin\");\n });\n\n it(\"returns the plugin name from a named function\", () => {\n function myPlugin() {}\n expect(getPluginName(myPlugin)).toBe(\"myPlugin\");\n });\n\n it(\"returns the name property from an object\", () => {\n const plugin = { name: \"test-plugin\", apply: () => {} };\n expect(getPluginName(plugin)).toBe(\"test-plugin\");\n });\n\n it(\"extracts name from the first element of an array\", () => {\n expect(getPluginName([\"my-plugin\", {}])).toBe(\"my-plugin\");\n });\n});\n\ndescribe(\"includesPlugin\", () => {\n it(\"returns false when plugin name is not found in list\", () => {\n const plugins = [[\"other-plugin\", {}]] as any[];\n expect(includesPlugin(plugins, [\"my-plugin\", {}] as any)).toBe(false);\n });\n\n it(\"returns false when plugin has no name\", () => {\n const plugins = [[{}]] as any[];\n expect(includesPlugin(plugins, [{}] as any)).toBe(false);\n });\n});\n\ndescribe(\"includesPreset\", () => {\n it(\"is a function\", () => {\n expect(typeof includesPreset).toBe(\"function\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,uBAAuB;CAC9B,GAAG,+CAA+C;EAChD,OAAO,cAAc,MAAS,CAAC,EAAE,cAAc;CACjD,CAAC;CAED,GAAG,gDAAgD;EACjD,OAAO,cAAc,WAAW,CAAC,EAAE,KAAK,WAAW;CACrD,CAAC;CAED,GAAG,uDAAuD;EACxD,SAAS,WAAW,CAAC;EACrB,OAAO,cAAc,QAAQ,CAAC,EAAE,KAAK,UAAU;CACjD,CAAC;CAED,GAAG,kDAAkD;EAEnD,OAAO,cAAc;GADJ,MAAM;GAAe,aAAa,CAAC;EAC1B,CAAC,CAAC,EAAE,KAAK,aAAa;CAClD,CAAC;CAED,GAAG,0DAA0D;EAC3D,OAAO,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW;CAC3D,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB;CAC/B,GAAG,6DAA6D;EAE9D,OAAO,eAAe,CADL,CAAC,gBAAgB,CAAC,CAAC,CACR,GAAG,CAAC,aAAa,CAAC,CAAC,CAAQ,CAAC,EAAE,KAAK,KAAK;CACtE,CAAC;CAED,GAAG,+CAA+C;EAEhD,OAAO,eAAe,CADL,CAAC,CAAC,CAAC,CACQ,GAAG,CAAC,CAAC,CAAC,CAAQ,CAAC,EAAE,KAAK,KAAK;CACzD,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB;CAC/B,GAAG,uBAAuB;EACxB,OAAO,OAAO,cAAc,EAAE,KAAK,UAAU;CAC/C,CAAC;AACH,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const require_helpers_module_helpers = require('./module-helpers.cjs');
|
|
2
|
-
let vitest = require("vitest");
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/module-helpers.test.ts
|
|
5
|
-
(0, vitest.describe)("plugins/plugin-babel/src/helpers/module-helpers.ts", () => {
|
|
6
|
-
(0, vitest.it)("loads module exports", () => {
|
|
7
|
-
(0, vitest.expect)(require_helpers_module_helpers.module_helpers_exports).toBeDefined();
|
|
8
|
-
(0, vitest.expect)(typeof require_helpers_module_helpers.module_helpers_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
(0, vitest.it)("has at least one runtime export", () => {
|
|
11
|
-
(0, vitest.expect)(Object.keys(require_helpers_module_helpers.module_helpers_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { t as module_helpers_exports } from "./module-helpers.mjs";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/module-helpers.test.ts
|
|
5
|
-
describe("plugins/plugin-babel/src/helpers/module-helpers.ts", () => {
|
|
6
|
-
it("loads module exports", () => {
|
|
7
|
-
expect(module_helpers_exports).toBeDefined();
|
|
8
|
-
expect(typeof module_helpers_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
it("has at least one runtime export", () => {
|
|
11
|
-
expect(Object.keys(module_helpers_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=module-helpers.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-helpers.test.mjs","names":["moduleExports"],"sources":["../../src/helpers/module-helpers.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./module-helpers\";\n\ndescribe(\"plugins/plugin-babel/src/helpers/module-helpers.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;AAGA,SAAS,4DAA4D;CACnE,GAAG,8BAA8B;EAC/B,OAAOA,sBAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,sBAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,sBAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const require_helpers_options = require('./options.cjs');
|
|
2
|
-
let vitest = require("vitest");
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/options.test.ts
|
|
5
|
-
(0, vitest.describe)("plugins/plugin-babel/src/helpers/options.ts", () => {
|
|
6
|
-
(0, vitest.it)("loads module exports", () => {
|
|
7
|
-
(0, vitest.expect)(require_helpers_options.options_exports).toBeDefined();
|
|
8
|
-
(0, vitest.expect)(typeof require_helpers_options.options_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
(0, vitest.it)("has at least one runtime export", () => {
|
|
11
|
-
(0, vitest.expect)(Object.keys(require_helpers_options.options_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { t as options_exports } from "./options.mjs";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/options.test.ts
|
|
5
|
-
describe("plugins/plugin-babel/src/helpers/options.ts", () => {
|
|
6
|
-
it("loads module exports", () => {
|
|
7
|
-
expect(options_exports).toBeDefined();
|
|
8
|
-
expect(typeof options_exports).toBe("object");
|
|
9
|
-
});
|
|
10
|
-
it("has at least one runtime export", () => {
|
|
11
|
-
expect(Object.keys(options_exports).length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { };
|
|
17
|
-
//# sourceMappingURL=options.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.test.mjs","names":["moduleExports"],"sources":["../../src/helpers/options.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./options\";\n\ndescribe(\"plugins/plugin-babel/src/helpers/options.ts\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n\n it(\"has at least one runtime export\", () => {\n expect(Object.keys(moduleExports).length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;;;AAGA,SAAS,qDAAqD;CAC5D,GAAG,8BAA8B;EAC/B,OAAOA,eAAa,EAAE,YAAY;EAClC,OAAO,OAAOA,eAAa,EAAE,KAAK,QAAQ;CAC5C,CAAC;CAED,GAAG,yCAAyC;EAC1C,OAAO,OAAO,KAAKA,eAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC;CAC7D,CAAC;AACH,CAAC"}
|