@powerlines/plugin-plugin 0.5.0 → 0.6.1
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/node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.4/node_modules/esbuild-plugin-babel/src/index.cjs +46 -0
- package/dist/node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.4/node_modules/esbuild-plugin-babel/src/index.js +44 -0
- package/dist/src/index.cjs +46 -38
- package/dist/src/index.js +46 -38
- package/package.json +10 -15
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var babel = require('@babel/core');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
const pluginBabel = (options = {}) => ({
|
|
8
|
+
name: 'babel',
|
|
9
|
+
setup(build, { transform } = {}) {
|
|
10
|
+
const { filter = /.*/, namespace = '', config = {} } = options;
|
|
11
|
+
|
|
12
|
+
const transformContents = ({ args, contents }) => {
|
|
13
|
+
const babelOptions = babel.loadOptions({
|
|
14
|
+
...config,
|
|
15
|
+
filename: args.path,
|
|
16
|
+
caller: {
|
|
17
|
+
name: 'esbuild-plugin-babel',
|
|
18
|
+
supportsStaticESM: true
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (!babelOptions) return { contents };
|
|
22
|
+
|
|
23
|
+
if (babelOptions.sourceMaps) {
|
|
24
|
+
const filename = path.relative(process.cwd(), args.path);
|
|
25
|
+
|
|
26
|
+
babelOptions.sourceFileName = filename;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
babel.transform(contents, babelOptions, (error, result) => {
|
|
31
|
+
error ? reject(error) : resolve({ contents: result.code });
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (transform) return transformContents(transform);
|
|
37
|
+
|
|
38
|
+
build.onLoad({ filter, namespace }, async args => {
|
|
39
|
+
const contents = await fs.promises.readFile(args.path, 'utf8');
|
|
40
|
+
|
|
41
|
+
return transformContents({ args, contents });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
module.exports = pluginBabel;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import babel from '@babel/core';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
const pluginBabel = (options = {}) => ({
|
|
6
|
+
name: 'babel',
|
|
7
|
+
setup(build, { transform } = {}) {
|
|
8
|
+
const { filter = /.*/, namespace = '', config = {} } = options;
|
|
9
|
+
|
|
10
|
+
const transformContents = ({ args, contents }) => {
|
|
11
|
+
const babelOptions = babel.loadOptions({
|
|
12
|
+
...config,
|
|
13
|
+
filename: args.path,
|
|
14
|
+
caller: {
|
|
15
|
+
name: 'esbuild-plugin-babel',
|
|
16
|
+
supportsStaticESM: true
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (!babelOptions) return { contents };
|
|
20
|
+
|
|
21
|
+
if (babelOptions.sourceMaps) {
|
|
22
|
+
const filename = path.relative(process.cwd(), args.path);
|
|
23
|
+
|
|
24
|
+
babelOptions.sourceFileName = filename;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
babel.transform(contents, babelOptions, (error, result) => {
|
|
29
|
+
error ? reject(error) : resolve({ contents: result.code });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
if (transform) return transformContents(transform);
|
|
35
|
+
|
|
36
|
+
build.onLoad({ filter, namespace }, async args => {
|
|
37
|
+
const contents = await fs.promises.readFile(args.path, 'utf8');
|
|
38
|
+
|
|
39
|
+
return transformContents({ args, contents });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export { pluginBabel as default };
|
package/dist/src/index.cjs
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var src_types_plugin = require('./types/plugin.cjs');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var alloyBabelPreset = require('@alloy-js/babel-preset');
|
|
7
|
+
var typescriptBabelPreset = require('@babel/preset-typescript');
|
|
8
8
|
var types = require('@storm-software/config-tools/types');
|
|
9
|
+
var tsup = require('@storm-software/tsup');
|
|
9
10
|
var copyFile = require('@stryke/fs/copy-file');
|
|
10
11
|
var stormJson = require('@stryke/json/storm-json');
|
|
11
12
|
var append = require('@stryke/path/append');
|
|
12
|
-
var
|
|
13
|
+
var isParentPath = require('@stryke/path/is-parent-path');
|
|
13
14
|
var join = require('@stryke/path/join');
|
|
15
|
+
var defu = require('defu');
|
|
16
|
+
var index = require('../node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.4/node_modules/esbuild-plugin-babel/src/index.cjs');
|
|
17
|
+
var chunkWIQTANXE = require('../packages/powerlines/dist/lib/chunk-WIQTANXE.cjs');
|
|
18
|
+
require('../packages/powerlines/dist/lib/chunk-K5RSG5JS.cjs');
|
|
19
|
+
require('../packages/powerlines/dist/lib/chunk-Q56GIKMF.cjs');
|
|
14
20
|
|
|
15
21
|
/*@ts-ignore*/
|
|
16
22
|
function __assignType(fn, args) {
|
|
@@ -23,8 +29,7 @@ function __assignType(fn, args) {
|
|
|
23
29
|
const plugin = __assignType((options = {}) => {
|
|
24
30
|
return {
|
|
25
31
|
name: "plugin",
|
|
26
|
-
|
|
27
|
-
config() {
|
|
32
|
+
config: __assignType(function config() {
|
|
28
33
|
this.log(types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines plugin.");
|
|
29
34
|
return {
|
|
30
35
|
type: "library",
|
|
@@ -34,29 +39,6 @@ const plugin = __assignType((options = {}) => {
|
|
|
34
39
|
projectDistPath: "dist",
|
|
35
40
|
format: ["cjs", "esm"]
|
|
36
41
|
},
|
|
37
|
-
transform: options.alloy
|
|
38
|
-
? {
|
|
39
|
-
babel: {
|
|
40
|
-
presets: [
|
|
41
|
-
[
|
|
42
|
-
"@babel/preset-typescript",
|
|
43
|
-
{
|
|
44
|
-
allExtensions: true,
|
|
45
|
-
allowDeclareFields: true,
|
|
46
|
-
isTSX: true
|
|
47
|
-
},
|
|
48
|
-
__assignType((code, id) => find.findFileExtension(id) === "tsx", ['code', 'id', '', 'P&2!&2""/#'])
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
"@alloy-js/babel-preset",
|
|
52
|
-
{},
|
|
53
|
-
__assignType((code, id) => find.findFileExtension(id) === "jsx" ||
|
|
54
|
-
find.findFileExtension(id) === "tsx", ['code', 'id', '', 'P&2!&2""/#'])
|
|
55
|
-
]
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
: undefined,
|
|
60
42
|
build: {
|
|
61
43
|
external: ["powerlines"],
|
|
62
44
|
bundle: false,
|
|
@@ -64,7 +46,7 @@ const plugin = __assignType((options = {}) => {
|
|
|
64
46
|
platform: "node"
|
|
65
47
|
}
|
|
66
48
|
};
|
|
67
|
-
},
|
|
49
|
+
}, ['config', 'P"/!']),
|
|
68
50
|
configResolved: __assignType(async function configResolved() {
|
|
69
51
|
this.log(types.LogLevelLabel.TRACE, "The Powerlines plugin has resolved the final configuration.");
|
|
70
52
|
if (options.alloy) {
|
|
@@ -77,15 +59,41 @@ const plugin = __assignType((options = {}) => {
|
|
|
77
59
|
this.config.override.outputPath ??= join.joinPaths(this.config.projectRoot, this.config.output.projectDistPath);
|
|
78
60
|
}
|
|
79
61
|
}, ['configResolved', 'P"/!']),
|
|
80
|
-
build
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
62
|
+
async build() {
|
|
63
|
+
await tsup.build(await tsup.resolveOptions(defu.defu({
|
|
64
|
+
config: false,
|
|
65
|
+
entry: Object.fromEntries(Object.entries(chunkWIQTANXE.resolveTsupEntry(this, this.entry)).map(__assignType(([key, value]) => [
|
|
66
|
+
key,
|
|
67
|
+
isParentPath.isParentPath(value, this.config.projectRoot)
|
|
68
|
+
? value
|
|
69
|
+
: join.joinPaths(this.config.projectRoot, value)
|
|
70
|
+
], ['param0', '', 'P"2!"/"'])))
|
|
71
|
+
}, chunkWIQTANXE.extractTsupConfig(this), {
|
|
72
|
+
esbuildPlugins: options.alloy
|
|
73
|
+
? [
|
|
74
|
+
index({
|
|
75
|
+
filter: /\.tsx$/,
|
|
76
|
+
config: {
|
|
77
|
+
presets: [
|
|
78
|
+
[
|
|
79
|
+
typescriptBabelPreset,
|
|
80
|
+
{
|
|
81
|
+
allExtensions: true,
|
|
82
|
+
allowDeclareFields: true,
|
|
83
|
+
isTSX: true
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
alloyBabelPreset
|
|
87
|
+
]
|
|
88
|
+
}})
|
|
89
|
+
]
|
|
90
|
+
: []
|
|
91
|
+
})));
|
|
92
|
+
if (this.config.override.outputPath &&
|
|
93
|
+
this.config.override.outputPath !== this.config.output.outputPath) {
|
|
94
|
+
this.log(types.LogLevelLabel.INFO, `Copying built files from override output path (${this.config.override.outputPath}) to final output path (${this.config.output.outputPath}).`);
|
|
95
|
+
await copyFile.copyFiles(append.appendPath(this.config.override.outputPath, this.workspaceConfig.workspaceRoot), join.joinPaths(append.appendPath(this.config.output.outputPath, this.workspaceConfig.workspaceRoot), "dist"));
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
99
|
}, [() => src_types_plugin.__ΩPluginPluginOptions, 'options', () => ({}), '', 'Pn!2">#!/$']);
|
package/dist/src/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { __ΩPluginPluginOptions as ___PluginPluginOptions } from './types/plugin.js';
|
|
2
2
|
export { __ΩPluginPluginAlloyOptions, __ΩPluginPluginContext, __ΩPluginPluginOutputConfig, __ΩPluginPluginResolvedConfig, __ΩPluginPluginUserConfig } from './types/plugin.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import alloyBabelPreset from '@alloy-js/babel-preset';
|
|
4
|
+
import typescriptBabelPreset from '@babel/preset-typescript';
|
|
5
5
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
6
|
+
import { build, resolveOptions } from '@storm-software/tsup';
|
|
6
7
|
import { copyFiles } from '@stryke/fs/copy-file';
|
|
7
8
|
import { StormJSON } from '@stryke/json/storm-json';
|
|
8
9
|
import { appendPath } from '@stryke/path/append';
|
|
9
|
-
import {
|
|
10
|
+
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
10
11
|
import { joinPaths } from '@stryke/path/join';
|
|
12
|
+
import { defu } from 'defu';
|
|
13
|
+
import pluginBabel from '../node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.4/node_modules/esbuild-plugin-babel/src/index.js';
|
|
14
|
+
import { resolveTsupEntry, extractTsupConfig } from '../packages/powerlines/dist/lib/chunk-WIQTANXE.js';
|
|
15
|
+
import '../packages/powerlines/dist/lib/chunk-K5RSG5JS.js';
|
|
16
|
+
import '../packages/powerlines/dist/lib/chunk-Q56GIKMF.js';
|
|
11
17
|
|
|
12
18
|
/*@ts-ignore*/
|
|
13
19
|
function __assignType(fn, args) {
|
|
@@ -20,8 +26,7 @@ function __assignType(fn, args) {
|
|
|
20
26
|
const plugin = __assignType((options = {}) => {
|
|
21
27
|
return {
|
|
22
28
|
name: "plugin",
|
|
23
|
-
|
|
24
|
-
config() {
|
|
29
|
+
config: __assignType(function config() {
|
|
25
30
|
this.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines plugin.");
|
|
26
31
|
return {
|
|
27
32
|
type: "library",
|
|
@@ -31,29 +36,6 @@ const plugin = __assignType((options = {}) => {
|
|
|
31
36
|
projectDistPath: "dist",
|
|
32
37
|
format: ["cjs", "esm"]
|
|
33
38
|
},
|
|
34
|
-
transform: options.alloy
|
|
35
|
-
? {
|
|
36
|
-
babel: {
|
|
37
|
-
presets: [
|
|
38
|
-
[
|
|
39
|
-
"@babel/preset-typescript",
|
|
40
|
-
{
|
|
41
|
-
allExtensions: true,
|
|
42
|
-
allowDeclareFields: true,
|
|
43
|
-
isTSX: true
|
|
44
|
-
},
|
|
45
|
-
__assignType((code, id) => findFileExtension(id) === "tsx", ['code', 'id', '', 'P&2!&2""/#'])
|
|
46
|
-
],
|
|
47
|
-
[
|
|
48
|
-
"@alloy-js/babel-preset",
|
|
49
|
-
{},
|
|
50
|
-
__assignType((code, id) => findFileExtension(id) === "jsx" ||
|
|
51
|
-
findFileExtension(id) === "tsx", ['code', 'id', '', 'P&2!&2""/#'])
|
|
52
|
-
]
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
: undefined,
|
|
57
39
|
build: {
|
|
58
40
|
external: ["powerlines"],
|
|
59
41
|
bundle: false,
|
|
@@ -61,7 +43,7 @@ const plugin = __assignType((options = {}) => {
|
|
|
61
43
|
platform: "node"
|
|
62
44
|
}
|
|
63
45
|
};
|
|
64
|
-
},
|
|
46
|
+
}, ['config', 'P"/!']),
|
|
65
47
|
configResolved: __assignType(async function configResolved() {
|
|
66
48
|
this.log(LogLevelLabel.TRACE, "The Powerlines plugin has resolved the final configuration.");
|
|
67
49
|
if (options.alloy) {
|
|
@@ -74,15 +56,41 @@ const plugin = __assignType((options = {}) => {
|
|
|
74
56
|
this.config.override.outputPath ??= joinPaths(this.config.projectRoot, this.config.output.projectDistPath);
|
|
75
57
|
}
|
|
76
58
|
}, ['configResolved', 'P"/!']),
|
|
77
|
-
build
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
59
|
+
async build() {
|
|
60
|
+
await build(await resolveOptions(defu({
|
|
61
|
+
config: false,
|
|
62
|
+
entry: Object.fromEntries(Object.entries(resolveTsupEntry(this, this.entry)).map(__assignType(([key, value]) => [
|
|
63
|
+
key,
|
|
64
|
+
isParentPath(value, this.config.projectRoot)
|
|
65
|
+
? value
|
|
66
|
+
: joinPaths(this.config.projectRoot, value)
|
|
67
|
+
], ['param0', '', 'P"2!"/"'])))
|
|
68
|
+
}, extractTsupConfig(this), {
|
|
69
|
+
esbuildPlugins: options.alloy
|
|
70
|
+
? [
|
|
71
|
+
pluginBabel({
|
|
72
|
+
filter: /\.tsx$/,
|
|
73
|
+
config: {
|
|
74
|
+
presets: [
|
|
75
|
+
[
|
|
76
|
+
typescriptBabelPreset,
|
|
77
|
+
{
|
|
78
|
+
allExtensions: true,
|
|
79
|
+
allowDeclareFields: true,
|
|
80
|
+
isTSX: true
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
alloyBabelPreset
|
|
84
|
+
]
|
|
85
|
+
}})
|
|
86
|
+
]
|
|
87
|
+
: []
|
|
88
|
+
})));
|
|
89
|
+
if (this.config.override.outputPath &&
|
|
90
|
+
this.config.override.outputPath !== this.config.output.outputPath) {
|
|
91
|
+
this.log(LogLevelLabel.INFO, `Copying built files from override output path (${this.config.override.outputPath}) to final output path (${this.config.output.outputPath}).`);
|
|
92
|
+
await copyFiles(appendPath(this.config.override.outputPath, this.workspaceConfig.workspaceRoot), joinPaths(appendPath(this.config.output.outputPath, this.workspaceConfig.workspaceRoot), "dist"));
|
|
93
|
+
}
|
|
86
94
|
}
|
|
87
95
|
};
|
|
88
96
|
}, [() => ___PluginPluginOptions, 'options', () => ({}), '', 'Pn!2">#!/$']);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -117,31 +117,26 @@
|
|
|
117
117
|
"files": ["dist/**/*"],
|
|
118
118
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@alloy-js/babel-
|
|
121
|
-
"@alloy-js/babel-plugin-jsx-dom-expressions": "^0.39.1",
|
|
120
|
+
"@alloy-js/babel-preset": "^0.2.1",
|
|
122
121
|
"@alloy-js/core": "^0.20.0",
|
|
123
122
|
"@alloy-js/json": "^0.20.0",
|
|
124
123
|
"@alloy-js/markdown": "^0.20.0",
|
|
125
124
|
"@alloy-js/typescript": "^0.20.0",
|
|
126
|
-
"@babel/
|
|
127
|
-
"@
|
|
128
|
-
"@
|
|
129
|
-
"@powerlines/plugin-babel": "^0.5.0",
|
|
130
|
-
"@powerlines/plugin-tsup": "^0.5.0",
|
|
131
|
-
"@stryke/fs": "^0.31.4",
|
|
125
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
126
|
+
"@storm-software/tsup": "^0.2.4",
|
|
127
|
+
"@stryke/fs": "^0.32.2",
|
|
132
128
|
"@stryke/json": "^0.9.3",
|
|
133
|
-
"@stryke/path": "^0.
|
|
129
|
+
"@stryke/path": "^0.16.0",
|
|
130
|
+
"@stryke/type-checks": "^0.3.10",
|
|
134
131
|
"@stryke/types": "^0.10.0",
|
|
135
|
-
"@vue/reactivity": "^3.5.22",
|
|
136
132
|
"defu": "^6.1.4",
|
|
137
133
|
"esbuild-plugin-babel": "^0.2.3",
|
|
138
134
|
"jiti": "^2.6.1",
|
|
139
|
-
"powerlines": "^0.
|
|
140
|
-
"prettier": "^3.6.2"
|
|
135
|
+
"powerlines": "^0.5.0"
|
|
141
136
|
},
|
|
142
137
|
"devDependencies": {
|
|
143
138
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
144
|
-
"@powerlines/nx": "^0.5.
|
|
139
|
+
"@powerlines/nx": "^0.5.1",
|
|
145
140
|
"@rollup/plugin-commonjs": "^28.0.8",
|
|
146
141
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
147
142
|
"@types/babel__helper-plugin-utils": "^7.10.3",
|
|
@@ -151,5 +146,5 @@
|
|
|
151
146
|
"rollup-plugin-typescript2": "^0.36.0"
|
|
152
147
|
},
|
|
153
148
|
"publishConfig": { "access": "public" },
|
|
154
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "9f798e68652f3be59814d62b30ce3be4710b7ae7"
|
|
155
150
|
}
|