@powerlines/plugin-esbuild 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4LCU5I5Q.cjs → chunk-DKSPBMRI.cjs} +3 -3
- package/dist/{chunk-4LCU5I5Q.cjs.map → chunk-DKSPBMRI.cjs.map} +1 -1
- package/dist/{chunk-5M2RJ6V6.js → chunk-FGTVQNHX.js} +3 -3
- package/dist/{chunk-5M2RJ6V6.js.map → chunk-FGTVQNHX.js.map} +1 -1
- package/dist/helpers/index.cjs +2 -2
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/unplugin.cjs +2 -2
- package/dist/helpers/unplugin.js +1 -1
- package/dist/index.cjs +7 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('../chunk-R6NPMTZP.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkDKSPBMRI_cjs = require('../chunk-DKSPBMRI.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "createESBuildPlugin", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkDKSPBMRI_cjs.createESBuildPlugin; }
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=index.cjs.map
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDKSPBMRI_cjs = require('../chunk-DKSPBMRI.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "createESBuildPlugin", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkDKSPBMRI_cjs.createESBuildPlugin; }
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=unplugin.cjs.map
|
|
12
12
|
//# sourceMappingURL=unplugin.cjs.map
|
package/dist/helpers/unplugin.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('./chunk-R6NPMTZP.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkDKSPBMRI_cjs = require('./chunk-DKSPBMRI.cjs');
|
|
7
7
|
require('./chunk-ZJGSECAJ.cjs');
|
|
8
8
|
require('./chunk-MTB74RUM.cjs');
|
|
9
9
|
var defu = require('defu');
|
|
@@ -34,12 +34,12 @@ function resolveESBuildEntry(context, entryPoints = []) {
|
|
|
34
34
|
if (isString.isString(entry)) {
|
|
35
35
|
ret[replace.replacePath(entry, context.config.sourceRoot || context.config.projectRoot).replace(`.${filePathFns.findFileExtensionSafe(entry)}`, "")] = replace.replacePath(entry, context.config.sourceRoot || context.config.projectRoot);
|
|
36
36
|
} else {
|
|
37
|
-
ret[entry.output ||
|
|
37
|
+
ret[entry.output || chunkDKSPBMRI_cjs.resolveEntryOutput(context, entry.input || entry)] = chunkDKSPBMRI_cjs.resolveEntryInputFile(context, entry.input || entry);
|
|
38
38
|
}
|
|
39
39
|
return ret;
|
|
40
40
|
}, {});
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
chunkDKSPBMRI_cjs.__name(resolveESBuildEntry, "resolveESBuildEntry");
|
|
43
43
|
function extractESBuildConfig(context) {
|
|
44
44
|
return defu__default.default({
|
|
45
45
|
alias: context.fs.builtinIdMap.keys().reduce((ret, id) => {
|
|
@@ -62,10 +62,10 @@ function extractESBuildConfig(context) {
|
|
|
62
62
|
sourcemap: context.config.mode === "development"
|
|
63
63
|
}, DEFAULT_ESBUILD_CONFIG);
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
chunkDKSPBMRI_cjs.__name(extractESBuildConfig, "extractESBuildConfig");
|
|
66
66
|
|
|
67
67
|
// src/index.ts
|
|
68
|
-
var plugin = /* @__PURE__ */
|
|
68
|
+
var plugin = /* @__PURE__ */ chunkDKSPBMRI_cjs.__name((options = {}) => {
|
|
69
69
|
return {
|
|
70
70
|
name: "esbuild",
|
|
71
71
|
config() {
|
|
@@ -84,16 +84,12 @@ var plugin = /* @__PURE__ */ chunk4LCU5I5Q_cjs.__name((options = {}) => {
|
|
|
84
84
|
},
|
|
85
85
|
configResolved() {
|
|
86
86
|
this.config.build = extractESBuildConfig(this);
|
|
87
|
-
this.dependencies.esbuild = {
|
|
88
|
-
type: "devDependency",
|
|
89
|
-
version: "^0.25.0"
|
|
90
|
-
};
|
|
91
87
|
},
|
|
92
88
|
async build() {
|
|
93
89
|
await esbuild.build(defu__default.default({
|
|
94
90
|
entryPoints: resolveESBuildEntry(this, this.entry),
|
|
95
91
|
plugins: [
|
|
96
|
-
|
|
92
|
+
chunkDKSPBMRI_cjs.createESBuildPlugin(this)
|
|
97
93
|
]
|
|
98
94
|
}, extractESBuildConfig(this)));
|
|
99
95
|
}
|
|
@@ -103,7 +99,7 @@ var index_default = plugin;
|
|
|
103
99
|
|
|
104
100
|
Object.defineProperty(exports, "createESBuildPlugin", {
|
|
105
101
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkDKSPBMRI_cjs.createESBuildPlugin; }
|
|
107
103
|
});
|
|
108
104
|
exports.default = index_default;
|
|
109
105
|
exports.plugin = plugin;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../powerlines/src/lib/build/esbuild.ts","../src/index.ts"],"names":["DEFAULT_ESBUILD_CONFIG","target","platform","format","write","minify","sourcemap","bundle","treeShaking","keepNames","splitting","logLevel","resolveESBuildEntry","context","entryPoints","reduce","ret","entry","isString","replacePath","config","sourceRoot","projectRoot","replace","findFileExtensionSafe","output","resolveEntryOutput","input","resolveEntryInputFile","extractESBuildConfig","defu","alias","fs","builtinIdMap","keys","id","path","get","build","variant","override","Array","isArray","Boolean","treeshake","outdir","outputPath","tsconfig","tsconfigFilePath","tsconfigRaw","tsconfigJson","mode","metafile","plugin","__name","options","name","configResolved","dependencies","esbuild","type","version","plugins","createESBuildPlugin"],"mappings":";;;;;;;;;;;;;;;;;;AAqFO,IAAMA,sBAAAA,GAA8D;EACzEC,MAAAA,EAAQ,QAAA;EACRC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,KAAA;EACRC,KAAAA,EAAO,IAAA;EACPC,MAAAA,EAAQ,IAAA;EACRC,SAAAA,EAAW,KAAA;EACXC,MAAAA,EAAQ,IAAA;EACRC,WAAAA,EAAa,IAAA;EACbC,SAAAA,EAAW,IAAA;EACXC,SAAAA,EAAW,IAAA;EACXC,QAAAA,EAAU;AACZ,CAAA;AASO,SAASC,mBAAAA,CACdC,OAAAA,EACAC,WAAAA,GAAwD,EAAA,EAAE;AAE1D,EAAA,OAAOA,WAAAA,CAAYC,MAAAA,CACjB,CAACC,GAAAA,EAAKC,KAAAA,KAAAA;AACJ,IAAA,IAAIC,iBAAAA,CAASD,KAAAA,CAAAA,EAAQ;AACnBD,MAAAA,GAAAA,CACEG,mBAAAA,CACEF,KAAAA,EACAJ,OAAAA,CAAQO,MAAAA,CAAOC,UAAAA,IAAcR,QAAQO,MAAAA,CAAOE,WAAW,CAAA,CACvDC,OAAAA,CAAQ,CAAA,CAAA,EAAIC,iCAAAA,CAAsBP,KAAAA,CAAAA,CAAAA,CAAAA,EAAU,EAAA,CAAA,CAAA,GAC5CE,mBAAAA,CACFF,KAAAA,EACAJ,OAAAA,CAAQO,MAAAA,CAAOC,UAAAA,IAAcR,OAAAA,CAAQO,MAAAA,CAAOE,WAAW,CAAA;IAE3D,CAAA,MAAO;AACLN,MAAAA,GAAAA,C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AAA;QACNC,OAAAA,EAAS;AACX,OAAA;AACF,IAAA,CAAA;AACA,IAAA,MAAMvB,KAAAA,GAAAA;AACJ,MAAA,MAAMA,cACJR,qBAAAA,CACE;QACEhB,WAAAA,EAAaF,mBAAAA,CAAoB,IAAA,EAAM,IAAA,CAAKK,KAAK,CAAA;QACjD6C,OAAAA,EAAS;AAACC,UAAAA,qCAAAA,CAAoB,IAAI;;OACpC,EACAlC,oBAAAA,CAAqB,IAAI,CAAA,CAAA,CAAA;AAG/B,IAAA;AACF,GAAA;AACF,CAAA,EAvCsB,QAAA;AAyCtB,IAAA,aAAA,GAAewB","file":"index.cjs","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 { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { Format, LogLevel, Platform } from \"esbuild\";\nimport {\n ESBuildBuildConfig,\n ESBuildResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport type { ResolvedEntryTypeDefinition } from \"../../types/resolved\";\nimport { resolveEntryInputFile, resolveEntryOutput } from \"../entry\";\n\n// const resolverPlugin = (\n// context: Context,\n// options: Pick<\n// BuildResolvedConfig,\n// \"external\" | \"noExternal\" | \"skipNodeModulesBundle\"\n// > = {}\n// ): Plugin => {\n// return {\n// name: \"powerlines:resolver\",\n// setup(build) {\n// const skipNodeModulesBundle =\n// options.skipNodeModulesBundle ??\n// context.config.build.skipNodeModulesBundle;\n// const external = options.external ?? context.config.build.external ?? [];\n// const noExternal =\n// options.noExternal ?? context.config.build.noExternal ?? [];\n// const resolvePatterns = skipNodeModulesBundle\n// ? tsconfigPathsToRegExp(context.tsconfig.options.paths ?? [])\n// : [];\n\n// const handle = async (args: OnResolveArgs) => {\n// const result = await handleResolveId(\n// context,\n// {\n// id: args.path,\n// importer: args.importer,\n// options: {\n// isEntry: false\n// }\n// },\n// {\n// skipNodeModulesBundle,\n// external,\n// noExternal,\n// resolvePatterns\n// }\n// );\n// if (!result) {\n// return;\n// }\n\n// return {\n// path: result?.id,\n// external: result?.external\n// };\n// };\n\n// build.onResolve({ filter: /.*/ }, handle);\n// build.onResolve({ filter: /^storm:/ }, handle);\n// }\n// };\n// };\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<ESBuildResolvedBuildConfig> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveESBuildEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): ESBuildResolvedBuildConfig[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[\n replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n ).replace(`.${findFileExtensionSafe(entry)}`, \"\")\n ] = replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n );\n } else {\n ret[entry.output || resolveEntryOutput(context, entry.input || entry)] =\n resolveEntryInputFile(context, entry.input || entry);\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function extractESBuildConfig(\n context: Context\n): ESBuildResolvedBuildConfig {\n return defu(\n {\n alias: context.fs.builtinIdMap.keys().reduce(\n (ret, id) => {\n const path = context.fs.builtinIdMap.get(id);\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"esbuild\" ? context.config.override : {},\n {\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.build.platform,\n treeShaking:\n Boolean((context.config.build as TsupBuildConfig)?.treeshake) ||\n (context.config.build as ESBuildBuildConfig)?.treeShaking,\n outdir: context.config.output.outputPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n context.config.build.variant === \"esbuild\" ? context.config.build : {},\n {\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { build } from \"esbuild\";\nimport {\n DEFAULT_ESBUILD_CONFIG,\n extractESBuildConfig,\n resolveESBuildEntry\n} from \"powerlines/lib/build/esbuild\";\nimport { ESBuildUserConfig } from \"powerlines/types/config\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { createESBuildPlugin } from \"./helpers/unplugin\";\nimport { ESBuildPluginContext, ESBuildPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n TContext extends ESBuildPluginContext = ESBuildPluginContext\n>(\n options: ESBuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"esbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n build: {\n ...DEFAULT_ESBUILD_CONFIG,\n ...options,\n variant: \"esbuild\"\n }\n } as Partial<ESBuildUserConfig>;\n },\n configResolved() {\n this.config.build = extractESBuildConfig(this);\n\n this.dependencies.esbuild = {\n type: \"devDependency\",\n version: \"^0.25.0\"\n };\n },\n async build() {\n await build(\n defu(\n {\n entryPoints: resolveESBuildEntry(this, this.entry),\n plugins: [createESBuildPlugin(this)]\n },\n extractESBuildConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../powerlines/src/lib/build/esbuild.ts","../src/index.ts"],"names":["DEFAULT_ESBUILD_CONFIG","target","platform","format","write","minify","sourcemap","bundle","treeShaking","keepNames","splitting","logLevel","resolveESBuildEntry","context","entryPoints","reduce","ret","entry","isString","replacePath","config","sourceRoot","projectRoot","replace","findFileExtensionSafe","output","resolveEntryOutput","input","resolveEntryInputFile","extractESBuildConfig","defu","alias","fs","builtinIdMap","keys","id","path","get","build","variant","override","Array","isArray","Boolean","treeshake","outdir","outputPath","tsconfig","tsconfigFilePath","tsconfigRaw","tsconfigJson","mode","metafile","plugin","__name","options","name","configResolved","plugins","createESBuildPlugin"],"mappings":";;;;;;;;;;;;;;;;;;AAqFO,IAAMA,sBAAAA,GAA8D;EACzEC,MAAAA,EAAQ,QAAA;EACRC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,KAAA;EACRC,KAAAA,EAAO,IAAA;EACPC,MAAAA,EAAQ,IAAA;EACRC,SAAAA,EAAW,KAAA;EACXC,MAAAA,EAAQ,IAAA;EACRC,WAAAA,EAAa,IAAA;EACbC,SAAAA,EAAW,IAAA;EACXC,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AWO,OAAAA,CAAQO,OAAO+B,IAAAA,KAAS;AACrC,GAAA,EACAnD,sBAAAA,CAAAA;AAEJ;AAtCgB6B,wBAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA;;;ACvGT,IAAMwB,MAAAA,mBAASC,wBAAA,CAAA,CAGpBC,OAAAA,GAAgC,EAAC,KAAC;AAElC,EAAA,OAAO;IACLC,IAAAA,EAAM,SAAA;IACNpC,MAAAA,GAAAA;AACE,MAAA,OAAO;QACLK,MAAAA,EAAQ;UACNtB,MAAAA,EAAQ;AAAC,YAAA;;AACX,SAAA;QACAmC,KAAAA,EAAO;UACL,GAAGtC,sBAAAA;UACH,GAAGuD,OAAAA;UACHhB,OAAAA,EAAS;AACX;AACF,OAAA;AACF,IAAA,CAAA;IACAkB,cAAAA,GAAAA;AACE,MAAA,IAAA,CAAKrC,MAAAA,CAAOkB,KAAAA,GAAQT,oBAAAA,CAAqB,IAAI,CAAA;AAC/C,IAAA,CAAA;AACA,IAAA,MAAMS,KAAAA,GAAAA;AACJ,MAAA,MAAMA,cACJR,qBAAAA,CACE;QACEhB,WAAAA,EAAaF,mBAAAA,CAAoB,IAAA,EAAM,IAAA,CAAKK,KAAK,CAAA;QACjDyC,OAAAA,EAAS;AAACC,UAAAA,qCAAAA,CAAoB,IAAI;;OACpC,EACA9B,oBAAAA,CAAqB,IAAI,CAAA,CAAA,CAAA;AAG/B,IAAA;AACF,GAAA;AACF,CAAA,EAlCsB,QAAA;AAoCtB,IAAA,aAAA,GAAewB","file":"index.cjs","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 { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { Format, LogLevel, Platform } from \"esbuild\";\nimport {\n ESBuildBuildConfig,\n ESBuildResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport type { ResolvedEntryTypeDefinition } from \"../../types/resolved\";\nimport { resolveEntryInputFile, resolveEntryOutput } from \"../entry\";\n\n// const resolverPlugin = (\n// context: Context,\n// options: Pick<\n// BuildResolvedConfig,\n// \"external\" | \"noExternal\" | \"skipNodeModulesBundle\"\n// > = {}\n// ): Plugin => {\n// return {\n// name: \"powerlines:resolver\",\n// setup(build) {\n// const skipNodeModulesBundle =\n// options.skipNodeModulesBundle ??\n// context.config.build.skipNodeModulesBundle;\n// const external = options.external ?? context.config.build.external ?? [];\n// const noExternal =\n// options.noExternal ?? context.config.build.noExternal ?? [];\n// const resolvePatterns = skipNodeModulesBundle\n// ? tsconfigPathsToRegExp(context.tsconfig.options.paths ?? [])\n// : [];\n\n// const handle = async (args: OnResolveArgs) => {\n// const result = await handleResolveId(\n// context,\n// {\n// id: args.path,\n// importer: args.importer,\n// options: {\n// isEntry: false\n// }\n// },\n// {\n// skipNodeModulesBundle,\n// external,\n// noExternal,\n// resolvePatterns\n// }\n// );\n// if (!result) {\n// return;\n// }\n\n// return {\n// path: result?.id,\n// external: result?.external\n// };\n// };\n\n// build.onResolve({ filter: /.*/ }, handle);\n// build.onResolve({ filter: /^storm:/ }, handle);\n// }\n// };\n// };\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<ESBuildResolvedBuildConfig> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveESBuildEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): ESBuildResolvedBuildConfig[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[\n replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n ).replace(`.${findFileExtensionSafe(entry)}`, \"\")\n ] = replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n );\n } else {\n ret[entry.output || resolveEntryOutput(context, entry.input || entry)] =\n resolveEntryInputFile(context, entry.input || entry);\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function extractESBuildConfig(\n context: Context\n): ESBuildResolvedBuildConfig {\n return defu(\n {\n alias: context.fs.builtinIdMap.keys().reduce(\n (ret, id) => {\n const path = context.fs.builtinIdMap.get(id);\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"esbuild\" ? context.config.override : {},\n {\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.build.platform,\n treeShaking:\n Boolean((context.config.build as TsupBuildConfig)?.treeshake) ||\n (context.config.build as ESBuildBuildConfig)?.treeShaking,\n outdir: context.config.output.outputPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n context.config.build.variant === \"esbuild\" ? context.config.build : {},\n {\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { build } from \"esbuild\";\nimport {\n DEFAULT_ESBUILD_CONFIG,\n extractESBuildConfig,\n resolveESBuildEntry\n} from \"powerlines/lib/build/esbuild\";\nimport { ESBuildUserConfig } from \"powerlines/types/config\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { createESBuildPlugin } from \"./helpers/unplugin\";\nimport { ESBuildPluginContext, ESBuildPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n TContext extends ESBuildPluginContext = ESBuildPluginContext\n>(\n options: ESBuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"esbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n build: {\n ...DEFAULT_ESBUILD_CONFIG,\n ...options,\n variant: \"esbuild\"\n }\n } as Partial<ESBuildUserConfig>;\n },\n configResolved() {\n this.config.build = extractESBuildConfig(this);\n },\n async build() {\n await build(\n defu(\n {\n entryPoints: resolveESBuildEntry(this, this.entry),\n plugins: [createESBuildPlugin(this)]\n },\n extractESBuildConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './chunk-EWDQEFTW.js';
|
|
2
|
-
import { __name, resolveEntryInputFile, resolveEntryOutput, createESBuildPlugin } from './chunk-
|
|
3
|
-
export { createESBuildPlugin } from './chunk-
|
|
2
|
+
import { __name, resolveEntryInputFile, resolveEntryOutput, createESBuildPlugin } from './chunk-FGTVQNHX.js';
|
|
3
|
+
export { createESBuildPlugin } from './chunk-FGTVQNHX.js';
|
|
4
4
|
import './chunk-54IL5JZD.js';
|
|
5
5
|
import './chunk-DXDH2OBY.js';
|
|
6
6
|
import defu from 'defu';
|
|
@@ -77,10 +77,6 @@ var plugin = /* @__PURE__ */ __name((options = {}) => {
|
|
|
77
77
|
},
|
|
78
78
|
configResolved() {
|
|
79
79
|
this.config.build = extractESBuildConfig(this);
|
|
80
|
-
this.dependencies.esbuild = {
|
|
81
|
-
type: "devDependency",
|
|
82
|
-
version: "^0.25.0"
|
|
83
|
-
};
|
|
84
80
|
},
|
|
85
81
|
async build() {
|
|
86
82
|
await build(defu({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../powerlines/src/lib/build/esbuild.ts","../src/index.ts"],"names":["DEFAULT_ESBUILD_CONFIG","target","platform","format","write","minify","sourcemap","bundle","treeShaking","keepNames","splitting","logLevel","resolveESBuildEntry","context","entryPoints","reduce","ret","entry","isString","replacePath","config","sourceRoot","projectRoot","replace","findFileExtensionSafe","output","resolveEntryOutput","input","resolveEntryInputFile","extractESBuildConfig","defu","alias","fs","builtinIdMap","keys","id","path","get","build","variant","override","Array","isArray","Boolean","treeshake","outdir","outputPath","tsconfig","tsconfigFilePath","tsconfigRaw","tsconfigJson","mode","metafile","plugin","options","name","configResolved","dependencies","esbuild","type","version","plugins","createESBuildPlugin"],"mappings":";;;;;;;;;;;AAqFO,IAAMA,sBAAAA,GAA8D;EACzEC,MAAAA,EAAQ,QAAA;EACRC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,KAAA;EACRC,KAAAA,EAAO,IAAA;EACPC,MAAAA,EAAQ,IAAA;EACRC,SAAAA,EAAW,KAAA;EACXC,MAAAA,EAAQ,IAAA;EACRC,WAAAA,EAAa,IAAA;EACbC,SAAAA,EAAW,IAAA;EACXC,SAAAA,EAAW,IAAA;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B,IAAAA,KAAS;AACrC,GAAA,EACAnD,sBAAAA,CAAAA;AAEJ;AAtCgB6B,MAAAA,CAAAA,oBAAAA,EAAAA,sBAAAA,CAAAA;;;ACvGT,IAAMwB,MAAAA,mBAAS,MAAA,CAAA,CAGpBC,OAAAA,GAAgC,EAAC,KAAC;AAElC,EAAA,OAAO;IACLC,IAAAA,EAAM,SAAA;IACNnC,MAAAA,GAAAA;AACE,MAAA,OAAO;QACLK,MAAAA,EAAQ;UACNtB,MAAAA,EAAQ;AAAC,YAAA;;AACX,SAAA;QACAmC,KAAAA,EAAO;UACL,GAAGtC,sBAAAA;UACH,GAAGsD,OAAAA;UACHf,OAAAA,EAAS;AACX;AACF,OAAA;AACF,IAAA,CAAA;IACAiB,cAAAA,GAAAA;AACE,MAAA,IAAA,CAAKpC,MAAAA,CAAOkB,KAAAA,GAAQT,oBAAAA,CAAqB,IAAI,CAAA;AAE7C,MAAA,IAAA,CAAK4B,aAAaC,OAAAA,GAAU;QAC1BC,IAAAA,EAAM,eAAA;QACNC,OAAAA,EAAS;AACX,OAAA;AACF,IAAA,CAAA;AACA,IAAA,MAAMtB,KAAAA,GAAAA;AACJ,MAAA,MAAMA,MACJR,IAAAA,CACE;QACEhB,WAAAA,EAAaF,mBAAAA,CAAoB,IAAA,EAAM,IAAA,CAAKK,KAAK,CAAA;QACjD4C,OAAAA,EAAS;AAACC,UAAAA,mBAAAA,CAAoB,IAAI;;OACpC,EACAjC,oBAAAA,CAAqB,IAAI,CAAA,CAAA,CAAA;AAG/B,IAAA;AACF,GAAA;AACF,CAAA,EAvCsB,QAAA;AAyCtB,IAAA,aAAA,GAAewB","file":"index.js","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 { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { Format, LogLevel, Platform } from \"esbuild\";\nimport {\n ESBuildBuildConfig,\n ESBuildResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport type { ResolvedEntryTypeDefinition } from \"../../types/resolved\";\nimport { resolveEntryInputFile, resolveEntryOutput } from \"../entry\";\n\n// const resolverPlugin = (\n// context: Context,\n// options: Pick<\n// BuildResolvedConfig,\n// \"external\" | \"noExternal\" | \"skipNodeModulesBundle\"\n// > = {}\n// ): Plugin => {\n// return {\n// name: \"powerlines:resolver\",\n// setup(build) {\n// const skipNodeModulesBundle =\n// options.skipNodeModulesBundle ??\n// context.config.build.skipNodeModulesBundle;\n// const external = options.external ?? context.config.build.external ?? [];\n// const noExternal =\n// options.noExternal ?? context.config.build.noExternal ?? [];\n// const resolvePatterns = skipNodeModulesBundle\n// ? tsconfigPathsToRegExp(context.tsconfig.options.paths ?? [])\n// : [];\n\n// const handle = async (args: OnResolveArgs) => {\n// const result = await handleResolveId(\n// context,\n// {\n// id: args.path,\n// importer: args.importer,\n// options: {\n// isEntry: false\n// }\n// },\n// {\n// skipNodeModulesBundle,\n// external,\n// noExternal,\n// resolvePatterns\n// }\n// );\n// if (!result) {\n// return;\n// }\n\n// return {\n// path: result?.id,\n// external: result?.external\n// };\n// };\n\n// build.onResolve({ filter: /.*/ }, handle);\n// build.onResolve({ filter: /^storm:/ }, handle);\n// }\n// };\n// };\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<ESBuildResolvedBuildConfig> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveESBuildEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): ESBuildResolvedBuildConfig[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[\n replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n ).replace(`.${findFileExtensionSafe(entry)}`, \"\")\n ] = replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n );\n } else {\n ret[entry.output || resolveEntryOutput(context, entry.input || entry)] =\n resolveEntryInputFile(context, entry.input || entry);\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function extractESBuildConfig(\n context: Context\n): ESBuildResolvedBuildConfig {\n return defu(\n {\n alias: context.fs.builtinIdMap.keys().reduce(\n (ret, id) => {\n const path = context.fs.builtinIdMap.get(id);\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"esbuild\" ? context.config.override : {},\n {\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.build.platform,\n treeShaking:\n Boolean((context.config.build as TsupBuildConfig)?.treeshake) ||\n (context.config.build as ESBuildBuildConfig)?.treeShaking,\n outdir: context.config.output.outputPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n context.config.build.variant === \"esbuild\" ? context.config.build : {},\n {\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { build } from \"esbuild\";\nimport {\n DEFAULT_ESBUILD_CONFIG,\n extractESBuildConfig,\n resolveESBuildEntry\n} from \"powerlines/lib/build/esbuild\";\nimport { ESBuildUserConfig } from \"powerlines/types/config\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { createESBuildPlugin } from \"./helpers/unplugin\";\nimport { ESBuildPluginContext, ESBuildPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n TContext extends ESBuildPluginContext = ESBuildPluginContext\n>(\n options: ESBuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"esbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n build: {\n ...DEFAULT_ESBUILD_CONFIG,\n ...options,\n variant: \"esbuild\"\n }\n } as Partial<ESBuildUserConfig>;\n },\n configResolved() {\n this.config.build = extractESBuildConfig(this);\n\n this.dependencies.esbuild = {\n type: \"devDependency\",\n version: \"^0.25.0\"\n };\n },\n async build() {\n await build(\n defu(\n {\n entryPoints: resolveESBuildEntry(this, this.entry),\n plugins: [createESBuildPlugin(this)]\n },\n extractESBuildConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../powerlines/src/lib/build/esbuild.ts","../src/index.ts"],"names":["DEFAULT_ESBUILD_CONFIG","target","platform","format","write","minify","sourcemap","bundle","treeShaking","keepNames","splitting","logLevel","resolveESBuildEntry","context","entryPoints","reduce","ret","entry","isString","replacePath","config","sourceRoot","projectRoot","replace","findFileExtensionSafe","output","resolveEntryOutput","input","resolveEntryInputFile","extractESBuildConfig","defu","alias","fs","builtinIdMap","keys","id","path","get","build","variant","override","Array","isArray","Boolean","treeshake","outdir","outputPath","tsconfig","tsconfigFilePath","tsconfigRaw","tsconfigJson","mode","metafile","plugin","options","name","configResolved","plugins","createESBuildPlugin"],"mappings":";;;;;;;;;;;AAqFO,IAAMA,sBAAAA,GAA8D;EACzEC,MAAAA,EAAQ,QAAA;EACRC,QAAAA,EAAU,SAAA;EACVC,MAAAA,EAAQ,KAAA;EACRC,KAAAA,EAAO,IAAA;EACPC,MAAAA,EAAQ,IAAA;EACRC,SAAAA,EAAW,KAAA;EACXC,MAAAA,EAAQ,IAAA;EACRC,WAAAA,EAAa,IAAA;EACbC,SAAAA,EAAW,IAAA;EACXC,SAAAA,EAAW,IAAA;EACXC,QAAAA,EAAU;AACZ,CAAA;AASO,SAASC,mBAAAA,CACdC,OAAAA,EACAC,WAAAA,GAAwD,EAAA,EAAE;AAE1D,EAAA,OAAOA,WAAAA,CAAYC,MAAAA,CACjB,CAACC,GAAAA,EAAKC,KAAAA,KAAAA;AACJ,IAAA,IAAIC,QAAAA,CAASD,KAAAA,CAAAA,EAAQ;AACnBD,MAAAA,GAAAA,CACEG,WAAAA,CACEF,KAAAA,EACAJ,OAAAA,CAAQO,MAAAA,CAAOC,UAAAA,IAAcR,QAAQO,MAAAA,CAAOE,WAAW,CAAA,CACvDC,OAAAA,CAAQ,CAAA,CAAA,EAAIC,qBAAAA,CAAsBP,KAAAA,CAAAA,CAAAA,CAAAA,EAAU,EAAA,CAAA,CAAA,GAC5CE,WAAAA,CACFF,KAAAA,EACAJ,OAAAA,CAAQO,MAAAA,CAAOC,UAAAA,IAAcR,OAAAA,CAAQO,MAAAA,CAAOE,WAAW,CAAA;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,KAAAA,GAAAA;AACJ,MAAA,MAAMA,MACJR,IAAAA,CACE;QACEhB,WAAAA,EAAaF,mBAAAA,CAAoB,IAAA,EAAM,IAAA,CAAKK,KAAK,CAAA;QACjDwC,OAAAA,EAAS;AAACC,UAAAA,mBAAAA,CAAoB,IAAI;;OACpC,EACA7B,oBAAAA,CAAqB,IAAI,CAAA,CAAA,CAAA;AAG/B,IAAA;AACF,GAAA;AACF,CAAA,EAlCsB,QAAA;AAoCtB,IAAA,aAAA,GAAewB","file":"index.js","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 { findFileExtensionSafe } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { Format, LogLevel, Platform } from \"esbuild\";\nimport {\n ESBuildBuildConfig,\n ESBuildResolvedBuildConfig,\n TsupBuildConfig\n} from \"../../types/build\";\nimport { Context } from \"../../types/context\";\nimport type { ResolvedEntryTypeDefinition } from \"../../types/resolved\";\nimport { resolveEntryInputFile, resolveEntryOutput } from \"../entry\";\n\n// const resolverPlugin = (\n// context: Context,\n// options: Pick<\n// BuildResolvedConfig,\n// \"external\" | \"noExternal\" | \"skipNodeModulesBundle\"\n// > = {}\n// ): Plugin => {\n// return {\n// name: \"powerlines:resolver\",\n// setup(build) {\n// const skipNodeModulesBundle =\n// options.skipNodeModulesBundle ??\n// context.config.build.skipNodeModulesBundle;\n// const external = options.external ?? context.config.build.external ?? [];\n// const noExternal =\n// options.noExternal ?? context.config.build.noExternal ?? [];\n// const resolvePatterns = skipNodeModulesBundle\n// ? tsconfigPathsToRegExp(context.tsconfig.options.paths ?? [])\n// : [];\n\n// const handle = async (args: OnResolveArgs) => {\n// const result = await handleResolveId(\n// context,\n// {\n// id: args.path,\n// importer: args.importer,\n// options: {\n// isEntry: false\n// }\n// },\n// {\n// skipNodeModulesBundle,\n// external,\n// noExternal,\n// resolvePatterns\n// }\n// );\n// if (!result) {\n// return;\n// }\n\n// return {\n// path: result?.id,\n// external: result?.external\n// };\n// };\n\n// build.onResolve({ filter: /.*/ }, handle);\n// build.onResolve({ filter: /^storm:/ }, handle);\n// }\n// };\n// };\n\nexport const DEFAULT_ESBUILD_CONFIG: Partial<ESBuildResolvedBuildConfig> = {\n target: \"esnext\",\n platform: \"neutral\" as Platform,\n format: \"esm\" as Format,\n write: true,\n minify: true,\n sourcemap: false,\n bundle: true,\n treeShaking: true,\n keepNames: true,\n splitting: true,\n logLevel: \"silent\" as LogLevel\n};\n\n/**\n * Resolves the entry options for esbuild.\n *\n * @param context - The build context.\n * @param entryPoints - The entry points to resolve.\n * @returns The resolved entry options.\n */\nexport function resolveESBuildEntry(\n context: Context,\n entryPoints: ResolvedEntryTypeDefinition[] | string[] = []\n): ESBuildResolvedBuildConfig[\"entryPoints\"] {\n return entryPoints.reduce(\n (ret, entry) => {\n if (isString(entry)) {\n ret[\n replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n ).replace(`.${findFileExtensionSafe(entry)}`, \"\")\n ] = replacePath(\n entry,\n context.config.sourceRoot || context.config.projectRoot\n );\n } else {\n ret[entry.output || resolveEntryOutput(context, entry.input || entry)] =\n resolveEntryInputFile(context, entry.input || entry);\n }\n\n return ret;\n },\n {} as Record<string, string>\n );\n}\n\n/**\n * Resolves the esbuild options.\n *\n * @param context - The build context.\n * @returns The resolved esbuild options.\n */\nexport function extractESBuildConfig(\n context: Context\n): ESBuildResolvedBuildConfig {\n return defu(\n {\n alias: context.fs.builtinIdMap.keys().reduce(\n (ret, id) => {\n const path = context.fs.builtinIdMap.get(id);\n if (path) {\n ret[id] = path;\n }\n\n return ret;\n },\n {} as Record<string, string>\n )\n },\n context.config.build.variant === \"esbuild\" ? context.config.override : {},\n {\n format: (Array.isArray(context.config.output.format)\n ? context.config.output.format[0]\n : context.config.output.format) as Format,\n platform: context.config.build.platform,\n treeShaking:\n Boolean((context.config.build as TsupBuildConfig)?.treeshake) ||\n (context.config.build as ESBuildBuildConfig)?.treeShaking,\n outdir: context.config.output.outputPath,\n tsconfig: context.tsconfig.tsconfigFilePath,\n tsconfigRaw: context.tsconfig.tsconfigJson\n },\n context.config.build.variant === \"esbuild\" ? context.config.build : {},\n {\n minify: context.config.mode !== \"development\",\n metafile: context.config.mode === \"development\",\n sourcemap: context.config.mode === \"development\"\n },\n DEFAULT_ESBUILD_CONFIG\n );\n}\n","/* -------------------------------------------------------------------\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 defu from \"defu\";\nimport { build } from \"esbuild\";\nimport {\n DEFAULT_ESBUILD_CONFIG,\n extractESBuildConfig,\n resolveESBuildEntry\n} from \"powerlines/lib/build/esbuild\";\nimport { ESBuildUserConfig } from \"powerlines/types/config\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { createESBuildPlugin } from \"./helpers/unplugin\";\nimport { ESBuildPluginContext, ESBuildPluginOptions } from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <\n TContext extends ESBuildPluginContext = ESBuildPluginContext\n>(\n options: ESBuildPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"esbuild\",\n config() {\n return {\n output: {\n format: [\"esm\"]\n },\n build: {\n ...DEFAULT_ESBUILD_CONFIG,\n ...options,\n variant: \"esbuild\"\n }\n } as Partial<ESBuildUserConfig>;\n },\n configResolved() {\n this.config.build = extractESBuildConfig(this);\n },\n async build() {\n await build(\n defu(\n {\n entryPoints: resolveESBuildEntry(this, this.entry),\n plugins: [createESBuildPlugin(this)]\n },\n extractESBuildConfig(this)\n )\n );\n }\n };\n};\n\nexport default plugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-esbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -134,10 +134,10 @@
|
|
|
134
134
|
"defu": "^6.1.4",
|
|
135
135
|
"esbuild": "^0.25.11",
|
|
136
136
|
"jiti": "^2.6.1",
|
|
137
|
-
"powerlines": "^0.
|
|
137
|
+
"powerlines": "^0.4.0",
|
|
138
138
|
"unplugin": "^2.3.10"
|
|
139
139
|
},
|
|
140
|
-
"devDependencies": { "@powerlines/nx": "^0.
|
|
140
|
+
"devDependencies": { "@powerlines/nx": "^0.4.0", "@types/node": "^22.18.11" },
|
|
141
141
|
"publishConfig": { "access": "public" },
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "f4d0c8a8f0036ac8de46ac96afd9336a390a7268"
|
|
143
143
|
}
|