@powerlines/plugin-esbuild 0.13.460 → 0.13.463
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/build-B8u-bRQt.d.cts +8 -0
- package/dist/build-B8u-bRQt.d.cts.map +1 -0
- package/dist/build-VnV0tsb3.d.mts +8 -0
- package/dist/build-VnV0tsb3.d.mts.map +1 -0
- package/dist/bundle-A-22BjWv.d.mts +22 -0
- package/dist/bundle-A-22BjWv.d.mts.map +1 -0
- package/dist/bundle-B_-jRFlM.cjs +84 -0
- package/dist/bundle-HmHLeZt2.d.cts +22 -0
- package/dist/bundle-HmHLeZt2.d.cts.map +1 -0
- package/dist/helpers/bundle.cjs +2 -49
- package/dist/helpers/bundle.d.cts +2 -22
- package/dist/helpers/bundle.d.mts +2 -22
- package/dist/helpers/bundle.mjs +3 -6
- package/dist/helpers/bundle.mjs.map +1 -1
- package/dist/helpers/index.cjs +3 -9
- package/dist/helpers/index.d.cts +3 -5
- package/dist/helpers/index.d.mts +3 -5
- package/dist/helpers/index.mjs +1 -3
- package/dist/helpers/resolve.cjs +4 -5
- package/dist/helpers/resolve.d.cts +2 -26
- package/dist/helpers/resolve.d.mts +2 -26
- package/dist/helpers/resolve.mjs +2 -2
- package/dist/helpers/resolve.mjs.map +1 -1
- package/dist/index-BtBZHVmz.d.cts +1 -0
- package/dist/index-DXRuzH8z.d.mts +1 -0
- package/dist/index.cjs +19 -19
- package/dist/index.d.cts +5 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-BuKZtP7s.d.mts +19 -0
- package/dist/plugin-BuKZtP7s.d.mts.map +1 -0
- package/dist/plugin-g0pkWAvQ.d.cts +19 -0
- package/dist/plugin-g0pkWAvQ.d.cts.map +1 -0
- package/dist/resolve-DGrNGKUw.d.mts +26 -0
- package/dist/resolve-DGrNGKUw.d.mts.map +1 -0
- package/dist/resolve-uvDtu7oi.d.cts +26 -0
- package/dist/resolve-uvDtu7oi.d.cts.map +1 -0
- package/dist/types/build.d.cts +2 -8
- package/dist/types/build.d.mts +2 -8
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.mts +3 -3
- package/dist/types/plugin.d.cts +2 -21
- package/dist/types/plugin.d.mts +2 -21
- package/package.json +12 -11
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/helpers/bundle.d.cts.map +0 -1
- package/dist/helpers/bundle.d.mts.map +0 -1
- package/dist/helpers/resolve-options.cjs +0 -91
- package/dist/helpers/resolve-options.d.cts +0 -23
- package/dist/helpers/resolve-options.d.cts.map +0 -1
- package/dist/helpers/resolve-options.d.mts +0 -23
- package/dist/helpers/resolve-options.d.mts.map +0 -1
- package/dist/helpers/resolve-options.mjs +0 -87
- package/dist/helpers/resolve-options.mjs.map +0 -1
- package/dist/helpers/resolve.d.cts.map +0 -1
- package/dist/helpers/resolve.d.mts.map +0 -1
- package/dist/helpers/unplugin.cjs +0 -18
- package/dist/helpers/unplugin.d.cts +0 -8
- package/dist/helpers/unplugin.d.cts.map +0 -1
- package/dist/helpers/unplugin.d.mts +0 -8
- package/dist/helpers/unplugin.d.mts.map +0 -1
- package/dist/helpers/unplugin.mjs +0 -17
- package/dist/helpers/unplugin.mjs.map +0 -1
- package/dist/types/build.d.cts.map +0 -1
- package/dist/types/build.d.mts.map +0 -1
- package/dist/types/plugin.d.cts.map +0 -1
- package/dist/types/plugin.d.mts.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildOptions } from "esbuild";
|
|
2
|
+
|
|
3
|
+
//#region src/types/build.d.ts
|
|
4
|
+
type EsbuildOptions = Omit<BuildOptions, "entryPoints" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel">;
|
|
5
|
+
declare type __ΩEsbuildOptions = any[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { __ΩEsbuildOptions as n, EsbuildOptions as t };
|
|
8
|
+
//# sourceMappingURL=build-B8u-bRQt.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-B8u-bRQt.d.cts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,cAAA,GAAiB,IAAA,CAC3B,YAAA;AAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildOptions } from "esbuild";
|
|
2
|
+
|
|
3
|
+
//#region src/types/build.d.ts
|
|
4
|
+
type EsbuildOptions = Omit<BuildOptions, "entryPoints" | "platform" | "outdir" | "env" | "assets" | "external" | "inject" | "tsconfig" | "tsconfigRaw" | "logLevel">;
|
|
5
|
+
declare type __ΩEsbuildOptions = any[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { __ΩEsbuildOptions as n, EsbuildOptions as t };
|
|
8
|
+
//# sourceMappingURL=build-VnV0tsb3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-VnV0tsb3.d.mts","names":[],"sources":["../src/types/build.ts"],"mappings":";;;KAoBY,cAAA,GAAiB,IAAA,CAC3B,YAAA;AAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as EsbuildOptions } from "./build-VnV0tsb3.mjs";
|
|
2
|
+
import { PluginContext, ResolveOptions } from "@powerlines/core";
|
|
3
|
+
import { OutputFile } from "esbuild";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/bundle.d.ts
|
|
6
|
+
type BundleOptions = Partial<EsbuildOptions> & {
|
|
7
|
+
name?: string;
|
|
8
|
+
resolve?: Partial<ResolveOptions>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Bundle a type definition to a module.
|
|
12
|
+
*
|
|
13
|
+
* @param context - The context object containing the environment paths.
|
|
14
|
+
* @param file - The file path to bundle.
|
|
15
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
16
|
+
* @returns A promise that resolves to the bundled module.
|
|
17
|
+
*/
|
|
18
|
+
declare function bundle<TContext extends PluginContext = PluginContext>(context: TContext, file: string, overrides?: BundleOptions): Promise<OutputFile>;
|
|
19
|
+
declare type __ΩBundleOptions = any[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __ΩBundleOptions as n, bundle as r, BundleOptions as t };
|
|
22
|
+
//# sourceMappingURL=bundle-A-22BjWv.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-A-22BjWv.d.mts","names":[],"sources":["../src/helpers/bundle.ts"],"mappings":";;;;;KAgCY,aAAA,GAAgB,OAAA,CAAQ,cAAA;EAClC,IAAA;EACA,OAAA,GAAU,OAAA,CAAQ,cAAA;AAAA;;;;;;;;;iBAWE,MAAA,kBAAwB,aAAA,GAAgB,aAAA,CAAA,CAC5D,OAAA,EAAS,QAAA,EACT,IAAA,UACA,SAAA,GAAW,aAAA,GACV,OAAA,CAAQ,UAAA;AAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let _powerlines_unplugin_esbuild = require("@powerlines/unplugin/esbuild");
|
|
29
|
+
let defu = require("defu");
|
|
30
|
+
defu = __toESM(defu, 1);
|
|
31
|
+
let esbuild = require("esbuild");
|
|
32
|
+
let unplugin = require("unplugin");
|
|
33
|
+
let _powerlines_core_lib_unplugin = require("@powerlines/core/lib/unplugin");
|
|
34
|
+
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
35
|
+
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
36
|
+
|
|
37
|
+
//#region src/helpers/bundle.ts
|
|
38
|
+
/**
|
|
39
|
+
* Bundle a type definition to a module.
|
|
40
|
+
*
|
|
41
|
+
* @param context - The context object containing the environment paths.
|
|
42
|
+
* @param file - The file path to bundle.
|
|
43
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
44
|
+
* @returns A promise that resolves to the bundled module.
|
|
45
|
+
*/
|
|
46
|
+
async function bundle(context, file, overrides = {}) {
|
|
47
|
+
const path = await context.fs.resolve(file);
|
|
48
|
+
if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
|
|
49
|
+
const result = await (0, esbuild.build)((0, defu.default)({
|
|
50
|
+
entryPoints: [path],
|
|
51
|
+
write: false,
|
|
52
|
+
sourcemap: false,
|
|
53
|
+
splitting: false,
|
|
54
|
+
treeShaking: true,
|
|
55
|
+
bundle: true,
|
|
56
|
+
packages: "bundle",
|
|
57
|
+
platform: "node",
|
|
58
|
+
logLevel: "silent",
|
|
59
|
+
...(0, _stryke_helpers_omit.omit)(overrides, ["name", "resolve"])
|
|
60
|
+
}, (0, _powerlines_unplugin_esbuild.resolveOptions)(context), { plugins: [(0, unplugin.createEsbuildPlugin)((0, _powerlines_core_lib_unplugin.createUnpluginResolver)(context, {
|
|
61
|
+
name: overrides.name ?? `${(0, _stryke_path_file_path_fns.findFileName)(file)} Bundler`,
|
|
62
|
+
prefix: false,
|
|
63
|
+
overrides: (0, defu.default)(overrides.resolve ?? {}, { skipNodeModulesBundle: false }, context.config.resolve),
|
|
64
|
+
silenceHookLogging: true
|
|
65
|
+
}))({ ...context.options })] }));
|
|
66
|
+
if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
|
|
67
|
+
if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
|
|
68
|
+
if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
|
|
69
|
+
return result.outputFiles.filter(Boolean)[0];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
Object.defineProperty(exports, '__toESM', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return __toESM;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'bundle', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return bundle;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as EsbuildOptions } from "./build-B8u-bRQt.cjs";
|
|
2
|
+
import { PluginContext, ResolveOptions } from "@powerlines/core";
|
|
3
|
+
import { OutputFile } from "esbuild";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/bundle.d.ts
|
|
6
|
+
type BundleOptions = Partial<EsbuildOptions> & {
|
|
7
|
+
name?: string;
|
|
8
|
+
resolve?: Partial<ResolveOptions>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Bundle a type definition to a module.
|
|
12
|
+
*
|
|
13
|
+
* @param context - The context object containing the environment paths.
|
|
14
|
+
* @param file - The file path to bundle.
|
|
15
|
+
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
16
|
+
* @returns A promise that resolves to the bundled module.
|
|
17
|
+
*/
|
|
18
|
+
declare function bundle<TContext extends PluginContext = PluginContext>(context: TContext, file: string, overrides?: BundleOptions): Promise<OutputFile>;
|
|
19
|
+
declare type __ΩBundleOptions = any[];
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __ΩBundleOptions as n, bundle as r, BundleOptions as t };
|
|
22
|
+
//# sourceMappingURL=bundle-HmHLeZt2.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-HmHLeZt2.d.cts","names":[],"sources":["../src/helpers/bundle.ts"],"mappings":";;;;;KAgCY,aAAA,GAAgB,OAAA,CAAQ,cAAA;EAClC,IAAA;EACA,OAAA,GAAU,OAAA,CAAQ,cAAA;AAAA;;;;;;;;;iBAWE,MAAA,kBAAwB,aAAA,GAAgB,aAAA,CAAA,CAC5D,OAAA,EAAS,QAAA,EACT,IAAA,UACA,SAAA,GAAW,aAAA,GACV,OAAA,CAAQ,UAAA;AAAA"}
|
package/dist/helpers/bundle.cjs
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_helpers_resolve_options = require('./resolve-options.cjs');
|
|
4
|
-
let defu = require("defu");
|
|
5
|
-
defu = require_runtime.__toESM(defu, 1);
|
|
6
|
-
let esbuild = require("esbuild");
|
|
7
|
-
let _powerlines_core_lib_unplugin = require("@powerlines/core/lib/unplugin");
|
|
8
|
-
let unplugin = require("unplugin");
|
|
9
|
-
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
10
|
-
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
2
|
+
const require_bundle = require('../bundle-B_-jRFlM.cjs');
|
|
11
3
|
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Bundle a type definition to a module.
|
|
15
|
-
*
|
|
16
|
-
* @param context - The context object containing the environment paths.
|
|
17
|
-
* @param file - The file path to bundle.
|
|
18
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
19
|
-
* @returns A promise that resolves to the bundled module.
|
|
20
|
-
*/
|
|
21
|
-
async function bundle(context, file, overrides = {}) {
|
|
22
|
-
const path = await context.fs.resolve(file);
|
|
23
|
-
if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
|
|
24
|
-
const result = await (0, esbuild.build)((0, defu.default)({
|
|
25
|
-
entryPoints: [path],
|
|
26
|
-
write: false,
|
|
27
|
-
sourcemap: false,
|
|
28
|
-
splitting: false,
|
|
29
|
-
treeShaking: true,
|
|
30
|
-
bundle: true,
|
|
31
|
-
packages: "bundle",
|
|
32
|
-
platform: "node",
|
|
33
|
-
logLevel: "silent",
|
|
34
|
-
...(0, _stryke_helpers_omit.omit)(overrides, ["name", "resolve"])
|
|
35
|
-
}, require_helpers_resolve_options.resolveOptions(context), { plugins: [(0, unplugin.createEsbuildPlugin)((0, _powerlines_core_lib_unplugin.createUnpluginResolver)(context, {
|
|
36
|
-
name: overrides.name ?? `${(0, _stryke_path_file_path_fns.findFileName)(file)} Bundler`,
|
|
37
|
-
prefix: false,
|
|
38
|
-
overrides: (0, defu.default)(overrides.resolve ?? {}, { skipNodeModulesBundle: false }, context.config.resolve),
|
|
39
|
-
silenceHookLogging: true
|
|
40
|
-
}))({
|
|
41
|
-
...context.options,
|
|
42
|
-
...context.initialConfig
|
|
43
|
-
})] }));
|
|
44
|
-
if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
|
|
45
|
-
if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
|
|
46
|
-
if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
|
|
47
|
-
return result.outputFiles.filter(Boolean)[0];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
exports.bundle = bundle;
|
|
4
|
+
exports.bundle = require_bundle.bundle;
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { OutputFile } from "esbuild";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/bundle.d.ts
|
|
6
|
-
type BundleOptions = Partial<EsbuildOptions> & {
|
|
7
|
-
name?: string;
|
|
8
|
-
resolve?: Partial<ResolveOptions>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Bundle a type definition to a module.
|
|
12
|
-
*
|
|
13
|
-
* @param context - The context object containing the environment paths.
|
|
14
|
-
* @param file - The file path to bundle.
|
|
15
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
16
|
-
* @returns A promise that resolves to the bundled module.
|
|
17
|
-
*/
|
|
18
|
-
declare function bundle<TContext extends PluginContext = PluginContext>(context: TContext, file: string, overrides?: BundleOptions): Promise<OutputFile>;
|
|
19
|
-
declare type __ΩBundleOptions = any[];
|
|
20
|
-
//#endregion
|
|
21
|
-
export { BundleOptions, __ΩBundleOptions, bundle };
|
|
22
|
-
//# sourceMappingURL=bundle.d.cts.map
|
|
1
|
+
import { n as __ΩBundleOptions, r as bundle, t as BundleOptions } from "../bundle-HmHLeZt2.cjs";
|
|
2
|
+
export { BundleOptions, __ΩBundleOptions, bundle };
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { PluginContext, ResolveOptions } from "@powerlines/core";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/bundle.d.ts
|
|
6
|
-
type BundleOptions = Partial<EsbuildOptions> & {
|
|
7
|
-
name?: string;
|
|
8
|
-
resolve?: Partial<ResolveOptions>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Bundle a type definition to a module.
|
|
12
|
-
*
|
|
13
|
-
* @param context - The context object containing the environment paths.
|
|
14
|
-
* @param file - The file path to bundle.
|
|
15
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
16
|
-
* @returns A promise that resolves to the bundled module.
|
|
17
|
-
*/
|
|
18
|
-
declare function bundle<TContext extends PluginContext = PluginContext>(context: TContext, file: string, overrides?: BundleOptions): Promise<OutputFile>;
|
|
19
|
-
declare type __ΩBundleOptions = any[];
|
|
20
|
-
//#endregion
|
|
21
|
-
export { BundleOptions, __ΩBundleOptions, bundle };
|
|
22
|
-
//# sourceMappingURL=bundle.d.mts.map
|
|
1
|
+
import { n as __ΩBundleOptions, r as bundle, t as BundleOptions } from "../bundle-A-22BjWv.mjs";
|
|
2
|
+
export { BundleOptions, __ΩBundleOptions, bundle };
|
package/dist/helpers/bundle.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { resolveOptions } from "
|
|
1
|
+
import { resolveOptions } from "@powerlines/unplugin/esbuild";
|
|
2
2
|
import defu from "defu";
|
|
3
3
|
import { build } from "esbuild";
|
|
4
|
-
import { createUnpluginResolver } from "@powerlines/core/lib/unplugin";
|
|
5
4
|
import { createEsbuildPlugin } from "unplugin";
|
|
5
|
+
import { createUnpluginResolver } from "@powerlines/core/lib/unplugin";
|
|
6
6
|
import { omit } from "@stryke/helpers/omit";
|
|
7
7
|
import { findFileName } from "@stryke/path/file-path-fns";
|
|
8
8
|
|
|
@@ -34,10 +34,7 @@ async function bundle(context, file, overrides = {}) {
|
|
|
34
34
|
prefix: false,
|
|
35
35
|
overrides: defu(overrides.resolve ?? {}, { skipNodeModulesBundle: false }, context.config.resolve),
|
|
36
36
|
silenceHookLogging: true
|
|
37
|
-
}))({
|
|
38
|
-
...context.options,
|
|
39
|
-
...context.initialConfig
|
|
40
|
-
})] }));
|
|
37
|
+
}))({ ...context.options })] }));
|
|
41
38
|
if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
|
|
42
39
|
if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
|
|
43
40
|
if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.mjs","names":[],"sources":["../../src/helpers/bundle.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 {\n CreateUnpluginResolverOptions,\n
|
|
1
|
+
{"version":3,"file":"bundle.mjs","names":[],"sources":["../../src/helpers/bundle.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 {\n CreateUnpluginResolverOptions,\n PluginContext,\n ResolveOptions\n} from \"@powerlines/core\";\nimport { createUnpluginResolver } from \"@powerlines/core/lib/unplugin\";\nimport { resolveOptions } from \"@powerlines/unplugin/esbuild\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport defu from \"defu\";\nimport { build, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\nimport { EsbuildOptions } from \"../types\";\n\nexport type BundleOptions = Partial<EsbuildOptions> & {\n name?: string;\n resolve?: Partial<ResolveOptions>;\n};\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle<TContext extends PluginContext = PluginContext>(\n context: TContext,\n file: string,\n overrides: BundleOptions = {}\n): Promise<OutputFile> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const result = await build(\n defu(\n {\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: true,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...omit(overrides, [\"name\", \"resolve\"])\n },\n resolveOptions(context),\n {\n plugins: [\n createEsbuildPlugin(\n createUnpluginResolver(context, {\n name: overrides.name ?? `${findFileName(file)} Bundler`,\n prefix: false,\n overrides: defu(\n overrides.resolve ?? {},\n { skipNodeModulesBundle: false },\n context.config.resolve\n ),\n silenceHookLogging: true\n } as CreateUnpluginResolverOptions)\n )({\n ...context.options\n })\n ]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,eAAsB,OACpB,SACA,MACA,YAA2B,EAAE,EACR;CACrB,MAAM,OAAO,MAAM,QAAQ,GAAG,QAAQ,KAAK;AAC3C,KAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,KAAK,CACvC,OAAM,IAAI,MACR,sBAAsB,KAAK,yCAC5B;CAGH,MAAM,SAAS,MAAM,MACnB,KACE;EACE,aAAa,CAAC,KAAK;EACnB,OAAO;EACP,WAAW;EACX,WAAW;EACX,aAAa;EACb,QAAQ;EACR,UAAU;EACV,UAAU;EACV,UAAU;EACV,GAAG,KAAK,WAAW,CAAC,QAAQ,UAAU,CAAC;EACxC,EACD,eAAe,QAAQ,EACvB,EACE,SAAS,CACP,oBACE,uBAAuB,SAAS;EAC9B,MAAM,UAAU,QAAQ,GAAG,aAAa,KAAK,CAAC;EAC9C,QAAQ;EACR,WAAW,KACT,UAAU,WAAW,EAAE,EACvB,EAAE,uBAAuB,OAAO,EAChC,QAAQ,OAAO,QAChB;EACD,oBAAoB;EACrB,CAAkC,CACpC,CAAC,EACA,GAAG,QAAQ,SACZ,CAAC,CACH,EACF,CACF,CACF;AACD,KAAI,OAAO,OAAO,SAAS,EACzB,OAAM,IAAI,MACR,oBAAoB,KAAK,IAAI,OAAO,OACjC,KAAI,UAAS,MAAM,KAAK,CACxB,KAAK,KAAK,GACd;AAEH,KAAI,OAAO,SAAS,SAAS,EAC3B,SAAQ,KACN,2BAA2B,KAAK,IAAI,OAAO,SACxC,KAAI,YAAW,QAAQ,KAAK,CAC5B,KAAK,KAAK,GACd;AAEH,KAAI,CAAC,OAAO,eAAe,OAAO,YAAY,OAAO,QAAQ,CAAC,WAAW,EACvE,OAAM,IAAI,MACR,iCACE,KACD,iDACF;AAGH,QAAO,OAAO,YAAY,OAAO,QAAQ,CAAC"}
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_helpers_unplugin = require('./unplugin.cjs');
|
|
4
|
-
const require_helpers_bundle = require('./bundle.cjs');
|
|
2
|
+
const require_bundle = require('../bundle-B_-jRFlM.cjs');
|
|
5
3
|
const require_helpers_resolve = require('./resolve.cjs');
|
|
6
4
|
|
|
7
|
-
exports.
|
|
8
|
-
exports.bundle = require_helpers_bundle.bundle;
|
|
9
|
-
exports.createEsbuildPlugin = require_helpers_unplugin.createEsbuildPlugin;
|
|
5
|
+
exports.bundle = require_bundle.bundle;
|
|
10
6
|
exports.resolve = require_helpers_resolve.resolve;
|
|
11
|
-
exports.
|
|
12
|
-
exports.resolveModule = require_helpers_resolve.resolveModule;
|
|
13
|
-
exports.resolveOptions = require_helpers_resolve_options.resolveOptions;
|
|
7
|
+
exports.resolveModule = require_helpers_resolve.resolveModule;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { createEsbuildPlugin } from "./unplugin.cjs";
|
|
5
|
-
export { BundleOptions, DEFAULT_ESBUILD_CONFIG, __ΩBundleOptions, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
|
|
1
|
+
import { n as __ΩBundleOptions, r as bundle, t as BundleOptions } from "../bundle-HmHLeZt2.cjs";
|
|
2
|
+
import { n as resolveModule, t as resolve } from "../resolve-uvDtu7oi.cjs";
|
|
3
|
+
export { BundleOptions, __ΩBundleOptions, bundle, resolve, resolveModule };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { createEsbuildPlugin } from "./unplugin.mjs";
|
|
5
|
-
export { BundleOptions, DEFAULT_ESBUILD_CONFIG, __ΩBundleOptions, bundle, createEsbuildPlugin, resolve, resolveEntry, resolveModule, resolveOptions };
|
|
1
|
+
import { n as __ΩBundleOptions, r as bundle, t as BundleOptions } from "../bundle-A-22BjWv.mjs";
|
|
2
|
+
import { n as resolveModule, t as resolve } from "../resolve-DGrNGKUw.mjs";
|
|
3
|
+
export { BundleOptions, __ΩBundleOptions, bundle, resolve, resolveModule };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./resolve-options.mjs";
|
|
2
|
-
import { createEsbuildPlugin } from "./unplugin.mjs";
|
|
3
1
|
import { bundle } from "./bundle.mjs";
|
|
4
2
|
import { resolve, resolveModule } from "./resolve.mjs";
|
|
5
3
|
|
|
6
|
-
export {
|
|
4
|
+
export { bundle, resolve, resolveModule };
|
package/dist/helpers/resolve.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_helpers_bundle = require('./bundle.cjs');
|
|
2
|
+
const require_bundle = require('../bundle-B_-jRFlM.cjs');
|
|
4
3
|
let _stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
5
4
|
let _stryke_path_find = require("@stryke/path/find");
|
|
6
5
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
@@ -18,7 +17,7 @@ async function resolveModule(context, type, overrides) {
|
|
|
18
17
|
let typeDefinition;
|
|
19
18
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(type);
|
|
20
19
|
else typeDefinition = type;
|
|
21
|
-
const result = await
|
|
20
|
+
const result = await require_bundle.bundle(context, typeDefinition.file, overrides);
|
|
22
21
|
let resolved;
|
|
23
22
|
try {
|
|
24
23
|
resolved = await context.resolver.evalModule(result.text, {
|
|
@@ -26,8 +25,8 @@ async function resolveModule(context, type, overrides) {
|
|
|
26
25
|
ext: (0, _stryke_path_find.findFileDotExtension)(result.path)
|
|
27
26
|
});
|
|
28
27
|
} catch (error) {
|
|
29
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(error.message) && new RegExp(`Cannot find module '${context.config.framework || "powerlines"}:.*'`).test(error.message)) {
|
|
30
|
-
const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework || "powerlines"}:.*)'`))?.[1];
|
|
28
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(error.message) && new RegExp(`Cannot find module '${context.config.framework?.name || "powerlines"}:.*'`).test(error.message)) {
|
|
29
|
+
const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework?.name || "powerlines"}:.*)'`))?.[1];
|
|
31
30
|
throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${typeDefinition.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel.general === "debug" || context.config.logLevel.general === "trace" ? `
|
|
32
31
|
|
|
33
32
|
Bundle output for module:
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/resolve.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Compiles a type definition to a module and returns the module.
|
|
8
|
-
*
|
|
9
|
-
* @param context - The context object containing the environment paths.
|
|
10
|
-
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
11
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
12
|
-
* @returns A promise that resolves to the compiled module.
|
|
13
|
-
*/
|
|
14
|
-
declare function resolveModule<TResult, TContext extends PluginContext = PluginContext>(context: TContext, type: TypeDefinitionParameter, overrides?: BundleOptions): Promise<TResult>;
|
|
15
|
-
/**
|
|
16
|
-
* Compiles a type definition to a module and returns the specified export from the module.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The context object containing the environment paths.
|
|
19
|
-
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
20
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
21
|
-
* @returns A promise that resolves to the compiled module.
|
|
22
|
-
*/
|
|
23
|
-
declare function resolve<TResult, TContext extends PluginContext = PluginContext>(context: TContext, type: TypeDefinitionParameter, overrides?: BundleOptions): Promise<TResult>;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { resolve, resolveModule };
|
|
26
|
-
//# sourceMappingURL=resolve.d.cts.map
|
|
1
|
+
import { n as resolveModule, t as resolve } from "../resolve-uvDtu7oi.cjs";
|
|
2
|
+
export { resolve, resolveModule };
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
4
|
-
|
|
5
|
-
//#region src/helpers/resolve.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Compiles a type definition to a module and returns the module.
|
|
8
|
-
*
|
|
9
|
-
* @param context - The context object containing the environment paths.
|
|
10
|
-
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
11
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
12
|
-
* @returns A promise that resolves to the compiled module.
|
|
13
|
-
*/
|
|
14
|
-
declare function resolveModule<TResult, TContext extends PluginContext = PluginContext>(context: TContext, type: TypeDefinitionParameter, overrides?: BundleOptions): Promise<TResult>;
|
|
15
|
-
/**
|
|
16
|
-
* Compiles a type definition to a module and returns the specified export from the module.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The context object containing the environment paths.
|
|
19
|
-
* @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
|
|
20
|
-
* @param overrides - Optional overrides for the ESBuild configuration.
|
|
21
|
-
* @returns A promise that resolves to the compiled module.
|
|
22
|
-
*/
|
|
23
|
-
declare function resolve<TResult, TContext extends PluginContext = PluginContext>(context: TContext, type: TypeDefinitionParameter, overrides?: BundleOptions): Promise<TResult>;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { resolve, resolveModule };
|
|
26
|
-
//# sourceMappingURL=resolve.d.mts.map
|
|
1
|
+
import { n as resolveModule, t as resolve } from "../resolve-DGrNGKUw.mjs";
|
|
2
|
+
export { resolve, resolveModule };
|
package/dist/helpers/resolve.mjs
CHANGED
|
@@ -24,8 +24,8 @@ async function resolveModule(context, type, overrides) {
|
|
|
24
24
|
ext: findFileDotExtension(result.path)
|
|
25
25
|
});
|
|
26
26
|
} catch (error) {
|
|
27
|
-
if (isSetString(error.message) && new RegExp(`Cannot find module '${context.config.framework || "powerlines"}:.*'`).test(error.message)) {
|
|
28
|
-
const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework || "powerlines"}:.*)'`))?.[1];
|
|
27
|
+
if (isSetString(error.message) && new RegExp(`Cannot find module '${context.config.framework?.name || "powerlines"}:.*'`).test(error.message)) {
|
|
28
|
+
const moduleName = error.message.match(new RegExp(`Cannot find module '(${context.config.framework?.name || "powerlines"}:.*)'`))?.[1];
|
|
29
29
|
throw new Error(`The module "${moduleName}" could not be resolved while evaluating "${typeDefinition.file}". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${context.config.logLevel.general === "debug" || context.config.logLevel.general === "trace" ? `
|
|
30
30
|
|
|
31
31
|
Bundle output for module:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/helpers/resolve.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 { PluginContext } from \"@powerlines/core\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { findFileDotExtension } from \"@stryke/path/find\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { bundle, BundleOptions } from \"./bundle\";\n\n/**\n * Compiles a type definition to a module and returns the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolveModule<\n TResult,\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n type: TypeDefinitionParameter,\n overrides?: BundleOptions\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const result = await bundle<TContext>(\n context,\n typeDefinition.file,\n overrides\n );\n\n let resolved: any;\n try {\n resolved = await context.resolver.evalModule(result.text, {\n filename: result.path,\n ext: findFileDotExtension(result.path)\n });\n } catch (error) {\n if (\n isSetString((error as Error).message) &&\n new RegExp(\n `Cannot find module '${context.config.framework || \"powerlines\"}:.*'`\n ).test((error as Error).message)\n ) {\n const moduleName = (error as Error).message.match(\n new RegExp(\n `Cannot find module '(${context.config.framework || \"powerlines\"}:.*)'`\n )\n )?.[1];\n throw new Error(\n `The module \"${moduleName}\" could not be resolved while evaluating \"${\n typeDefinition.file\n }\". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${\n context.config.logLevel.general === \"debug\" ||\n context.config.logLevel.general === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n throw new Error(\n `Failed to evaluate the bundled module for \"${\n typeDefinition.file\n }\". Error: ${(error as Error).message}${\n context.config.logLevel.general === \"debug\" ||\n context.config.logLevel.general === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n return resolved;\n}\n\n/**\n * Compiles a type definition to a module and returns the specified export from the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolve<\n TResult,\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n type: TypeDefinitionParameter,\n overrides?: BundleOptions\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const resolved = await resolveModule<Record<string, any>, TContext>(\n context,\n typeDefinition,\n overrides\n );\n\n let exportName = typeDefinition.name;\n if (!exportName) {\n exportName = \"default\";\n }\n\n const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];\n if (resolvedExport === undefined) {\n throw new Error(\n `The export \"${exportName}\" could not be resolved in the \"${\n typeDefinition.file\n }\" module. ${\n Object.keys(resolved).length === 0\n ? `After bundling, no exports were found in the module. Please ensure that the \"${\n typeDefinition.file\n }\" module has a \"${exportName}\" export with the desired value.`\n : `After bundling, the available exports were: ${Object.keys(\n resolved\n ).join(\n \", \"\n )}. Please ensure that the export exists and is correctly named.`\n }`\n );\n }\n\n return resolvedExport;\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,eAAsB,cAIpB,SACA,MACA,WACkB;CAClB,IAAI;AACJ,KAAI,YAAY,KAAK,CACnB,kBAAiB,oBAAoB,KAAK;KAE1C,kBAAiB;CAGnB,MAAM,SAAS,MAAM,OACnB,SACA,eAAe,MACf,UACD;CAED,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,QAAQ,SAAS,WAAW,OAAO,MAAM;GACxD,UAAU,OAAO;GACjB,KAAK,qBAAqB,OAAO,KAAK;GACvC,CAAC;UACK,OAAO;AACd,MACE,YAAa,MAAgB,QAAQ,IACrC,IAAI,OACF,uBAAuB,QAAQ,OAAO,
|
|
1
|
+
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/helpers/resolve.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 { PluginContext } from \"@powerlines/core\";\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { findFileDotExtension } from \"@stryke/path/find\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { bundle, BundleOptions } from \"./bundle\";\n\n/**\n * Compiles a type definition to a module and returns the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolveModule<\n TResult,\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n type: TypeDefinitionParameter,\n overrides?: BundleOptions\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const result = await bundle<TContext>(\n context,\n typeDefinition.file,\n overrides\n );\n\n let resolved: any;\n try {\n resolved = await context.resolver.evalModule(result.text, {\n filename: result.path,\n ext: findFileDotExtension(result.path)\n });\n } catch (error) {\n if (\n isSetString((error as Error).message) &&\n new RegExp(\n `Cannot find module '${context.config.framework?.name || \"powerlines\"}:.*'`\n ).test((error as Error).message)\n ) {\n const moduleName = (error as Error).message.match(\n new RegExp(\n `Cannot find module '(${context.config.framework?.name || \"powerlines\"}:.*)'`\n )\n )?.[1];\n throw new Error(\n `The module \"${moduleName}\" could not be resolved while evaluating \"${\n typeDefinition.file\n }\". It is possible the required built-in modules have not yet been generated. Please check the order of your plugins. ${\n context.config.logLevel.general === \"debug\" ||\n context.config.logLevel.general === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n throw new Error(\n `Failed to evaluate the bundled module for \"${\n typeDefinition.file\n }\". Error: ${(error as Error).message}${\n context.config.logLevel.general === \"debug\" ||\n context.config.logLevel.general === \"trace\"\n ? `\n\nBundle output for module:\n${result.text}`\n : \"\"\n }`\n );\n }\n\n return resolved;\n}\n\n/**\n * Compiles a type definition to a module and returns the specified export from the module.\n *\n * @param context - The context object containing the environment paths.\n * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.\n * @param overrides - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the compiled module.\n */\nexport async function resolve<\n TResult,\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n type: TypeDefinitionParameter,\n overrides?: BundleOptions\n): Promise<TResult> {\n let typeDefinition!: TypeDefinition;\n if (isSetString(type)) {\n typeDefinition = parseTypeDefinition(type) as TypeDefinition;\n } else {\n typeDefinition = type;\n }\n\n const resolved = await resolveModule<Record<string, any>, TContext>(\n context,\n typeDefinition,\n overrides\n );\n\n let exportName = typeDefinition.name;\n if (!exportName) {\n exportName = \"default\";\n }\n\n const resolvedExport = resolved[exportName] ?? resolved[`__Ω${exportName}`];\n if (resolvedExport === undefined) {\n throw new Error(\n `The export \"${exportName}\" could not be resolved in the \"${\n typeDefinition.file\n }\" module. ${\n Object.keys(resolved).length === 0\n ? `After bundling, no exports were found in the module. Please ensure that the \"${\n typeDefinition.file\n }\" module has a \"${exportName}\" export with the desired value.`\n : `After bundling, the available exports were: ${Object.keys(\n resolved\n ).join(\n \", \"\n )}. Please ensure that the export exists and is correctly named.`\n }`\n );\n }\n\n return resolvedExport;\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,eAAsB,cAIpB,SACA,MACA,WACkB;CAClB,IAAI;AACJ,KAAI,YAAY,KAAK,CACnB,kBAAiB,oBAAoB,KAAK;KAE1C,kBAAiB;CAGnB,MAAM,SAAS,MAAM,OACnB,SACA,eAAe,MACf,UACD;CAED,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,QAAQ,SAAS,WAAW,OAAO,MAAM;GACxD,UAAU,OAAO;GACjB,KAAK,qBAAqB,OAAO,KAAK;GACvC,CAAC;UACK,OAAO;AACd,MACE,YAAa,MAAgB,QAAQ,IACrC,IAAI,OACF,uBAAuB,QAAQ,OAAO,WAAW,QAAQ,aAAa,MACvE,CAAC,KAAM,MAAgB,QAAQ,EAChC;GACA,MAAM,aAAc,MAAgB,QAAQ,MAC1C,IAAI,OACF,wBAAwB,QAAQ,OAAO,WAAW,QAAQ,aAAa,OACxE,CACF,GAAG;AACJ,SAAM,IAAI,MACR,eAAe,WAAW,4CACxB,eAAe,KAChB,uHACC,QAAQ,OAAO,SAAS,YAAY,WACpC,QAAQ,OAAO,SAAS,YAAY,UAChC;;;EAGZ,OAAO,SACK,KAEP;;AAGH,QAAM,IAAI,MACR,8CACE,eAAe,KAChB,YAAa,MAAgB,UAC5B,QAAQ,OAAO,SAAS,YAAY,WACpC,QAAQ,OAAO,SAAS,YAAY,UAChC;;;EAGV,OAAO,SACG,KAEP;;AAGH,QAAO;;;;;;;;;;AAWT,eAAsB,QAIpB,SACA,MACA,WACkB;CAClB,IAAI;AACJ,KAAI,YAAY,KAAK,CACnB,kBAAiB,oBAAoB,KAAK;KAE1C,kBAAiB;CAGnB,MAAM,WAAW,MAAM,cACrB,SACA,gBACA,UACD;CAED,IAAI,aAAa,eAAe;AAChC,KAAI,CAAC,WACH,cAAa;CAGf,MAAM,iBAAiB,SAAS,eAAe,SAAS,MAAM;AAC9D,KAAI,mBAAmB,OACrB,OAAM,IAAI,MACR,eAAe,WAAW,kCACxB,eAAe,KAChB,YACC,OAAO,KAAK,SAAS,CAAC,WAAW,IAC7B,gFACE,eAAe,KAChB,kBAAkB,WAAW,oCAC9B,+CAA+C,OAAO,KACpD,SACD,CAAC,KACA,KACD,CAAC,kEAET;AAGH,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const
|
|
3
|
-
const require_helpers_resolve_options = require('./helpers/resolve-options.cjs');
|
|
4
|
-
const require_helpers_unplugin = require('./helpers/unplugin.cjs');
|
|
5
|
-
const require_helpers_bundle = require('./helpers/bundle.cjs');
|
|
2
|
+
const require_bundle = require('./bundle-B_-jRFlM.cjs');
|
|
6
3
|
const require_helpers_resolve = require('./helpers/resolve.cjs');
|
|
7
4
|
require('./helpers/index.cjs');
|
|
5
|
+
require('./types/index.cjs');
|
|
6
|
+
let _powerlines_core = require("@powerlines/core");
|
|
8
7
|
let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
|
|
8
|
+
let _powerlines_unplugin_esbuild = require("@powerlines/unplugin/esbuild");
|
|
9
9
|
let defu = require("defu");
|
|
10
|
-
defu =
|
|
10
|
+
defu = require_bundle.__toESM(defu, 1);
|
|
11
11
|
let esbuild = require("esbuild");
|
|
12
|
+
let unplugin = require("unplugin");
|
|
12
13
|
|
|
13
14
|
//#region src/index.ts
|
|
14
15
|
/**
|
|
@@ -20,18 +21,21 @@ const plugin = (options = {}) => {
|
|
|
20
21
|
config() {
|
|
21
22
|
return {
|
|
22
23
|
output: { format: ["esm"] },
|
|
23
|
-
esbuild: {
|
|
24
|
-
...require_helpers_resolve_options.DEFAULT_ESBUILD_CONFIG,
|
|
25
|
-
...options
|
|
26
|
-
}
|
|
24
|
+
esbuild: { ...options }
|
|
27
25
|
};
|
|
28
26
|
},
|
|
29
27
|
async build() {
|
|
30
28
|
this.debug("Starting Esbuild build process...");
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const resolved = (0, _powerlines_unplugin_esbuild.resolveOptions)(this);
|
|
30
|
+
const options = (0, defu.default)(this.config.esbuild, {
|
|
31
|
+
...resolved,
|
|
32
|
+
entryPoints: (0, _powerlines_unplugin_esbuild.resolveEntry)(this, this.entry),
|
|
33
|
+
config: false,
|
|
34
|
+
plugins: [(0, unplugin.createEsbuildPlugin)((0, _powerlines_core.createUnplugin)(this, {
|
|
35
|
+
silenceHookLogging: true,
|
|
36
|
+
name: "esbuild"
|
|
37
|
+
}))()]
|
|
38
|
+
});
|
|
35
39
|
this.debug({
|
|
36
40
|
meta: { category: "config" },
|
|
37
41
|
message: `Resolved Esbuild configuration: \n${(0, _powerlines_core_plugin_utils.formatConfig)(options)}`
|
|
@@ -42,12 +46,8 @@ const plugin = (options = {}) => {
|
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
//#endregion
|
|
45
|
-
exports.
|
|
46
|
-
exports.bundle = require_helpers_bundle.bundle;
|
|
47
|
-
exports.createEsbuildPlugin = require_helpers_unplugin.createEsbuildPlugin;
|
|
49
|
+
exports.bundle = require_bundle.bundle;
|
|
48
50
|
exports.default = plugin;
|
|
49
51
|
exports.plugin = plugin;
|
|
50
52
|
exports.resolve = require_helpers_resolve.resolve;
|
|
51
|
-
exports.
|
|
52
|
-
exports.resolveModule = require_helpers_resolve.resolveModule;
|
|
53
|
-
exports.resolveOptions = require_helpers_resolve_options.resolveOptions;
|
|
53
|
+
exports.resolveModule = require_helpers_resolve.resolveModule;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EsbuildPluginContext,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DEFAULT_ESBUILD_CONFIG, resolveEntry, resolveOptions } from "./helpers/resolve-options.cjs";
|
|
6
|
-
import { createEsbuildPlugin } from "./helpers/unplugin.cjs";
|
|
1
|
+
import { n as __ΩEsbuildOptions, t as EsbuildOptions } from "./build-B8u-bRQt.cjs";
|
|
2
|
+
import { a as __ΩEsbuildPluginContext, c as __ΩEsbuildPluginUserConfig, i as EsbuildPluginUserConfig, n as EsbuildPluginOptions, o as __ΩEsbuildPluginOptions, r as EsbuildPluginResolvedConfig, s as __ΩEsbuildPluginResolvedConfig, t as EsbuildPluginContext } from "./plugin-g0pkWAvQ.cjs";
|
|
3
|
+
import { n as __ΩBundleOptions, r as bundle, t as BundleOptions } from "./bundle-HmHLeZt2.cjs";
|
|
4
|
+
import { n as resolveModule, t as resolve } from "./resolve-uvDtu7oi.cjs";
|
|
7
5
|
import { Plugin } from "@powerlines/core";
|
|
8
6
|
|
|
9
7
|
//#region src/index.d.ts
|
|
@@ -17,5 +15,5 @@ declare module "@powerlines/core" {
|
|
|
17
15
|
*/
|
|
18
16
|
declare const plugin: <TContext extends EsbuildPluginContext = EsbuildPluginContext>(options?: EsbuildPluginOptions) => Plugin<TContext>;
|
|
19
17
|
//#endregion
|
|
20
|
-
export { BundleOptions,
|
|
18
|
+
export { BundleOptions, EsbuildOptions, EsbuildPluginContext, EsbuildPluginOptions, EsbuildPluginResolvedConfig, EsbuildPluginUserConfig, __ΩBundleOptions, __ΩEsbuildOptions, __ΩEsbuildPluginContext, __ΩEsbuildPluginOptions, __ΩEsbuildPluginResolvedConfig, __ΩEsbuildPluginUserConfig, bundle, plugin as default, plugin, resolve, resolveModule };
|
|
21
19
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;YA8BY,MAAA;IACR,OAAA,GAAU,oBAAA;EAAA;AAAA;AAJU;;;AAAA,cAWX,MAAA,oBACM,oBAAA,GAAuB,oBAAA,EAExC,OAAA,GAAS,oBAAA,KACR,MAAA,CAAO,QAAA"}
|