@powerlines/plugin-babel 0.12.261 → 0.12.263
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-CbDLau6x.cjs → _virtual/rolldown_runtime.cjs} +1 -6
- package/dist/helpers/ast-utils.cjs +34 -3
- package/dist/helpers/ast-utils.d.cts +20 -2
- package/dist/helpers/ast-utils.d.cts.map +1 -0
- package/dist/helpers/ast-utils.d.mts +20 -2
- package/dist/helpers/ast-utils.d.mts.map +1 -0
- package/dist/helpers/ast-utils.mjs +32 -2
- package/dist/helpers/ast-utils.mjs.map +1 -0
- package/dist/helpers/create-plugin.cjs +40 -2
- package/dist/helpers/create-plugin.d.cts +16 -2
- package/dist/helpers/create-plugin.d.cts.map +1 -0
- package/dist/helpers/create-plugin.d.mts +16 -2
- package/dist/helpers/create-plugin.d.mts.map +1 -0
- package/dist/helpers/create-plugin.mjs +39 -2
- package/dist/helpers/create-plugin.mjs.map +1 -0
- package/dist/helpers/filters.cjs +58 -5
- 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/filters.mjs +55 -2
- package/dist/helpers/filters.mjs.map +1 -0
- package/dist/helpers/index.cjs +21 -22
- package/dist/helpers/index.d.cts +5 -6
- package/dist/helpers/index.d.mts +5 -6
- package/dist/helpers/index.mjs +5 -6
- package/dist/helpers/module-helpers.cjs +102 -9
- package/dist/helpers/module-helpers.d.cts +50 -2
- package/dist/helpers/module-helpers.d.cts.map +1 -0
- package/dist/helpers/module-helpers.d.mts +50 -2
- package/dist/helpers/module-helpers.d.mts.map +1 -0
- package/dist/helpers/module-helpers.mjs +95 -3
- package/dist/helpers/module-helpers.mjs.map +1 -0
- package/dist/helpers/options.cjs +48 -4
- 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/helpers/options.mjs +46 -3
- package/dist/helpers/options.mjs.map +1 -0
- package/dist/index.cjs +27 -29
- package/dist/index.d.cts +8 -8
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +6 -8
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +20 -2
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +20 -2
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +0 -2
- package/package.json +8 -8
- package/dist/ast-utils-BcmWaIan.cjs +0 -45
- package/dist/ast-utils-Bs6DBkKg.d.mts +0 -20
- package/dist/ast-utils-Bs6DBkKg.d.mts.map +0 -1
- package/dist/ast-utils-DU1foCxH.mjs +0 -33
- package/dist/ast-utils-DU1foCxH.mjs.map +0 -1
- package/dist/ast-utils-DeuXcuqs.d.cts +0 -20
- package/dist/ast-utils-DeuXcuqs.d.cts.map +0 -1
- package/dist/create-plugin-BSNFeead.mjs +0 -40
- package/dist/create-plugin-BSNFeead.mjs.map +0 -1
- package/dist/create-plugin-Bf7dRYZB.cjs +0 -46
- package/dist/create-plugin-DU9FBfyz.d.cts +0 -16
- package/dist/create-plugin-DU9FBfyz.d.cts.map +0 -1
- package/dist/create-plugin-DgfkdI-s.d.mts +0 -16
- package/dist/create-plugin-DgfkdI-s.d.mts.map +0 -1
- package/dist/filters-CU0L1nIa.cjs +0 -79
- package/dist/filters-CpjboNi8.mjs +0 -56
- package/dist/filters-CpjboNi8.mjs.map +0 -1
- package/dist/filters-D75MrPzl.d.mts +0 -43
- package/dist/filters-D75MrPzl.d.mts.map +0 -1
- package/dist/filters-DKyk7Jxg.d.cts +0 -43
- package/dist/filters-DKyk7Jxg.d.cts.map +0 -1
- package/dist/helpers-BnW_4z5h.mjs +0 -1
- package/dist/helpers-Bx2yBrpn.cjs +0 -0
- package/dist/index-BXxhKmeA.d.mts +0 -1
- package/dist/index-CqdNToYT.d.cts +0 -1
- package/dist/index-DJOHDG5e.d.mts +0 -1
- package/dist/index-sQecLSpR.d.cts +0 -1
- package/dist/module-helpers-07-NCXys.d.cts +0 -50
- package/dist/module-helpers-07-NCXys.d.cts.map +0 -1
- package/dist/module-helpers-B1gnVB7F.d.mts +0 -50
- package/dist/module-helpers-B1gnVB7F.d.mts.map +0 -1
- package/dist/module-helpers-Ckq8sc4l.mjs +0 -96
- package/dist/module-helpers-Ckq8sc4l.mjs.map +0 -1
- package/dist/module-helpers-Non-jHMu.cjs +0 -138
- package/dist/options-2JL6WIXT.cjs +0 -59
- package/dist/options-CpZXObFr.d.mts +0 -19
- package/dist/options-CpZXObFr.d.mts.map +0 -1
- package/dist/options-DZkAyLff.d.cts +0 -19
- package/dist/options-DZkAyLff.d.cts.map +0 -1
- package/dist/options-DwynxlP6.mjs +0 -47
- package/dist/options-DwynxlP6.mjs.map +0 -1
- package/dist/plugin-BL8TLixo.mjs +0 -1
- package/dist/plugin-BSBH78mm.cjs +0 -0
- package/dist/plugin-C-FvkCBm.d.cts +0 -20
- package/dist/plugin-C-FvkCBm.d.cts.map +0 -1
- package/dist/plugin-Sxw1QP5p.d.mts +0 -20
- package/dist/plugin-Sxw1QP5p.d.mts.map +0 -1
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CvhspRRt.mjs +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "./index
|
|
7
|
-
import {
|
|
8
|
-
import "./index
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.cjs";
|
|
2
|
+
import { createBabelPlugin } from "./helpers/create-plugin.cjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.cjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.cjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.cjs";
|
|
6
|
+
import "./helpers/index.cjs";
|
|
7
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.cjs";
|
|
8
|
+
import "./types/index.cjs";
|
|
9
9
|
import { Plugin } from "powerlines/types/plugin";
|
|
10
10
|
|
|
11
11
|
//#region src/index.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "./index
|
|
7
|
-
import {
|
|
8
|
-
import "./index
|
|
1
|
+
import { GenerateFromAstOptions, GeneratorResult, __ΩGenerateFromAstOptions, generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
2
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
3
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
4
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
5
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
6
|
+
import "./helpers/index.mjs";
|
|
7
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./types/plugin.mjs";
|
|
8
|
+
import "./types/index.mjs";
|
|
9
9
|
import { Plugin } from "powerlines/types/plugin";
|
|
10
10
|
|
|
11
11
|
//#region src/index.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "./helpers
|
|
7
|
-
import "./plugin-BL8TLixo.mjs";
|
|
8
|
-
import "./types-CvhspRRt.mjs";
|
|
1
|
+
import { addPluginFilter, filterPluginByFileId, getPluginName, isDuplicatePlugin } from "./helpers/filters.mjs";
|
|
2
|
+
import { resolveBabelPlugin, resolvePluginFunction } from "./helpers/options.mjs";
|
|
3
|
+
import { generateFromAst, parseAst } from "./helpers/ast-utils.mjs";
|
|
4
|
+
import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
5
|
+
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
|
+
import "./helpers/index.mjs";
|
|
9
7
|
import { transformAsync } from "@babel/core";
|
|
10
8
|
import { findFileExtension, findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
11
9
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["plugin"],"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 {\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 { ResolvedBabelTransformPluginOptions } from \"powerlines/types/babel\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { isDuplicatePlugin } from \"./helpers/filters\";\nimport { resolveBabelPlugin } from \"./helpers/options\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\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 = <TContext extends BabelPluginContext>(\n options: BabelPluginOptions = {}\n) => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n transform: { babel: options }\n };\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.config.transform.babel = defu(this.config.transform.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.transform.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.transform.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.transform.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":["plugin"],"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 {\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 { ResolvedBabelTransformPluginOptions } from \"powerlines/types/babel\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { isDuplicatePlugin } from \"./helpers/filters\";\nimport { resolveBabelPlugin } from \"./helpers/options\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\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 = <TContext extends BabelPluginContext>(\n options: BabelPluginOptions = {}\n) => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n transform: { babel: options }\n };\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.config.transform.babel = defu(this.config.transform.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.transform.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.transform.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.transform.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":";;;;;;;;;;;;;;;;;;;AAyCA,MAAa,UACX,UAA8B,EAAE,KAC7B;AACH,QAAO;EACL,MAAM;EACN,SAAS;AACP,OAAI,CAAC,YAAY,QAAQ,CACvB;AAGF,UAAO,EACL,WAAW,EAAE,OAAO,SAAS,EAC9B;;EAEH,gBAAgB;GACd,OAAO;GACP,UAAU;AACR,SAAK,OAAO,UAAU,QAAQ,KAAK,KAAK,OAAO,UAAU,SAAS,EAAE,EAAE;KACpE,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,UAAU,MAAM,QACzC,KAAI,aAAU,mBAAmB,MAAM,MAAM,IAAIA,SAAO,CAAC,CACzD,QACE,UAAQ,GAAG,QAAQA,YAAU,CAAC,kBAAkB,KAAKA,SAAO,CAC9D;GACH,MAAM,UAAU,KAAK,OAAO,UAAU,MAAM,QACzC,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,UAAU,SAAS,EAAE;IACrC,UAAU;IACV,SAAS,QACN,KAAI,aAAU;AACb,YAAO,MAAM,QAAQA,SAAO,IAAIA,SAAO,UAAU,IAC7C,CACEA,SAAO,IACP,KAAKA,SAAO,SAAS,KAAKA,SAAO,KAAKA,SAAO,KAAK,EAAE,EAAE,EACpD,SACD,CAAC,CACH,GACDA;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;;AAGH,kBAAe"}
|
package/dist/types/index.cjs
CHANGED
package/dist/types/index.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-sQecLSpR.cjs";
|
|
1
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./plugin.cjs";
|
|
3
2
|
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../index-DJOHDG5e.mjs";
|
|
1
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig } from "./plugin.mjs";
|
|
3
2
|
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig };
|
package/dist/types/index.mjs
CHANGED
package/dist/types/plugin.cjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require('../plugin-BSBH78mm.cjs');
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { PluginContext } from "powerlines/types/context";
|
|
2
|
+
import { BabelUserConfig, UserConfig } from "powerlines/types/config";
|
|
3
|
+
import { BabelResolvedConfig, ResolvedConfig } from "powerlines/types/resolved";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
declare type __ΩBabelPluginOptions = any[];
|
|
15
|
+
declare type __ΩBabelPluginUserConfig = any[];
|
|
16
|
+
declare type __ΩBabelPluginResolvedConfig = any[];
|
|
17
|
+
declare type __ΩBabelPluginContext = any[];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig };
|
|
20
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,kBAAA,GAAqB,QAAQ;KAE7B,qBAAA,GAAwB;AAFxB,UAIK,yBAAA,SAAkC,cAJX,CAAA;EAE5B,SAAA,EAAA;IAEK,KAAA,EAEN,mBAFgC;EAM/B,CAAA;;AAC0C,KAD1C,kBAC0C,CAAA,wBAA5B,yBAA4B,GAAA,yBAAA,CAAA,GAClD,aADkD,CACpC,eADoC,CAAA;AACpC,qCAAA,GAAA,EAAA;AAAd,wCAAA,GAAA,EAAA;AAAa,4CAAA,GAAA,EAAA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { PluginContext } from "powerlines/types/context";
|
|
2
|
+
import { BabelUserConfig, UserConfig } from "powerlines/types/config";
|
|
3
|
+
import { BabelResolvedConfig, ResolvedConfig } from "powerlines/types/resolved";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
declare type __ΩBabelPluginOptions = any[];
|
|
15
|
+
declare type __ΩBabelPluginUserConfig = any[];
|
|
16
|
+
declare type __ΩBabelPluginResolvedConfig = any[];
|
|
17
|
+
declare type __ΩBabelPluginContext = any[];
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig, __ΩBabelPluginContext, __ΩBabelPluginOptions, __ΩBabelPluginResolvedConfig, __ΩBabelPluginUserConfig };
|
|
20
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAsBY,kBAAA,GAAqB,QAAQ;KAE7B,qBAAA,GAAwB;AAFxB,UAIK,yBAAA,SAAkC,cAJX,CAAA;EAE5B,SAAA,EAAA;IAEK,KAAA,EAEN,mBAFgC;EAM/B,CAAA;;AAC0C,KAD1C,kBAC0C,CAAA,wBAA5B,yBAA4B,GAAA,yBAAA,CAAA,GAClD,aADkD,CACpC,eADoC,CAAA;AACpC,qCAAA,GAAA,EAAA;AAAd,wCAAA,GAAA,EAAA;AAAa,4CAAA,GAAA,EAAA"}
|
package/dist/types/plugin.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-babel",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.263",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -185,17 +185,17 @@
|
|
|
185
185
|
"@babel/plugin-syntax-typescript": "^7.28.6",
|
|
186
186
|
"@babel/types": "^7.28.6",
|
|
187
187
|
"@storm-software/config-tools": "^1.189.0",
|
|
188
|
-
"@stryke/fs": "^0.33.
|
|
189
|
-
"@stryke/path": "^0.26.
|
|
190
|
-
"@stryke/type-checks": "^0.5.
|
|
191
|
-
"@stryke/types": "^0.10.
|
|
188
|
+
"@stryke/fs": "^0.33.40",
|
|
189
|
+
"@stryke/path": "^0.26.4",
|
|
190
|
+
"@stryke/type-checks": "^0.5.23",
|
|
191
|
+
"@stryke/types": "^0.10.37",
|
|
192
192
|
"chalk": "5.6.2",
|
|
193
193
|
"defu": "^6.1.4",
|
|
194
194
|
"jiti": "^2.6.1",
|
|
195
|
-
"powerlines": "^0.38.
|
|
195
|
+
"powerlines": "^0.38.21"
|
|
196
196
|
},
|
|
197
197
|
"devDependencies": {
|
|
198
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
198
|
+
"@powerlines/plugin-plugin": "^0.12.205",
|
|
199
199
|
"@types/node": "^24.10.9"
|
|
200
200
|
},
|
|
201
201
|
"publishConfig": {
|
|
@@ -237,5 +237,5 @@
|
|
|
237
237
|
"./package.json": "./package.json"
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
|
-
"gitHead": "
|
|
240
|
+
"gitHead": "6000a15bf3fbc1b7eaaf967088c68eef9949786a"
|
|
241
241
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
let __babel_generator = require("@babel/generator");
|
|
3
|
-
__babel_generator = require_chunk.__toESM(__babel_generator);
|
|
4
|
-
let __babel_parser = require("@babel/parser");
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/ast-utils.ts
|
|
7
|
-
/**
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
function parseAst(code, opts = {}) {
|
|
15
|
-
return (0, __babel_parser.parse)(code, {
|
|
16
|
-
plugins: ["typescript"],
|
|
17
|
-
sourceType: "module",
|
|
18
|
-
allowImportExportEverywhere: true,
|
|
19
|
-
allowAwaitOutsideFunction: true,
|
|
20
|
-
...opts
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
let generate = __babel_generator.default;
|
|
24
|
-
if ("default" in generate) generate = generate.default;
|
|
25
|
-
function generateFromAst(ast, opts) {
|
|
26
|
-
return generate(ast, opts ? {
|
|
27
|
-
importAttributesKeyword: "with",
|
|
28
|
-
sourceMaps: true,
|
|
29
|
-
...opts
|
|
30
|
-
} : void 0);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
Object.defineProperty(exports, 'generateFromAst', {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return generateFromAst;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(exports, 'parseAst', {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function () {
|
|
43
|
-
return parseAst;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
/**
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
15
|
-
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
16
|
-
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult;
|
|
17
|
-
declare type __ΩGenerateFromAstOptions = any[];
|
|
18
|
-
//#endregion
|
|
19
|
-
export { parseAst as a, generateFromAst as i, GeneratorResult$1 as n, __ΩGenerateFromAstOptions as r, GenerateFromAstOptions as t };
|
|
20
|
-
//# sourceMappingURL=ast-utils-Bs6DBkKg.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils-Bs6DBkKg.d.mts","names":[],"sources":["../src/helpers/ast-utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;AAkBY,iBAlBI,QAAA,CAkBkB,IAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAhB1B,aAgB0B,CAAA,EAf/B,WAe+B,CAfnB,CAAA,CAAE,IAeiB,CAAA;AAAG,KAAzB,sBAAA,GAAyB,gBAAA,GACnC,QADmC,CAC1B,IAD0B,CACrB,gBADqB,EAAA,gBAAA,GAAA,UAAA,CAAA,CAAA;AACrB,iBAEA,eAAA,CAFA,GAAA,EAGT,CAAA,CAAE,IAHO,EAAA,IAAA,CAAA,EAIP,sBAJO,CAAA,EAKb,eALa;AAAd,yCAAA,GAAA,EAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import _generate from "@babel/generator";
|
|
2
|
-
import { parse } from "@babel/parser";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/ast-utils.ts
|
|
5
|
-
/**
|
|
6
|
-
* Parse the given code into an AST.
|
|
7
|
-
*
|
|
8
|
-
* @param code - The code to parse.
|
|
9
|
-
* @param opts - The options for parsing.
|
|
10
|
-
* @returns The parsed AST.
|
|
11
|
-
*/
|
|
12
|
-
function parseAst(code, opts = {}) {
|
|
13
|
-
return parse(code, {
|
|
14
|
-
plugins: ["typescript"],
|
|
15
|
-
sourceType: "module",
|
|
16
|
-
allowImportExportEverywhere: true,
|
|
17
|
-
allowAwaitOutsideFunction: true,
|
|
18
|
-
...opts
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
let generate = _generate;
|
|
22
|
-
if ("default" in generate) generate = generate.default;
|
|
23
|
-
function generateFromAst(ast, opts) {
|
|
24
|
-
return generate(ast, opts ? {
|
|
25
|
-
importAttributesKeyword: "with",
|
|
26
|
-
sourceMaps: true,
|
|
27
|
-
...opts
|
|
28
|
-
} : void 0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { parseAst as n, generateFromAst as t };
|
|
33
|
-
//# sourceMappingURL=ast-utils-DU1foCxH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils-DU1foCxH.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(\n ast,\n opts\n ? { importAttributesKeyword: \"with\", sourceMaps: true, ...opts }\n : undefined\n );\n}\n\nexport type { GeneratorResult } from \"@babel/generator\";\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,SACd,MACA,OAAsB,EAAE,EACH;AACrB,QAAO,MAAM,MAAM;EACjB,SAAS,CAAC,aAAa;EACvB,YAAY;EACZ,6BAA6B;EAC7B,2BAA2B;EAC3B,GAAG;EACJ,CAAC;;AAGJ,IAAI,WAAW;AACf,IAAI,aAAa,SACf,YAAW,SAAS;AAMtB,SAAgB,gBACd,KACA,MACiB;AACjB,QAAO,SACL,KACA,OACI;EAAE,yBAAyB;EAAQ,YAAY;EAAM,GAAG;EAAM,GAC9D,OACL"}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
/**
|
|
8
|
-
* Parse the given code into an AST.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The code to parse.
|
|
11
|
-
* @param opts - The options for parsing.
|
|
12
|
-
* @returns The parsed AST.
|
|
13
|
-
*/
|
|
14
|
-
declare function parseAst(code: string, opts?: ParserOptions): ParseResult<t.File>;
|
|
15
|
-
type GenerateFromAstOptions = GeneratorOptions & Required<Pick<GeneratorOptions, "sourceFileName" | "filename">>;
|
|
16
|
-
declare function generateFromAst(ast: t.Node, opts?: GenerateFromAstOptions): GeneratorResult;
|
|
17
|
-
declare type __ΩGenerateFromAstOptions = any[];
|
|
18
|
-
//#endregion
|
|
19
|
-
export { parseAst as a, generateFromAst as i, GeneratorResult$1 as n, __ΩGenerateFromAstOptions as r, GenerateFromAstOptions as t };
|
|
20
|
-
//# sourceMappingURL=ast-utils-DeuXcuqs.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils-DeuXcuqs.d.cts","names":[],"sources":["../src/helpers/ast-utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA;;;;;AAkBY,iBAlBI,QAAA,CAkBkB,IAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAhB1B,aAgB0B,CAAA,EAf/B,WAe+B,CAfnB,CAAA,CAAE,IAeiB,CAAA;AAAG,KAAzB,sBAAA,GAAyB,gBAAA,GACnC,QADmC,CAC1B,IAD0B,CACrB,gBADqB,EAAA,gBAAA,GAAA,UAAA,CAAA,CAAA;AACrB,iBAEA,eAAA,CAFA,GAAA,EAGT,CAAA,CAAE,IAHO,EAAA,IAAA,CAAA,EAIP,sBAJO,CAAA,EAKb,eALa;AAAd,yCAAA,GAAA,EAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { declare } from "@babel/helper-plugin-utils";
|
|
3
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
4
|
-
import { extendLog } from "powerlines/lib/logger";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/create-plugin.ts
|
|
7
|
-
/**
|
|
8
|
-
* Create a Babel plugin using the provided builder function.
|
|
9
|
-
*
|
|
10
|
-
* @param name - The name of the plugin.
|
|
11
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
12
|
-
* @returns A Babel plugin declaration.
|
|
13
|
-
*/
|
|
14
|
-
function createBabelPlugin(name, builder) {
|
|
15
|
-
const plugin = (context) => {
|
|
16
|
-
return declare((api, options, dirname) => {
|
|
17
|
-
api.cache.using(() => context.meta.checksum);
|
|
18
|
-
api.assertVersion("^7.0.0-0");
|
|
19
|
-
const log = extendLog(context.log, name);
|
|
20
|
-
log(LogLevelLabel.TRACE, `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
21
|
-
const result = builder({
|
|
22
|
-
log,
|
|
23
|
-
name,
|
|
24
|
-
api,
|
|
25
|
-
options,
|
|
26
|
-
context,
|
|
27
|
-
dirname
|
|
28
|
-
});
|
|
29
|
-
result.name = name;
|
|
30
|
-
log(LogLevelLabel.TRACE, `Completed initialization of the ${chalk.bold.cyanBright(name)} Babel plugin`);
|
|
31
|
-
return result;
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
plugin.$$name = name;
|
|
35
|
-
return plugin;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { createBabelPlugin as t };
|
|
40
|
-
//# sourceMappingURL=create-plugin-BSNFeead.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin-BSNFeead.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 { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport chalk from \"chalk\";\nimport { extendLog } from \"powerlines/lib/logger\";\nimport {\n BabelTransformPluginBuilder,\n DeclareBabelTransformPluginReturn\n} from \"powerlines/types/babel\";\nimport { Context } from \"powerlines/types/context\";\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 Record<string, any> = Record<string, any>\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(\"^7.0.0-0\");\n\n const log = extendLog(context.log, name);\n log(\n LogLevelLabel.TRACE,\n `Initializing the ${chalk.bold.cyanBright(name)} Babel plugin`\n );\n\n const result = builder({\n log,\n name,\n api,\n options,\n context,\n dirname\n });\n result.name = name;\n\n log(\n LogLevelLabel.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":";;;;;;;;;;;;;AAmCA,SAAgB,kBAId,MACA,SACuD;CACvD,MAAM,UAAU,YAAsB;AACpC,SAAO,SAAmB,KAAK,SAAS,YAAY;AAClD,OAAI,MAAM,YAAY,QAAQ,KAAK,SAAS;AAC5C,OAAI,cAAc,WAAW;GAE7B,MAAM,MAAM,UAAU,QAAQ,KAAK,KAAK;AACxC,OACE,cAAc,OACd,oBAAoB,MAAM,KAAK,WAAW,KAAK,CAAC,eACjD;GAED,MAAM,SAAS,QAAQ;IACrB;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,UAAO,OAAO;AAEd,OACE,cAAc,OACd,mCAAmC,MAAM,KAAK,WAAW,KAAK,CAAC,eAChE;AAED,UAAO;IACP;;AAEJ,QAAO,SAAS;AAEhB,QAAO"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
let chalk = require("chalk");
|
|
3
|
-
chalk = require_chunk.__toESM(chalk);
|
|
4
|
-
let __babel_helper_plugin_utils = require("@babel/helper-plugin-utils");
|
|
5
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
6
|
-
let powerlines_lib_logger = require("powerlines/lib/logger");
|
|
7
|
-
|
|
8
|
-
//#region src/helpers/create-plugin.ts
|
|
9
|
-
/**
|
|
10
|
-
* Create a Babel plugin using the provided builder function.
|
|
11
|
-
*
|
|
12
|
-
* @param name - The name of the plugin.
|
|
13
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
14
|
-
* @returns A Babel plugin declaration.
|
|
15
|
-
*/
|
|
16
|
-
function createBabelPlugin(name, builder) {
|
|
17
|
-
const plugin = (context) => {
|
|
18
|
-
return (0, __babel_helper_plugin_utils.declare)((api, options, dirname) => {
|
|
19
|
-
api.cache.using(() => context.meta.checksum);
|
|
20
|
-
api.assertVersion("^7.0.0-0");
|
|
21
|
-
const log = (0, powerlines_lib_logger.extendLog)(context.log, name);
|
|
22
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
23
|
-
const result = builder({
|
|
24
|
-
log,
|
|
25
|
-
name,
|
|
26
|
-
api,
|
|
27
|
-
options,
|
|
28
|
-
context,
|
|
29
|
-
dirname
|
|
30
|
-
});
|
|
31
|
-
result.name = name;
|
|
32
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Completed initialization of the ${chalk.default.bold.cyanBright(name)} Babel plugin`);
|
|
33
|
-
return result;
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
plugin.$$name = name;
|
|
37
|
-
return plugin;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
Object.defineProperty(exports, 'createBabelPlugin', {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return createBabelPlugin;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "powerlines/types/babel";
|
|
2
|
-
import { Context } from "powerlines/types/context";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create a Babel plugin using the provided builder function.
|
|
8
|
-
*
|
|
9
|
-
* @param name - The name of the plugin.
|
|
10
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
11
|
-
* @returns A Babel plugin declaration.
|
|
12
|
-
*/
|
|
13
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { createBabelPlugin as t };
|
|
16
|
-
//# sourceMappingURL=create-plugin-DU9FBfyz.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin-DU9FBfyz.d.cts","names":[],"sources":["../src/helpers/create-plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;AAmCA;;;;;AAKuC,iBALvB,iBAKuB,CAAA,iBAJpB,OAIoB,GAJV,OAIU,EAAA,iBAHpB,MAGoB,CAAA,MAAA,EAAA,GAAA,CAAA,GAHE,MAGF,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAA5B,2BAA4B,CAAA,QAAA,EAAU,QAAV,CAAA,CAAA,EACpC,iCADoC,CACF,QADE,EACQ,QADR,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BabelTransformPluginBuilder, DeclareBabelTransformPluginReturn } from "powerlines/types/babel";
|
|
2
|
-
import { Context } from "powerlines/types/context";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create a Babel plugin using the provided builder function.
|
|
8
|
-
*
|
|
9
|
-
* @param name - The name of the plugin.
|
|
10
|
-
* @param builder - The builder function that defines the plugin behavior.
|
|
11
|
-
* @returns A Babel plugin declaration.
|
|
12
|
-
*/
|
|
13
|
-
declare function createBabelPlugin<TContext extends Context = Context, TOptions extends Record<string, any> = Record<string, any>>(name: string, builder: BabelTransformPluginBuilder<TContext, TOptions>): DeclareBabelTransformPluginReturn<TContext, TOptions>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { createBabelPlugin as t };
|
|
16
|
-
//# sourceMappingURL=create-plugin-DgfkdI-s.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin-DgfkdI-s.d.mts","names":[],"sources":["../src/helpers/create-plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;AAmCA;;;;;AAKuC,iBALvB,iBAKuB,CAAA,iBAJpB,OAIoB,GAJV,OAIU,EAAA,iBAHpB,MAGoB,CAAA,MAAA,EAAA,GAAA,CAAA,GAHE,MAGF,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAA5B,2BAA4B,CAAA,QAAA,EAAU,QAAV,CAAA,CAAA,EACpC,iCADoC,CACF,QADE,EACQ,QADR,CAAA"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CbDLau6x.cjs');
|
|
2
|
-
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
-
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
4
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/filters.ts
|
|
7
|
-
function getPluginName(plugin) {
|
|
8
|
-
return (0, __stryke_type_checks_is_set_string.isSetString)(plugin) ? plugin : Array.isArray(plugin) && plugin.length > 0 ? getPluginName(plugin[0]) : plugin.$$name || plugin.name ? plugin.$$name || plugin.name : void 0;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check if a Babel plugin is a duplicate of another plugin in the list.
|
|
12
|
-
*
|
|
13
|
-
* @param plugins - The list of existing Babel plugins.
|
|
14
|
-
* @param plugin - The Babel plugin to check for duplicates.
|
|
15
|
-
* @returns True if the plugin is a duplicate, false otherwise.
|
|
16
|
-
*/
|
|
17
|
-
function isDuplicatePlugin(plugins, plugin) {
|
|
18
|
-
return !!(getPluginName(plugin) && plugins.some((existing) => Array.isArray(existing) && getPluginName(existing[0]) === getPluginName(plugin)));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Filters a Babel plugin by its runtime ID.
|
|
22
|
-
*
|
|
23
|
-
* @param context - The context in which the filter is applied.
|
|
24
|
-
* @param fileId - The file ID to filter by.
|
|
25
|
-
* @returns A filter function that checks if a plugin's ID matches the runtime ID.
|
|
26
|
-
*/
|
|
27
|
-
function filterPluginByFileId(context, fileId) {
|
|
28
|
-
return (code, id) => fileId !== id && context.fs.ids[fileId] !== id && fileId !== context.fs.ids[id] && context.fs.ids[fileId] !== context.fs.ids[id] && context.fs.paths[fileId] !== id && fileId !== context.fs.paths[id] && context.fs.paths[fileId] !== context.fs.paths[id];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Adds a filter to a Babel plugin or a list of Babel plugins.
|
|
32
|
-
*
|
|
33
|
-
* @param context - The context in which the plugin is being added.
|
|
34
|
-
* @param pluginOrPlugins - The Babel plugin or plugins to add the filter to.
|
|
35
|
-
* @param filter - The filter function to apply to the plugins.
|
|
36
|
-
* @param name - The name of the plugin to add the filter to.
|
|
37
|
-
* @returns The updated list of Babel plugins with the filter applied.
|
|
38
|
-
*/
|
|
39
|
-
function addPluginFilter(context, pluginOrPlugins, filter, name) {
|
|
40
|
-
if (!Array.isArray(pluginOrPlugins) || !pluginOrPlugins.some((plugin) => Array.isArray(plugin)) && pluginOrPlugins.length < 4 && pluginOrPlugins.length > 0 && ((0, __stryke_type_checks_is_set_string.isSetString)(pluginOrPlugins[0]) || (0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[0]) || pluginOrPlugins.length > 1 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[1]) || pluginOrPlugins.length > 2 && (0, __stryke_type_checks_is_object.isObject)(pluginOrPlugins[2]))) return Array.isArray(pluginOrPlugins) ? [
|
|
41
|
-
pluginOrPlugins[0],
|
|
42
|
-
pluginOrPlugins.length > 1 ? pluginOrPlugins[1] : {},
|
|
43
|
-
{ filter: (code, id) => filter(code, id) && (pluginOrPlugins.length < 2 || !(0, __stryke_type_checks_is_function.isFunction)(pluginOrPlugins[2]) || pluginOrPlugins[2]?.(code, id)) }
|
|
44
|
-
] : [
|
|
45
|
-
pluginOrPlugins,
|
|
46
|
-
{},
|
|
47
|
-
{ filter }
|
|
48
|
-
];
|
|
49
|
-
if (!name) throw new Error("No name was provided to `addPluginFilter`, could not find babel plugin without it.");
|
|
50
|
-
const foundIndex = pluginOrPlugins.findIndex((plugin) => getPluginName(plugin)?.toLowerCase() === name.toLowerCase());
|
|
51
|
-
if (foundIndex > -1) pluginOrPlugins[foundIndex] = addPluginFilter(context, pluginOrPlugins[foundIndex], filter, name);
|
|
52
|
-
return pluginOrPlugins;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
Object.defineProperty(exports, 'addPluginFilter', {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return addPluginFilter;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, 'filterPluginByFileId', {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return filterPluginByFileId;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, 'getPluginName', {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return getPluginName;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, 'isDuplicatePlugin', {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return isDuplicatePlugin;
|
|
78
|
-
}
|
|
79
|
-
});
|