@powerlines/plugin-babel 0.12.452 → 0.12.455
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/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const require_helpers_create_plugin = require('./helpers/create-plugin.cjs');
|
|
|
7
7
|
const require_helpers_module_helpers = require('./helpers/module-helpers.cjs');
|
|
8
8
|
require('./helpers/index.cjs');
|
|
9
9
|
let _babel_core = require("@babel/core");
|
|
10
|
-
let
|
|
10
|
+
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
11
11
|
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
12
12
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
13
13
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
@@ -74,7 +74,7 @@ const plugin = (options = {}) => {
|
|
|
74
74
|
envName: this.config.mode,
|
|
75
75
|
caller: { name: this.config.framework },
|
|
76
76
|
...(0, _stryke_helpers_omit.omit)(this.config.babel ?? {}, ["skipConfigResolution"]),
|
|
77
|
-
filename:
|
|
77
|
+
filename: (0, _powerlines_core_plugin_utils.removeVirtualPrefix)(id),
|
|
78
78
|
plugins: plugins.map((plugin) => {
|
|
79
79
|
if (Array.isArray(plugin) && plugin.length >= 2) {
|
|
80
80
|
if (plugin.slice(1).every((item) => !(0, node_util_types.isSet)(item) || (0, _stryke_type_checks_is_empty_object.isEmptyObject)(item))) return plugin[0];
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { createBabelPlugin } from "./helpers/create-plugin.mjs";
|
|
|
5
5
|
import { addImport, addImportsToProgram, findExport, getImport, isImportCall, listExports, listImports } from "./helpers/module-helpers.mjs";
|
|
6
6
|
import "./helpers/index.mjs";
|
|
7
7
|
import { transformAsync } from "@babel/core";
|
|
8
|
-
import {
|
|
8
|
+
import { removeVirtualPrefix } from "@powerlines/core/plugin-utils";
|
|
9
9
|
import { omit } from "@stryke/helpers/omit";
|
|
10
10
|
import { findFileExtensionSafe } from "@stryke/path/file-path-fns";
|
|
11
11
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
@@ -71,7 +71,7 @@ const plugin = (options = {}) => {
|
|
|
71
71
|
envName: this.config.mode,
|
|
72
72
|
caller: { name: this.config.framework },
|
|
73
73
|
...omit(this.config.babel ?? {}, ["skipConfigResolution"]),
|
|
74
|
-
filename: id
|
|
74
|
+
filename: removeVirtualPrefix(id),
|
|
75
75
|
plugins: plugins.map((plugin) => {
|
|
76
76
|
if (Array.isArray(plugin) && plugin.length >= 2) {
|
|
77
77
|
if (plugin.slice(1).every((item) => !isSet(item) || isEmptyObject(item))) return plugin[0];
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { PluginItem, PresetItem, transformAsync } from \"@babel/core\";\nimport type { Plugin } from \"@powerlines/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { PluginItem, PresetItem, transformAsync } from \"@babel/core\";\nimport type { Plugin } from \"@powerlines/core\";\nimport { removeVirtualPrefix } from \"@powerlines/core/plugin-utils\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport defu from \"defu\";\nimport { isSet } from \"node:util/types\";\nimport { isDuplicatePlugin, isDuplicatePreset } from \"./helpers/filters\";\nimport {\n getUniquePlugins,\n getUniquePresets,\n resolveBabelPlugin,\n resolveBabelPreset\n} from \"./helpers/options\";\nimport {\n ResolvedBabelTransformPluginOptions,\n ResolvedBabelTransformPresetOptions\n} from \"./types/config\";\nimport { BabelPluginContext, BabelPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface Config {\n babel?: BabelPluginOptions;\n }\n}\n\n/**\n * Babel plugin for Powerlines.\n *\n * @param options - The Babel plugin user configuration options.\n * @returns A Powerlines plugin that integrates Babel transformations.\n */\nexport const plugin = <\n TContext extends BabelPluginContext = BabelPluginContext\n>(\n options: BabelPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"babel\",\n config() {\n if (!isSetObject(options)) {\n return undefined;\n }\n\n return {\n babel: options\n };\n },\n configResolved: {\n order: \"pre\",\n handler() {\n this.config.babel = defu(this.config.babel ?? {}, {\n plugins: [],\n presets: []\n });\n\n this.config.babel.plugins = getUniquePlugins(this.config.babel.plugins);\n this.config.babel.presets = getUniquePresets(this.config.babel.presets);\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 = getUniquePlugins(\n this.config.babel.plugins\n .map(plugin => resolveBabelPlugin(this, code, id, plugin))\n .filter(Boolean) as ResolvedBabelTransformPluginOptions[]\n );\n const presets = getUniquePresets(\n this.config.babel.presets\n .map(preset => resolveBabelPreset(this, code, id, preset))\n .filter(Boolean) as ResolvedBabelTransformPresetOptions[]\n );\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 (!this.config.babel?.skipConfigResolution) {\n if (\n /^(?:m|c)?tsx?$/.test(\n findFileExtensionSafe(id, {\n fullExtension: true\n })\n ) &&\n !isDuplicatePlugin(plugins, \"@babel/plugin-syntax-typescript\") &&\n !isDuplicatePreset(presets, \"@babel/preset-typescript\")\n ) {\n plugins.unshift(\"@babel/plugin-syntax-typescript\");\n }\n\n if (\n /^(?:t|j)sx$/.test(\n findFileExtensionSafe(id, {\n fullExtension: true\n })\n ) &&\n !isDuplicatePlugin(plugins, \"@babel/plugin-syntax-jsx\") &&\n !isDuplicatePreset(presets, \"@babel/preset-react\")\n ) {\n plugins.unshift(\"@babel/plugin-syntax-jsx\");\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 cwd: this.config.cwd,\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 ...omit(this.config.babel ?? {}, [\"skipConfigResolution\"]),\n filename: removeVirtualPrefix(id),\n plugins: plugins\n .map(plugin => {\n if (Array.isArray(plugin) && plugin.length >= 2) {\n if (\n plugin\n .slice(1)\n .every(item => !isSet(item) || isEmptyObject(item))\n ) {\n return plugin[0];\n }\n\n return [\n plugin[0],\n plugin.length > 1 && plugin[1] ? plugin[1] : {}\n ];\n }\n\n return plugin;\n })\n .filter(Boolean) as PluginItem<object>[],\n presets: presets\n .map(preset => {\n if (Array.isArray(preset) && preset.length >= 2) {\n if (\n preset\n .slice(1)\n .every(item => !isSet(item) || isEmptyObject(item))\n ) {\n return preset[0];\n }\n\n return [\n preset[0],\n preset.length > 1 && preset[1] ? preset[1] : {}\n ];\n }\n\n return preset;\n })\n .filter(Boolean) as PresetItem<object>[]\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":";;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,UAGX,UAA8B,EAAE,KACX;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,OAAI,CAAC,YAAY,QAAQ,CACvB;AAGF,UAAO,EACL,OAAO,SACR;;EAEH,gBAAgB;GACd,OAAO;GACP,UAAU;AACR,SAAK,OAAO,QAAQ,KAAK,KAAK,OAAO,SAAS,EAAE,EAAE;KAChD,SAAS,EAAE;KACX,SAAS,EAAE;KACZ,CAAC;AAEF,SAAK,OAAO,MAAM,UAAU,iBAAiB,KAAK,OAAO,MAAM,QAAQ;AACvE,SAAK,OAAO,MAAM,UAAU,iBAAiB,KAAK,OAAO,MAAM,QAAQ;;GAE1E;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,iBACd,KAAK,OAAO,MAAM,QACf,K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IAAI,cAAc,KAAK,CAAC,CAErD,QAAO,OAAO;AAGhB,aAAO,CACL,OAAO,IACP,OAAO,SAAS,KAAK,OAAO,KAAK,OAAO,KAAK,EAAE,CAChD;;AAGH,YAAO;MACP,CACD,OAAO,QAAQ;IAClB,SAAS,QACN,KAAI,WAAU;AACb,SAAI,MAAM,QAAQ,OAAO,IAAI,OAAO,UAAU,GAAG;AAC/C,UACE,OACG,MAAM,EAAE,CACR,OAAM,SAAQ,CAAC,MAAM,KAAK,IAAI,cAAc,KAAK,CAAC,CAErD,QAAO,OAAO;AAGhB,aAAO,CACL,OAAO,IACP,OAAO,SAAS,KAAK,OAAO,KAAK,OAAO,KAAK,EAAE,CAChD;;AAGH,YAAO;MACP,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-babel",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.455",
|
|
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,7 +90,7 @@
|
|
|
90
90
|
"@babel/helper-plugin-utils": "8.0.0-rc.4",
|
|
91
91
|
"@babel/parser": "8.0.0-rc.4",
|
|
92
92
|
"@babel/types": "8.0.0-rc.4",
|
|
93
|
-
"@powerlines/core": "^0.
|
|
93
|
+
"@powerlines/core": "^0.47.1",
|
|
94
94
|
"@storm-software/config-tools": "^1.190.1",
|
|
95
95
|
"@stryke/fs": "^0.33.70",
|
|
96
96
|
"@stryke/path": "^0.28.2",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"@babel/plugin-syntax-typescript": { "optional": true }
|
|
114
114
|
},
|
|
115
115
|
"publishConfig": { "access": "public" },
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "3d2c2a8ebb3941045a9aaeb5218c96368847c371"
|
|
117
117
|
}
|