@powerlines/plugin-esbuild 0.13.130 → 0.13.131
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/helpers/index.cjs +3 -2
- package/dist/helpers/index.d.cts +3 -1
- package/dist/helpers/index.d.mts +3 -1
- package/dist/helpers/index.mjs +2 -1
- package/dist/helpers/unplugin.cjs +2 -11
- package/dist/helpers/unplugin.d.cts +2 -6
- package/dist/helpers/unplugin.d.mts +2 -6
- package/dist/helpers/unplugin.mjs +1 -9
- package/dist/helpers-B15z10jN.mjs +1 -0
- package/dist/helpers-LF26RHol.cjs +0 -0
- package/dist/index-9iG2qHLe.d.mts +1 -0
- package/dist/index-D4ELpJXS.d.cts +1 -0
- package/dist/index-D6CnpA_r.d.cts +1 -0
- package/dist/index-DL0uimUT.d.mts +1 -0
- package/dist/index.cjs +120 -10
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +114 -3
- package/dist/plugin-22mS98Z7.d.mts +1765 -0
- package/dist/plugin-DClEUVBW.d.cts +1762 -0
- package/dist/plugin-ifZVa20V.mjs +1 -0
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.mjs +3 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +1 -12
- package/dist/types/plugin.d.mts +1 -12
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-U3zd8PTP.mjs +1 -0
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-CAREou6Y.cjs +4671 -0
- package/dist/unplugin-DMEUFyts.d.cts +7 -0
- package/dist/unplugin-DgwnB-az.mjs +4615 -0
- package/dist/unplugin-Ke8_-tqb.d.mts +7 -0
- package/package.json +3 -3
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/powerlines/schemas/fs.cjs +0 -226
- package/dist/powerlines/schemas/fs.mjs +0 -224
- package/dist/powerlines/src/api.cjs +0 -580
- package/dist/powerlines/src/api.mjs +0 -578
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
- package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
- package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
- package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
- package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
- package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
- package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
- package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
- package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -118
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -114
- package/dist/powerlines/src/lib/config-file.cjs +0 -79
- package/dist/powerlines/src/lib/config-file.mjs +0 -76
- package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
- package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
- package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
- package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
- package/dist/powerlines/src/lib/entry.cjs +0 -71
- package/dist/powerlines/src/lib/entry.mjs +0 -67
- package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
- package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
- package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
- package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
- package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
- package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
- package/dist/powerlines/src/lib/logger.cjs +0 -58
- package/dist/powerlines/src/lib/logger.mjs +0 -55
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
- package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
- package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
- package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
- package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
- package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
- package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
- package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
- package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
- package/dist/powerlines/src/types/babel.d.mts +0 -4
- package/dist/powerlines/src/types/build.cjs +0 -15
- package/dist/powerlines/src/types/build.d.cts +0 -149
- package/dist/powerlines/src/types/build.d.mts +0 -149
- package/dist/powerlines/src/types/build.mjs +0 -14
- package/dist/powerlines/src/types/commands.cjs +0 -16
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/commands.mjs +0 -15
- package/dist/powerlines/src/types/config.d.cts +0 -370
- package/dist/powerlines/src/types/config.d.mts +0 -371
- package/dist/powerlines/src/types/context.d.cts +0 -403
- package/dist/powerlines/src/types/context.d.mts +0 -405
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/plugin.cjs +0 -32
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/plugin.mjs +0 -31
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -83
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_unplugin = require('../unplugin-CAREou6Y.cjs');
|
|
2
|
+
require('../helpers-LF26RHol.cjs');
|
|
2
3
|
|
|
3
|
-
exports.createESBuildPlugin =
|
|
4
|
+
exports.createESBuildPlugin = require_unplugin.createESBuildPlugin;
|
package/dist/helpers/index.d.cts
CHANGED
package/dist/helpers/index.d.mts
CHANGED
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_plugin = require('../powerlines/src/lib/unplugin/plugin.cjs');
|
|
3
|
-
require('../powerlines/src/lib/unplugin/index.cjs');
|
|
4
|
-
let unplugin = require("unplugin");
|
|
1
|
+
const require_unplugin = require('../unplugin-CAREou6Y.cjs');
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
function createESBuildPlugin(context) {
|
|
8
|
-
return (0, unplugin.createEsbuildPlugin)(require_plugin.createUnplugin(context))({});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.createESBuildPlugin = createESBuildPlugin;
|
|
3
|
+
exports.createESBuildPlugin = require_unplugin.createESBuildPlugin;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/unplugin.d.ts
|
|
5
|
-
declare function createESBuildPlugin(context: ESBuildPluginContext): esbuild0.Plugin;
|
|
6
|
-
//#endregion
|
|
1
|
+
import "../plugin-DClEUVBW.cjs";
|
|
2
|
+
import { t as createESBuildPlugin } from "../unplugin-DMEUFyts.cjs";
|
|
7
3
|
export { createESBuildPlugin };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/unplugin.d.ts
|
|
5
|
-
declare function createESBuildPlugin(context: ESBuildPluginContext): esbuild0.Plugin;
|
|
6
|
-
//#endregion
|
|
1
|
+
import "../plugin-22mS98Z7.mjs";
|
|
2
|
+
import { t as createESBuildPlugin } from "../unplugin-Ke8_-tqb.mjs";
|
|
7
3
|
export { createESBuildPlugin };
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../powerlines/src/lib/unplugin/index.mjs";
|
|
3
|
-
import { createEsbuildPlugin } from "unplugin";
|
|
1
|
+
import { t as createESBuildPlugin } from "../unplugin-DgwnB-az.mjs";
|
|
4
2
|
|
|
5
|
-
//#region src/helpers/unplugin.ts
|
|
6
|
-
function createESBuildPlugin(context) {
|
|
7
|
-
return createEsbuildPlugin(createUnplugin(context))({});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
3
|
export { createESBuildPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,122 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require('./
|
|
2
|
+
const require_unplugin = require('./unplugin-CAREou6Y.cjs');
|
|
3
|
+
require('./helpers-LF26RHol.cjs');
|
|
4
|
+
require('./plugin-pBKbb5K9.cjs');
|
|
5
|
+
require('./types-o3zWarRp.cjs');
|
|
6
6
|
let defu = require("defu");
|
|
7
|
-
defu =
|
|
7
|
+
defu = require_unplugin.__toESM(defu);
|
|
8
8
|
let esbuild = require("esbuild");
|
|
9
|
+
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
10
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
11
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
12
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
13
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
9
14
|
|
|
15
|
+
//#region ../powerlines/src/lib/build/esbuild.ts
|
|
16
|
+
const DEFAULT_ESBUILD_CONFIG = {
|
|
17
|
+
target: "esnext",
|
|
18
|
+
platform: "neutral",
|
|
19
|
+
format: "esm",
|
|
20
|
+
write: true,
|
|
21
|
+
minify: true,
|
|
22
|
+
sourcemap: false,
|
|
23
|
+
bundle: true,
|
|
24
|
+
treeShaking: true,
|
|
25
|
+
keepNames: true,
|
|
26
|
+
splitting: true,
|
|
27
|
+
logLevel: "silent"
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the entry options for esbuild.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The build context.
|
|
33
|
+
* @param entryPoints - The entry points to resolve.
|
|
34
|
+
* @returns The resolved entry options.
|
|
35
|
+
*/
|
|
36
|
+
function resolveESBuildEntry(context, entryPoints = []) {
|
|
37
|
+
return entryPoints.reduce((ret, entry) => {
|
|
38
|
+
if ((0, __stryke_type_checks_is_string.isString)(entry)) ret[(0, __stryke_path_replace.replaceExtension)((0, __stryke_path_replace.replacePath)(entry, context.config.sourceRoot || context.config.projectRoot))] = (0, __stryke_path_replace.replacePath)(entry, context.config.sourceRoot || context.config.projectRoot);
|
|
39
|
+
else ret[entry.output || require_unplugin.resolveEntryOutput(context, entry.input || entry)] = require_unplugin.resolveEntryInputFile(context, entry.input || entry);
|
|
40
|
+
return ret;
|
|
41
|
+
}, {});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolves the esbuild options.
|
|
45
|
+
*
|
|
46
|
+
* @param context - The build context.
|
|
47
|
+
* @returns The resolved esbuild options.
|
|
48
|
+
*/
|
|
49
|
+
function extractESBuildConfig(context) {
|
|
50
|
+
const inject = context.config.build.override.inject ?? context.config.build.inject;
|
|
51
|
+
if (inject && Object.keys(inject).length > 0) context.fs.writeSync((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
|
|
52
|
+
if (value) if (Array.isArray(value)) {
|
|
53
|
+
if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) {
|
|
54
|
+
if (value.length === 1) return `
|
|
55
|
+
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
56
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
57
|
+
else if (value.length > 1) return `
|
|
58
|
+
import ${value[1] === "*" ? `* as ${(0, __stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, __stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
|
|
59
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
60
|
+
} else if (value.length === 1) return `
|
|
61
|
+
import ${key} from "${value[0]}";
|
|
62
|
+
export { ${key} };`;
|
|
63
|
+
else if (value.length > 1) return `
|
|
64
|
+
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
65
|
+
export { ${key} };`;
|
|
66
|
+
} else if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) return `
|
|
67
|
+
import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
|
|
68
|
+
export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
|
|
69
|
+
else return `
|
|
70
|
+
import ${key} from "${value}";
|
|
71
|
+
export { ${key} };`;
|
|
72
|
+
return "";
|
|
73
|
+
}).join("\n"));
|
|
74
|
+
return (0, defu.default)({
|
|
75
|
+
alias: context.builtins.reduce((ret, id) => {
|
|
76
|
+
if (!ret[id]) {
|
|
77
|
+
const path = context.fs.ids[id];
|
|
78
|
+
if (path) ret[id] = path;
|
|
79
|
+
}
|
|
80
|
+
return ret;
|
|
81
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
82
|
+
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
83
|
+
return ret;
|
|
84
|
+
}, {}) : context.config.build.alias : {}),
|
|
85
|
+
inject: inject && Object.keys(inject).length > 0 ? [(0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
|
|
86
|
+
}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build.override, [
|
|
87
|
+
"alias",
|
|
88
|
+
"inject",
|
|
89
|
+
"external",
|
|
90
|
+
"noExternal",
|
|
91
|
+
"skipNodeModulesBundle",
|
|
92
|
+
"extensions"
|
|
93
|
+
]) : {}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, [
|
|
94
|
+
"alias",
|
|
95
|
+
"inject",
|
|
96
|
+
"external",
|
|
97
|
+
"noExternal",
|
|
98
|
+
"skipNodeModulesBundle",
|
|
99
|
+
"extensions",
|
|
100
|
+
"variant",
|
|
101
|
+
"override"
|
|
102
|
+
]) : {}, {
|
|
103
|
+
mainFields: context.config.build.mainFields,
|
|
104
|
+
conditions: context.config.build.conditions,
|
|
105
|
+
define: context.config.build.define,
|
|
106
|
+
resolveExtensions: context.config.build.extensions,
|
|
107
|
+
packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
|
|
108
|
+
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
109
|
+
platform: context.config.build.platform,
|
|
110
|
+
treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
|
|
111
|
+
outdir: context.config.output.buildPath,
|
|
112
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
113
|
+
minify: context.config.mode !== "development",
|
|
114
|
+
metafile: context.config.mode === "development",
|
|
115
|
+
sourcemap: context.config.mode === "development"
|
|
116
|
+
}, DEFAULT_ESBUILD_CONFIG);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
10
120
|
//#region src/index.ts
|
|
11
121
|
/**
|
|
12
122
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
@@ -18,7 +128,7 @@ const plugin = (options = {}) => {
|
|
|
18
128
|
return {
|
|
19
129
|
output: { format: ["esm"] },
|
|
20
130
|
build: {
|
|
21
|
-
...
|
|
131
|
+
...DEFAULT_ESBUILD_CONFIG,
|
|
22
132
|
...options,
|
|
23
133
|
variant: "esbuild"
|
|
24
134
|
}
|
|
@@ -26,15 +136,15 @@ const plugin = (options = {}) => {
|
|
|
26
136
|
},
|
|
27
137
|
async build() {
|
|
28
138
|
await (0, esbuild.build)((0, defu.default)({
|
|
29
|
-
entryPoints:
|
|
30
|
-
plugins: [
|
|
31
|
-
},
|
|
139
|
+
entryPoints: resolveESBuildEntry(this, this.entry),
|
|
140
|
+
plugins: [require_unplugin.createESBuildPlugin(this)]
|
|
141
|
+
}, extractESBuildConfig(this)));
|
|
32
142
|
}
|
|
33
143
|
};
|
|
34
144
|
};
|
|
35
145
|
var src_default = plugin;
|
|
36
146
|
|
|
37
147
|
//#endregion
|
|
38
|
-
exports.createESBuildPlugin =
|
|
148
|
+
exports.createESBuildPlugin = require_unplugin.createESBuildPlugin;
|
|
39
149
|
exports.default = src_default;
|
|
40
150
|
exports.plugin = plugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Plugin } from "./
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { a as __ΩESBuildPluginOptions, i as __ΩESBuildPluginContext, n as ESBuildPluginOptions, o as __ΩESBuildPluginResolvedConfig, r as ESBuildPluginResolvedConfig, s as Plugin, t as ESBuildPluginContext } from "./plugin-DClEUVBW.cjs";
|
|
2
|
+
import { t as createESBuildPlugin } from "./unplugin-DMEUFyts.cjs";
|
|
3
|
+
import "./index-D6CnpA_r.cjs";
|
|
4
|
+
import "./index-D4ELpJXS.cjs";
|
|
4
5
|
|
|
5
6
|
//#region src/index.d.ts
|
|
6
7
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Plugin } from "./
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import "./types/index.mjs";
|
|
1
|
+
import { a as __ΩESBuildPluginOptions, i as __ΩESBuildPluginContext, n as ESBuildPluginOptions, o as __ΩESBuildPluginResolvedConfig, r as ESBuildPluginResolvedConfig, s as Plugin, t as ESBuildPluginContext } from "./plugin-22mS98Z7.mjs";
|
|
2
|
+
import { t as createESBuildPlugin } from "./unplugin-Ke8_-tqb.mjs";
|
|
3
|
+
import "./index-DL0uimUT.mjs";
|
|
4
|
+
import "./index-9iG2qHLe.mjs";
|
|
6
5
|
|
|
7
6
|
//#region src/index.d.ts
|
|
7
|
+
|
|
8
8
|
/**
|
|
9
9
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
10
10
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
1
|
+
import { n as resolveEntryInputFile, r as resolveEntryOutput, t as createESBuildPlugin } from "./unplugin-DgwnB-az.mjs";
|
|
2
|
+
import "./helpers-B15z10jN.mjs";
|
|
3
|
+
import "./plugin-ifZVa20V.mjs";
|
|
4
|
+
import "./types-U3zd8PTP.mjs";
|
|
4
5
|
import defu$1 from "defu";
|
|
5
6
|
import { build } from "esbuild";
|
|
7
|
+
import { omit } from "@stryke/helpers/omit";
|
|
8
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
9
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
10
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
11
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
6
12
|
|
|
13
|
+
//#region ../powerlines/src/lib/build/esbuild.ts
|
|
14
|
+
const DEFAULT_ESBUILD_CONFIG = {
|
|
15
|
+
target: "esnext",
|
|
16
|
+
platform: "neutral",
|
|
17
|
+
format: "esm",
|
|
18
|
+
write: true,
|
|
19
|
+
minify: true,
|
|
20
|
+
sourcemap: false,
|
|
21
|
+
bundle: true,
|
|
22
|
+
treeShaking: true,
|
|
23
|
+
keepNames: true,
|
|
24
|
+
splitting: true,
|
|
25
|
+
logLevel: "silent"
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the entry options for esbuild.
|
|
29
|
+
*
|
|
30
|
+
* @param context - The build context.
|
|
31
|
+
* @param entryPoints - The entry points to resolve.
|
|
32
|
+
* @returns The resolved entry options.
|
|
33
|
+
*/
|
|
34
|
+
function resolveESBuildEntry(context, entryPoints = []) {
|
|
35
|
+
return entryPoints.reduce((ret, entry) => {
|
|
36
|
+
if (isString(entry)) ret[replaceExtension(replacePath(entry, context.config.sourceRoot || context.config.projectRoot))] = replacePath(entry, context.config.sourceRoot || context.config.projectRoot);
|
|
37
|
+
else ret[entry.output || resolveEntryOutput(context, entry.input || entry)] = resolveEntryInputFile(context, entry.input || entry);
|
|
38
|
+
return ret;
|
|
39
|
+
}, {});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the esbuild options.
|
|
43
|
+
*
|
|
44
|
+
* @param context - The build context.
|
|
45
|
+
* @returns The resolved esbuild options.
|
|
46
|
+
*/
|
|
47
|
+
function extractESBuildConfig(context) {
|
|
48
|
+
const inject = context.config.build.override.inject ?? context.config.build.inject;
|
|
49
|
+
if (inject && Object.keys(inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
|
|
50
|
+
if (value) if (Array.isArray(value)) {
|
|
51
|
+
if (camelCase(key) !== key) {
|
|
52
|
+
if (value.length === 1) return `
|
|
53
|
+
import ${camelCase(key)} from "${value[0]}";
|
|
54
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
55
|
+
else if (value.length > 1) return `
|
|
56
|
+
import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
|
|
57
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
58
|
+
} else if (value.length === 1) return `
|
|
59
|
+
import ${key} from "${value[0]}";
|
|
60
|
+
export { ${key} };`;
|
|
61
|
+
else if (value.length > 1) return `
|
|
62
|
+
import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
|
|
63
|
+
export { ${key} };`;
|
|
64
|
+
} else if (camelCase(key) !== key) return `
|
|
65
|
+
import ${camelCase(key)} from "${value[0]}";
|
|
66
|
+
export { ${camelCase(key)} as "${key}" }`;
|
|
67
|
+
else return `
|
|
68
|
+
import ${key} from "${value}";
|
|
69
|
+
export { ${key} };`;
|
|
70
|
+
return "";
|
|
71
|
+
}).join("\n"));
|
|
72
|
+
return defu$1({
|
|
73
|
+
alias: context.builtins.reduce((ret, id) => {
|
|
74
|
+
if (!ret[id]) {
|
|
75
|
+
const path = context.fs.ids[id];
|
|
76
|
+
if (path) ret[id] = path;
|
|
77
|
+
}
|
|
78
|
+
return ret;
|
|
79
|
+
}, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
|
|
80
|
+
if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
|
|
81
|
+
return ret;
|
|
82
|
+
}, {}) : context.config.build.alias : {}),
|
|
83
|
+
inject: inject && Object.keys(inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
|
|
84
|
+
}, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
|
|
85
|
+
"alias",
|
|
86
|
+
"inject",
|
|
87
|
+
"external",
|
|
88
|
+
"noExternal",
|
|
89
|
+
"skipNodeModulesBundle",
|
|
90
|
+
"extensions"
|
|
91
|
+
]) : {}, context.config.build.variant === "esbuild" ? omit(context.config.build, [
|
|
92
|
+
"alias",
|
|
93
|
+
"inject",
|
|
94
|
+
"external",
|
|
95
|
+
"noExternal",
|
|
96
|
+
"skipNodeModulesBundle",
|
|
97
|
+
"extensions",
|
|
98
|
+
"variant",
|
|
99
|
+
"override"
|
|
100
|
+
]) : {}, {
|
|
101
|
+
mainFields: context.config.build.mainFields,
|
|
102
|
+
conditions: context.config.build.conditions,
|
|
103
|
+
define: context.config.build.define,
|
|
104
|
+
resolveExtensions: context.config.build.extensions,
|
|
105
|
+
packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
|
|
106
|
+
format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
|
|
107
|
+
platform: context.config.build.platform,
|
|
108
|
+
treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
|
|
109
|
+
outdir: context.config.output.buildPath,
|
|
110
|
+
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
111
|
+
minify: context.config.mode !== "development",
|
|
112
|
+
metafile: context.config.mode === "development",
|
|
113
|
+
sourcemap: context.config.mode === "development"
|
|
114
|
+
}, DEFAULT_ESBUILD_CONFIG);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
7
118
|
//#region src/index.ts
|
|
8
119
|
/**
|
|
9
120
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|