@storm-software/esbuild 0.1.0 → 0.3.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/build.cjs +11 -10
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.cts +5 -3
- package/dist/build.d.ts +5 -3
- package/dist/build.js +10 -9
- package/dist/build.js.map +1 -0
- package/dist/{chunk-A6CGWMV7.cjs → chunk-263L44RM.cjs} +12 -26
- package/dist/chunk-263L44RM.cjs.map +1 -0
- package/dist/chunk-437F3SFI.js +24 -0
- package/dist/chunk-437F3SFI.js.map +1 -0
- package/dist/{chunk-WLHWKRZB.cjs → chunk-BF5W6GVP.cjs} +5 -4
- package/dist/chunk-BF5W6GVP.cjs.map +1 -0
- package/dist/{chunk-YGD5JBOH.js → chunk-CMEDJ4L4.js} +98 -83
- package/dist/chunk-CMEDJ4L4.js.map +1 -0
- package/dist/{chunk-PCGRI6Z6.js → chunk-CMWXE5MF.js} +5 -6
- package/dist/chunk-CMWXE5MF.js.map +1 -0
- package/dist/{chunk-NVGEXPTG.cjs → chunk-D5PRB2E2.cjs} +1 -0
- package/dist/chunk-D5PRB2E2.cjs.map +1 -0
- package/dist/{chunk-3C3PXJUM.cjs → chunk-DFGHPRBD.cjs} +4 -3
- package/dist/chunk-DFGHPRBD.cjs.map +1 -0
- package/dist/{chunk-ELGZJRET.js → chunk-DRRPNILS.js} +1 -0
- package/dist/chunk-DRRPNILS.js.map +1 -0
- package/dist/chunk-J34FQYKV.cjs +24 -0
- package/dist/chunk-J34FQYKV.cjs.map +1 -0
- package/dist/{chunk-5JHKW6MG.js → chunk-KJ7ZHAFS.js} +6 -20
- package/dist/chunk-KJ7ZHAFS.js.map +1 -0
- package/dist/{chunk-MTKAAECG.cjs → chunk-KVBDKVBU.cjs} +7 -8
- package/dist/chunk-KVBDKVBU.cjs.map +1 -0
- package/dist/chunk-MUYXFAKB.cjs +1 -0
- package/dist/chunk-MUYXFAKB.cjs.map +1 -0
- package/dist/{chunk-DCWECOOS.cjs → chunk-MVLEDP7K.cjs} +5 -6
- package/dist/chunk-MVLEDP7K.cjs.map +1 -0
- package/dist/{chunk-5S2XTAF2.cjs → chunk-PBHOTQGA.cjs} +116 -101
- package/dist/chunk-PBHOTQGA.cjs.map +1 -0
- package/dist/chunk-QNDLJ2W7.js +1 -0
- package/dist/chunk-QNDLJ2W7.js.map +1 -0
- package/dist/{chunk-4TW4ZA3I.js → chunk-TTHABTDU.js} +2 -1
- package/dist/chunk-TTHABTDU.js.map +1 -0
- package/dist/{chunk-3GQAWCBQ.js → chunk-WCQVDF3K.js} +1 -0
- package/dist/chunk-WCQVDF3K.js.map +1 -0
- package/dist/{chunk-BGYQAVKQ.cjs → chunk-WGEGR3DF.cjs} +1 -0
- package/dist/chunk-WGEGR3DF.cjs.map +1 -0
- package/dist/{chunk-RKSGVSXZ.js → chunk-X5TLV7MF.js} +4 -5
- package/dist/chunk-X5TLV7MF.js.map +1 -0
- package/dist/{chunk-LVDPGHWK.js → chunk-YQBU3FSL.js} +2 -1
- package/dist/chunk-YQBU3FSL.js.map +1 -0
- package/dist/config.cjs +4 -3
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +3 -2
- package/dist/config.js.map +1 -0
- package/dist/index.cjs +12 -17
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.js +12 -17
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +2 -1
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +1169 -1
- package/dist/types.d.ts +1169 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -0
- package/package.json +13 -6
- package/dist/chunk-GGNOJ77I.js +0 -0
- package/dist/chunk-RJQ3LCGJ.cjs +0 -14
- package/dist/chunk-SFZRYJZ2.cjs +0 -1
- package/dist/chunk-YIAZ64WG.js +0 -14
package/dist/build.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
10
|
-
require('./chunk-
|
|
11
|
-
require('./chunk-
|
|
3
|
+
var _chunkPBHOTQGAcjs = require('./chunk-PBHOTQGA.cjs');
|
|
4
|
+
require('./chunk-BF5W6GVP.cjs');
|
|
5
|
+
require('./chunk-263L44RM.cjs');
|
|
6
|
+
require('./chunk-D5PRB2E2.cjs');
|
|
7
|
+
require('./chunk-KVBDKVBU.cjs');
|
|
8
|
+
require('./chunk-J34FQYKV.cjs');
|
|
9
|
+
require('./chunk-DFGHPRBD.cjs');
|
|
10
|
+
require('./chunk-MVLEDP7K.cjs');
|
|
11
|
+
require('./chunk-WGEGR3DF.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.build =
|
|
14
|
+
exports.build = _chunkPBHOTQGAcjs.build;
|
|
15
|
+
//# sourceMappingURL=build.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/build.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wCAAC","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/build.cjs"}
|
package/dist/build.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ESBuildOptions, ESBuildResolvedOptions } from './types.cjs';
|
|
1
|
+
import { ESBuildOptions } from './types.cjs';
|
|
3
2
|
import '@nx/devkit';
|
|
3
|
+
import '@storm-software/build-tools';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import 'esbuild';
|
|
4
6
|
import 'nx/src/utils/find-workspace-root';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -9,6 +11,6 @@ import 'nx/src/utils/find-workspace-root';
|
|
|
9
11
|
* @param options - the build options
|
|
10
12
|
* @returns the build result
|
|
11
13
|
*/
|
|
12
|
-
declare function build(options: ESBuildOptions[]): Promise<
|
|
14
|
+
declare function build(options: ESBuildOptions[]): Promise<void>;
|
|
13
15
|
|
|
14
16
|
export { build };
|
package/dist/build.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ESBuildOptions, ESBuildResolvedOptions } from './types.js';
|
|
1
|
+
import { ESBuildOptions } from './types.js';
|
|
3
2
|
import '@nx/devkit';
|
|
3
|
+
import '@storm-software/build-tools';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import 'esbuild';
|
|
4
6
|
import 'nx/src/utils/find-workspace-root';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -9,6 +11,6 @@ import 'nx/src/utils/find-workspace-root';
|
|
|
9
11
|
* @param options - the build options
|
|
10
12
|
* @returns the build result
|
|
11
13
|
*/
|
|
12
|
-
declare function build(options: ESBuildOptions[]): Promise<
|
|
14
|
+
declare function build(options: ESBuildOptions[]): Promise<void>;
|
|
13
15
|
|
|
14
16
|
export { build };
|
package/dist/build.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-CMEDJ4L4.js";
|
|
4
|
+
import "./chunk-TTHABTDU.js";
|
|
5
|
+
import "./chunk-KJ7ZHAFS.js";
|
|
6
|
+
import "./chunk-DRRPNILS.js";
|
|
7
|
+
import "./chunk-CMWXE5MF.js";
|
|
8
|
+
import "./chunk-437F3SFI.js";
|
|
9
|
+
import "./chunk-YQBU3FSL.js";
|
|
10
|
+
import "./chunk-X5TLV7MF.js";
|
|
11
|
+
import "./chunk-WCQVDF3K.js";
|
|
12
12
|
export {
|
|
13
13
|
build
|
|
14
14
|
};
|
|
15
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var _chunkRJQ3LCGJcjs = require('./chunk-RJQ3LCGJ.cjs');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
|
|
4
|
+
var _chunkWGEGR3DFcjs = require('./chunk-WGEGR3DF.cjs');
|
|
8
5
|
|
|
9
6
|
// src/plugins/tsc.ts
|
|
10
7
|
var _node = require('@humanfs/node');
|
|
11
8
|
var _apiextractor = require('@microsoft/api-extractor');
|
|
9
|
+
var _configtools = require('@storm-software/config-tools');
|
|
12
10
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
13
|
-
|
|
14
|
-
// src/utilities/run.ts
|
|
15
|
-
var _execa = require('execa');
|
|
16
|
-
function run(command) {
|
|
17
|
-
return _execa.execaCommand.call(void 0, command, {
|
|
18
|
-
preferLocal: true,
|
|
19
|
-
shell: true,
|
|
20
|
-
stdio: "inherit"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_chunkBGYQAVKQcjs.__name.call(void 0, run, "run");
|
|
24
|
-
|
|
25
|
-
// src/plugins/tsc.ts
|
|
26
11
|
function bundleTypeDefinitions(filename, outfile, externals) {
|
|
27
|
-
const { dependencies, peerDependencies, devDependencies } =
|
|
12
|
+
const { dependencies, peerDependencies, devDependencies } = _chunkWGEGR3DFcjs.__require.call(void 0, `${process.cwd()}/package.json`);
|
|
28
13
|
const dependenciesKeys = Object.keys(_nullishCoalesce(dependencies, () => ( {}))).flatMap((p) => [
|
|
29
14
|
p,
|
|
30
15
|
getTypeDependencyPackageName(p)
|
|
@@ -74,22 +59,23 @@ function bundleTypeDefinitions(filename, outfile, externals) {
|
|
|
74
59
|
localBuild: true
|
|
75
60
|
});
|
|
76
61
|
if (extractorResult.succeeded === false) {
|
|
77
|
-
|
|
62
|
+
_configtools.writeError.call(void 0, `API Extractor completed with ${extractorResult.errorCount} ${extractorResult.errorCount === 1 ? "error" : "errors"}`);
|
|
78
63
|
throw new Error("API Extractor completed with errors");
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
|
-
|
|
82
|
-
var tscPlugin = /* @__PURE__ */
|
|
66
|
+
_chunkWGEGR3DFcjs.__name.call(void 0, bundleTypeDefinitions, "bundleTypeDefinitions");
|
|
67
|
+
var tscPlugin = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (emitTypes) => ({
|
|
83
68
|
name: "tscPlugin",
|
|
84
69
|
setup(build) {
|
|
85
70
|
const options = build.initialOptions;
|
|
86
71
|
if (emitTypes === false) return;
|
|
87
72
|
build.onStart(async () => {
|
|
73
|
+
const config = await _configtools.loadStormConfig.call(void 0, );
|
|
88
74
|
if (process.env.WATCH !== "true" && process.env.DEV !== "true") {
|
|
89
|
-
await run(`tsc --project ${options.tsconfig} --paths null
|
|
75
|
+
await _configtools.run.call(void 0, config, `pnpm exec tsc --project ${options.tsconfig} --paths null`, config.workspaceRoot);
|
|
90
76
|
}
|
|
91
77
|
if (options.bundle && options.outfile && _optionalChain([options, 'access', _ => _.entryPoints, 'optionalAccess', _2 => _2[0], 'access', _3 => _3.endsWith, 'call', _4 => _4(".ts")])) {
|
|
92
|
-
const tsconfig =
|
|
78
|
+
const tsconfig = _chunkWGEGR3DFcjs.__require.call(void 0, `${process.cwd()}/${options.tsconfig}`);
|
|
93
79
|
const typeOutDir = _nullishCoalesce(_optionalChain([tsconfig, 'optionalAccess', _5 => _5.compilerOptions, 'optionalAccess', _6 => _6.outDir]), () => ( "."));
|
|
94
80
|
const entryPoint = _optionalChain([options, 'access', _7 => _7.entryPoints, 'optionalAccess', _8 => _8[0], 'access', _9 => _9.replace, 'call', _10 => _10(/\.ts$/, "")]);
|
|
95
81
|
const bundlePath = options.outfile.replace(/\.m?js$/, "");
|
|
@@ -118,9 +104,9 @@ function getTypeDependencyPackageName(npmPackage) {
|
|
|
118
104
|
}
|
|
119
105
|
return `@types/${npmPackage}`;
|
|
120
106
|
}
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
_chunkWGEGR3DFcjs.__name.call(void 0, getTypeDependencyPackageName, "getTypeDependencyPackageName");
|
|
123
108
|
|
|
124
109
|
|
|
125
110
|
|
|
126
|
-
exports.
|
|
111
|
+
exports.tscPlugin = tscPlugin;
|
|
112
|
+
//# sourceMappingURL=chunk-263L44RM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-263L44RM.cjs","../src/plugins/tsc.ts"],"names":["bundleTypeDefinitions","filename","outfile","externals","dependencies","peerDependencies","devDependencies","require","p","flatMap","devDependenciesKeys","dependenciesKeys","peerDependenciesKeys","dep","bundledPackages","undefined","initialOptions","loadStormConfig","endsWith","dtsPath","entryPoint","dtsContents","process","name","npmPackage","getTypeDependencyPackageName"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACYA,qCAAoB;AACpB,wDAA2C;AAC3C,2DAAiD;AAEjD,wEAAiB;AASjB,SAASA,qBAAAA,CACPC,QAAAA,EACAC,OAAAA,EACAC,SAAAA,EAAmB;AAGnB,EAAA,MAAM,EAAEC,YAAAA,EAAcC,gBAAAA,EAAkBC,gBAAe,EAAA,EAAKC,yCAAAA,CAC1D,EAAA;AAI+DC,EAAAA;AAC/DA,IAAAA;AAC6BA,IAAAA;AAC9B,EAAA;AACgEC,EAAAA;AACzDD,IAAAA;AAAgCA,IAAAA;AAAG,EAAA;AAE4BA,EAAAA;AACrEA,IAAAA;AAC6BA,IAAAA;AAC9B,EAAA;AAEmBE,EAAAA;AACQ,EAAA;AACvBC,IAAAA;AACAC,IAAAA;AACAT,IAAAA;AACJ,EAAA;AACkEU,EAAAA;AAGnB,EAAA;AAChC,IAAA;AACc,MAAA;AACFZ,MAAAA;AACxBa,MAAAA;AACU,MAAA;AACmC,QAAA;AACzB,QAAA;AACC,UAAA;AACP,YAAA;AD9BqD;AC+B/D,UAAA;AACF,QAAA;AACF,MAAA;AACW,MAAA;AACA,QAAA;AACoD,QAAA;AAC/D,MAAA;AACe,MAAA;AACJ,QAAA;AACX,MAAA;AACF,IAAA;AAC8C,IAAA;AACxBC,IAAAA;AACxB,EAAA;AAG0D,EAAA;AACnC,IAAA;AACT,IAAA;AACd,EAAA;AAGyC,EAAA;AAEqB,IAAA;AAG5C,IAAA;AAClB,EAAA;AACF;AAvESf;AA8EH;AACE,EAAA;AACK,EAAA;AACagB,IAAAA;AAEG,IAAA;AAEX,IAAA;AACSC,MAAAA;AAG2C,MAAA;AAOjB,QAAA;AAG/C,MAAA;AAM2BC,MAAAA;AAGsC,QAAA;AACP,QAAA;AACK,QAAA;AACP,QAAA;AAElDC,QAAAA;AAEiDC,QAAAA;AAEPA,UAAAA;AAGRA,QAAAA;AAG2B,UAAA;AACjE,QAAA;AAEiD,QAAA;AACe,QAAA;AAEC,UAAA;AAER,UAAA;AACfC,UAAAA;AACnC,QAAA;AAMeC,UAAAA;AAEtB,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AApEgE;AA8EV;AACtB,EAAA;AACS,IAAA;AAEFC,IAAAA;AACvC,EAAA;AACiBC,EAAAA;AACnB;AAPSC;AD7EgE;AACA;AACA;AACA","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-263L44RM.cjs","sourcesContent":[null,"/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\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.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport { hfs } from \"@humanfs/node\";\nimport { Extractor, ExtractorConfig } from \"@microsoft/api-extractor\";\nimport { loadStormConfig, run, writeError } from \"@storm-software/config-tools\";\nimport type * as esbuild from \"esbuild\";\nimport path from \"node:path\";\n\n/**\n * Bundle all type definitions by using the API Extractor from RushStack\n *\n * @param filename - the source d.ts to bundle\n * @param outfile - the output bundled file\n * @param externals - the list of external dependencies\n */\nfunction bundleTypeDefinitions(\n filename: string,\n outfile: string,\n externals: string[]\n) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { dependencies, peerDependencies, devDependencies } = require(\n `${process.cwd()}/package.json`\n );\n\n // get the list of bundled and non bundled as well as their eventual type dependencies\n const dependenciesKeys = Object.keys(dependencies ?? {}).flatMap(p => [\n p,\n getTypeDependencyPackageName(p)\n ]);\n const peerDependenciesKeys = Object.keys(peerDependencies ?? {}).flatMap(\n p => [p, getTypeDependencyPackageName(p)]\n );\n const devDependenciesKeys = Object.keys(devDependencies ?? {}).flatMap(p => [\n p,\n getTypeDependencyPackageName(p)\n ]);\n\n const includeDeps = devDependenciesKeys;\n const excludeDeps = new Set([\n ...dependenciesKeys,\n ...peerDependenciesKeys,\n ...externals\n ]);\n const bundledPackages = includeDeps.filter(dep => !excludeDeps.has(dep));\n\n // we give the config in its raw form instead of a file\n const extractorConfig = ExtractorConfig.prepare({\n configObject: {\n projectFolder: process.cwd(),\n mainEntryPointFilePath: filename,\n bundledPackages,\n compiler: {\n tsconfigFilePath: path.join(process.cwd(), \"tsconfig.build.json\"),\n overrideTsconfig: {\n compilerOptions: {\n paths: {} // bug with api extract + paths\n }\n }\n },\n dtsRollup: {\n enabled: true,\n untrimmedFilePath: path.join(process.cwd(), `${outfile}.d.ts`)\n },\n tsdocMetadata: {\n enabled: false\n }\n },\n packageJsonFullPath: path.join(process.cwd(), \"package.json\"),\n configObjectFullPath: undefined\n });\n\n // here we trigger the \"command line\" interface equivalent\n const extractorResult = Extractor.invoke(extractorConfig, {\n showVerboseMessages: true,\n localBuild: true\n });\n\n // we exit the process immediately if there were errors\n if (extractorResult.succeeded === false) {\n writeError(\n `API Extractor completed with ${extractorResult.errorCount} ${extractorResult.errorCount === 1 ? \"error\" : \"errors\"}`\n );\n\n throw new Error(\"API Extractor completed with errors\");\n }\n}\n\n/**\n * Triggers the TypeScript compiler and the type bundler.\n */\nexport const tscPlugin: (emitTypes?: boolean) => esbuild.Plugin = (\n emitTypes?: boolean\n) => ({\n name: \"tscPlugin\",\n setup(build) {\n const options = build.initialOptions;\n\n if (emitTypes === false) return; // build has opted out of emitting types\n\n build.onStart(async () => {\n const config = await loadStormConfig();\n\n // we only call tsc if not in watch mode or in dev mode (they skip types)\n if (process.env.WATCH !== \"true\" && process.env.DEV !== \"true\") {\n // --paths null basically prevents typescript from using paths from the\n // tsconfig.json that is passed from the esbuild config. We need to do\n // this because TS would include types from the paths into this build.\n // but our paths, in our specific case only represent separate packages.\n await run(\n config,\n `pnpm exec tsc --project ${options.tsconfig} --paths null`,\n config.workspaceRoot\n );\n }\n\n // we bundle types if we also bundle the entry point and it is a ts file\n if (\n options.bundle &&\n options.outfile &&\n options.entryPoints?.[0].endsWith(\".ts\")\n ) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const tsconfig = require(`${process.cwd()}/${options.tsconfig}`); // tsconfig\n const typeOutDir = tsconfig?.compilerOptions?.outDir ?? \".\"; // type out dir\n const entryPoint = options.entryPoints?.[0].replace(/\\.ts$/, \"\");\n const bundlePath = options.outfile.replace(/\\.m?js$/, \"\");\n\n let dtsPath;\n if (\n await hfs.isFile(`${process.cwd()}/${typeOutDir}/${entryPoint}.d.ts`)\n ) {\n dtsPath = `${process.cwd()}/${typeOutDir}/${entryPoint}.d.ts`;\n } else if (\n await hfs.isFile(\n `${process.cwd()}/${typeOutDir}/${entryPoint.replace(/^src\\//, \"\")}.d.ts`\n )\n ) {\n dtsPath = `${process.cwd()}/${typeOutDir}/${entryPoint.replace(/^src\\//, \"\")}.d.ts`;\n }\n\n const ext = options.format === \"esm\" ? \"d.mts\" : \"d.ts\";\n if (process.env.WATCH !== \"true\" && process.env.DEV !== \"true\") {\n // we get the types generated by tsc and bundle them near the output\n bundleTypeDefinitions(dtsPath, bundlePath, options.external ?? []);\n\n const dtsContents = await hfs.text(`${bundlePath}.d.ts`);\n await hfs.write(`${bundlePath}.${ext}`, dtsContents!);\n } else {\n // in watch mode, it wouldn't be viable to bundle the types every time\n // we haven't built any types with tsc at this stage, but we want types\n // we link the types locally by re-exporting them from the entry point\n await hfs.write(\n `${bundlePath}.${ext}`,\n `export * from '${process.cwd()}/${entryPoint}'`\n );\n }\n }\n });\n }\n});\n\n/**\n * Automatically get the type dependency package name, following the\n * DefinitelyTyped naming conventions.\n *\n * @param npmPackage - the npm package name\n * @returns the type dependency package name\n */\nfunction getTypeDependencyPackageName(npmPackage: string) {\n if (npmPackage.startsWith(\"@\")) {\n const [scope, name] = npmPackage.split(\"/\");\n\n return `@types/${scope?.slice(1)}__${name}`;\n }\n return `@types/${npmPackage}`;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/plugins/esm-split-code-to-cjs.ts
|
|
2
|
+
import * as esbuild from "esbuild";
|
|
3
|
+
var esmSplitCodeToCjsPlugin = {
|
|
4
|
+
name: "storm:esm-split-code-to-cjs",
|
|
5
|
+
setup(build2) {
|
|
6
|
+
build2.onEnd(async (result) => {
|
|
7
|
+
const outFiles = Object.keys(result.metafile?.outputs ?? {});
|
|
8
|
+
const jsFiles = outFiles.filter((f) => f.endsWith("js"));
|
|
9
|
+
await esbuild.build({
|
|
10
|
+
outdir: build2.initialOptions.outdir,
|
|
11
|
+
entryPoints: jsFiles,
|
|
12
|
+
allowOverwrite: true,
|
|
13
|
+
format: "cjs",
|
|
14
|
+
logLevel: "error",
|
|
15
|
+
packages: "external"
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
esmSplitCodeToCjsPlugin
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-437F3SFI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/esm-split-code-to-cjs.ts"],"sourcesContent":["/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\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.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport * as esbuild from \"esbuild\";\n\n/**\n * Code splitting only works in ESM at the moment, this plugin will convert the\n * ESM code to CJS automatically after the build. Only works with `outdir` set.\n */\nexport const esmSplitCodeToCjsPlugin: esbuild.Plugin = {\n name: \"storm:esm-split-code-to-cjs\",\n setup(build) {\n build.onEnd(async result => {\n const outFiles = Object.keys(result.metafile?.outputs ?? {});\n const jsFiles = outFiles.filter(f => f.endsWith(\"js\"));\n\n await esbuild.build({\n outdir: build.initialOptions.outdir,\n entryPoints: jsFiles,\n allowOverwrite: true,\n format: \"cjs\",\n logLevel: \"error\",\n packages: \"external\"\n });\n });\n }\n};\n"],"mappings":";AAiBA,YAAYA,aAAa;AAMlB,IAAMC,0BAA0C;EACrDC,MAAM;EACNC,MAAMC,QAAK;AACTA,IAAAA,OAAMC,MAAM,OAAMC,WAAAA;AAChB,YAAMC,WAAWC,OAAOC,KAAKH,OAAOI,UAAUC,WAAW,CAAC,CAAA;AAC1D,YAAMC,UAAUL,SAASM,OAAOC,CAAAA,MAAKA,EAAEC,SAAS,IAAA,CAAA;AAEhD,YAAcX,cAAM;QAClBY,QAAQZ,OAAMa,eAAeD;QAC7BE,aAAaN;QACbO,gBAAgB;QAChBC,QAAQ;QACRC,UAAU;QACVC,UAAU;MACZ,CAAA;IACF,CAAA;EACF;AACF;","names":["esbuild","esmSplitCodeToCjsPlugin","name","setup","build","onEnd","result","outFiles","Object","keys","metafile","outputs","jsFiles","filter","f","endsWith","outdir","initialOptions","entryPoints","allowOverwrite","format","logLevel","packages"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkWGEGR3DFcjs = require('./chunk-WGEGR3DF.cjs');
|
|
5
5
|
|
|
6
6
|
// src/plugins/resolve-paths.ts
|
|
7
7
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
@@ -19,16 +19,16 @@ function resolvePathsConfig(options, cwd) {
|
|
|
19
19
|
if (options.extends) {
|
|
20
20
|
const extendsPath = _path2.default.resolve(cwd, options.extends);
|
|
21
21
|
const extendsDir = _path2.default.dirname(extendsPath);
|
|
22
|
-
const extendsConfig =
|
|
22
|
+
const extendsConfig = _chunkWGEGR3DFcjs.__require.call(void 0, extendsPath);
|
|
23
23
|
return resolvePathsConfig(extendsConfig, extendsDir);
|
|
24
24
|
}
|
|
25
25
|
return [];
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
_chunkWGEGR3DFcjs.__name.call(void 0, resolvePathsConfig, "resolvePathsConfig");
|
|
28
28
|
var resolvePathsPlugin = {
|
|
29
29
|
name: "storm:resolve-paths",
|
|
30
30
|
setup(build) {
|
|
31
|
-
const parentTsConfig =
|
|
31
|
+
const parentTsConfig = _chunkWGEGR3DFcjs.__require.call(void 0, `${process.cwd()}/${build.initialOptions.tsconfig}`);
|
|
32
32
|
const resolvedTsPaths = resolvePathsConfig(parentTsConfig, process.cwd());
|
|
33
33
|
const packagesRegex = new RegExp(`^(${Object.keys(resolvedTsPaths).join("|")})$`);
|
|
34
34
|
build.onResolve({
|
|
@@ -50,3 +50,4 @@ var resolvePathsPlugin = {
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
exports.resolvePathsPlugin = resolvePathsPlugin;
|
|
53
|
+
//# sourceMappingURL=chunk-BF5W6GVP.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-BF5W6GVP.cjs","../src/plugins/resolve-paths.ts"],"names":["resolvePathsConfig","options","cwd","compilerOptions","paths","Object","entries","resolvedPaths","map","key","v","path","resolve","fromEntries","extends","extendsPath","extendsDir","dirname","extendsConfig","require","resolvePathsPlugin","name","setup","build","parentTsConfig","packagesRegex","args","external"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACaA,wEAAiB;AAgBjB,SAASA,kBAAAA,CAAmBC,OAAAA,EAAmBC,GAAAA,EAAW;AACxD,EAAA,GAAA,iBAAID,OAAAA,2BAASE,eAAAA,6BAAiBC,OAAAA,EAAO;AACnC,IAAA,MAAMA,MAAAA,EAAQC,MAAAA,CAAOC,OAAAA,CAAQL,OAAAA,CAAQE,eAAAA,CAAgBC,KAAK,CAAA;AAE1D,IAAA,MAAMG,cAAAA,EAAgBH,KAAAA,CAAMI,GAAAA,CAAI,CAAC,CAACC,GAAAA,EAAKL,MAAAA,CAAAA,EAAAA,GAAM;AAC3C,MAAA,OAAO;AD3Bb,QC2BcK,GAAAA;AD1Bd,QC0BmBL,MAAAA,CAAMI,GAAAA,CAAIE,CAAAA,CAAAA,EAAAA,GAAKC,cAAAA,CAAKC,OAAAA,CAAQV,GAAAA,EAAKQ,CAAAA,CAAAA;ADzBpD,MAAM,CAAC;AACP,ICyBI,CAAA,CAAA;AAEA,IAAA,OAAOL,MAAAA,CAAOQ,WAAAA,CAAYN,aAAAA,CAAAA;ADzB9B,EC0BE;AAEA,EAAA,GAAA,CAAIN,OAAAA,CAAQa,OAAAA,EAAS;AACnB,IAAA,MAAMC,YAAAA,EAAcJ,cAAAA,CAAKC,OAAAA,CAAQV,GAAAA,EAAKD,OAAAA,CAAQa,OAAO,CAAA;AACrD,IAAA,MAAME,WAAAA,EAAaL,cAAAA,CAAKM,OAAAA,CAAQF,WAAAA,CAAAA;AAEhC,IAAA,MAAMG,cAAAA,EAAgBC,yCAAAA,WAAQJ,CAAAA;AAE9B,IAAA,OAAOf,kBAAAA,CAAmBkB,aAAAA,EAAeF,UAAAA,CAAAA;AD5B7C,EC6BE;AAEA,EAAA,OAAO,CAAA,CAAA;AACT;AArBShB,sCAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA;AA6BF,IAAMoB,mBAAAA,EAAqC;ADnClD,ECoCEC,IAAAA,EAAM,qBAAA;ADnCR,ECoCEC,KAAAA,CAAMC,KAAAA,EAAK;AAET,IAAA,MAAMC,eAAAA,EAAiBL,yCAAAA,CACrB,EAAA;AAEsBnB,IAAAA;AAEtB,IAAA;AAGc,IAAA;AAAUyB,MAAAA;AAAiBC,IAAAA;AAChBC,MAAAA;AAChB,QAAA;AAAahB,UAAAA;AAAgB,UAAA;AAAK,QAAA;AAC3C,MAAA;AAEO,MAAA;AAAgCA,QAAAA;AAAoB,MAAA;AAC7D,IAAA;AACF,EAAA;AACF;ADnCsC;AACA;AACA;AACA","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-BF5W6GVP.cjs","sourcesContent":[null,"/*-------------------------------------------------------------------\n\n ⚡ Storm Software - Storm Stack\n\n This code was released as part of the Storm Stack project. Storm Stack\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.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/storm-ops\n Documentation: https://stormsoftware.com/projects/storm-ops/docs\n Contact: https://stormsoftware.com/contact\n License: https://stormsoftware.com/projects/storm-ops/license\n\n -------------------------------------------------------------------*/\n\nimport type * as esbuild from \"esbuild\";\nimport path from \"node:path\";\n\ntype TsConfig = {\n compilerOptions?: {\n paths?: Record<string, string[]>;\n };\n extends?: string;\n};\n\n/**\n * Recursive function to resolve the paths config from a tsconfig.json, whether\n * it is in the config directly or via an inherited config (via \"extends\").\n * @param options\n * @param cwd\n * @returns\n */\nfunction resolvePathsConfig(options: TsConfig, cwd: string) {\n if (options?.compilerOptions?.paths) {\n const paths = Object.entries(options.compilerOptions.paths);\n\n const resolvedPaths = paths.map(([key, paths]) => {\n return [key, paths.map(v => path.resolve(cwd, v))] as const;\n });\n\n return Object.fromEntries(resolvedPaths);\n }\n\n if (options.extends) {\n const extendsPath = path.resolve(cwd, options.extends);\n const extendsDir = path.dirname(extendsPath);\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const extendsConfig = require(extendsPath);\n\n return resolvePathsConfig(extendsConfig, extendsDir);\n }\n\n return [];\n}\n\n/**\n * Forces `esbuild` to always use the TS compiler paths, even when we are\n * bundling a local dependency of a local dependency, ensuring maximum\n * tree-shaking. Note: `esbuild` has some support for this, though it is limited\n * in the amount of dependency nesting it supports.\n */\nexport const resolvePathsPlugin: esbuild.Plugin = {\n name: \"storm:resolve-paths\",\n setup(build) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const parentTsConfig = require(\n `${process.cwd()}/${build.initialOptions.tsconfig}`\n );\n const resolvedTsPaths = resolvePathsConfig(parentTsConfig, process.cwd());\n const packagesRegex = new RegExp(\n `^(${Object.keys(resolvedTsPaths).join(\"|\")})$`\n );\n\n build.onResolve({ filter: packagesRegex }, args => {\n if (build.initialOptions.external?.includes(args.path)) {\n return { path: args.path, external: true };\n }\n\n return { path: `${resolvedTsPaths[args.path][0]}/index.ts` };\n });\n }\n};\n"]}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
onErrorPlugin
|
|
3
|
-
} from "./chunk-RKSGVSXZ.js";
|
|
4
1
|
import {
|
|
5
2
|
resolvePathsPlugin
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TTHABTDU.js";
|
|
7
4
|
import {
|
|
8
5
|
tscPlugin
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KJ7ZHAFS.js";
|
|
10
7
|
import {
|
|
11
8
|
DEFAULT_BUILD_OPTIONS
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DRRPNILS.js";
|
|
13
10
|
import {
|
|
14
11
|
depsCheckPlugin
|
|
15
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CMWXE5MF.js";
|
|
16
13
|
import {
|
|
17
|
-
|
|
18
|
-
} from "./chunk-
|
|
14
|
+
esmSplitCodeToCjsPlugin
|
|
15
|
+
} from "./chunk-437F3SFI.js";
|
|
19
16
|
import {
|
|
20
17
|
fixImportsPlugin
|
|
21
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YQBU3FSL.js";
|
|
19
|
+
import {
|
|
20
|
+
onErrorPlugin
|
|
21
|
+
} from "./chunk-X5TLV7MF.js";
|
|
22
22
|
import {
|
|
23
23
|
__name
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-WCQVDF3K.js";
|
|
25
25
|
|
|
26
26
|
// src/build.ts
|
|
27
27
|
import { hfs } from "@humanfs/node";
|
|
28
|
-
import { createProjectGraphAsync, joinPathFragments,
|
|
29
|
-
import {
|
|
28
|
+
import { createProjectGraphAsync, joinPathFragments, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
|
|
29
|
+
import { addPackageDependencies, addPackageJsonExport, addWorkspacePackageJsonFields, copyAssets } from "@storm-software/build-tools";
|
|
30
|
+
import { getStopwatch, loadStormConfig, writeDebug, writeError, writeFatal, writeSuccess, writeTrace, writeWarning } from "@storm-software/config-tools";
|
|
30
31
|
import { watch as createWatcher } from "chokidar";
|
|
31
32
|
import { debounce, flatten, omit } from "es-toolkit";
|
|
32
33
|
import { map } from "es-toolkit/compat";
|
|
33
34
|
import * as esbuild from "esbuild";
|
|
34
35
|
import { globbySync } from "globby";
|
|
35
|
-
import { existsSync } from "node:fs";
|
|
36
36
|
import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root";
|
|
37
37
|
|
|
38
38
|
// src/utilities/helpers.ts
|
|
@@ -132,8 +132,10 @@ var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
|
132
132
|
if (!projectConfigurations?.projects?.[projectName]) {
|
|
133
133
|
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
134
134
|
}
|
|
135
|
+
const config = await loadStormConfig(workspaceRoot.dir);
|
|
135
136
|
return {
|
|
136
137
|
...DEFAULT_BUILD_OPTIONS,
|
|
138
|
+
config,
|
|
137
139
|
format: "cjs",
|
|
138
140
|
outExtension: {
|
|
139
141
|
".js": ".js"
|
|
@@ -143,21 +145,20 @@ var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
|
143
145
|
".js",
|
|
144
146
|
".node"
|
|
145
147
|
],
|
|
146
|
-
entryPoints: globbySync("./src/**/*.{j,t}s", {
|
|
147
|
-
ignore: [
|
|
148
|
-
"./src/__tests__/**/*"
|
|
149
|
-
]
|
|
150
|
-
}),
|
|
151
148
|
mainFields: [
|
|
152
149
|
"module",
|
|
153
150
|
"main"
|
|
154
151
|
],
|
|
155
152
|
...options,
|
|
153
|
+
entryPoints: options.entryPoints || [
|
|
154
|
+
"./src/index.ts"
|
|
155
|
+
],
|
|
156
156
|
outdir: options.outdir || joinPathFragments(workspaceRoot.dir, "dist", projectRoot),
|
|
157
157
|
plugins: [
|
|
158
158
|
...options.plugins ?? [],
|
|
159
159
|
resolvePathsPlugin,
|
|
160
160
|
fixImportsPlugin,
|
|
161
|
+
esmSplitCodeToCjsPlugin,
|
|
161
162
|
tscPlugin(options.emitTypes),
|
|
162
163
|
onErrorPlugin
|
|
163
164
|
],
|
|
@@ -168,69 +169,55 @@ var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
|
168
169
|
projectConfigurations,
|
|
169
170
|
projectName,
|
|
170
171
|
projectGraph,
|
|
171
|
-
workspaceRoot
|
|
172
|
+
workspaceRoot,
|
|
173
|
+
sourceRoot: options.sourceRoot || joinPathFragments(workspaceRoot.dir, projectRoot, "src")
|
|
172
174
|
};
|
|
173
175
|
}, "resolveOptions");
|
|
174
176
|
var generatePackageJson = /* @__PURE__ */ __name(async (options) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (!await hfs.isFile(projectJsonPath)) {
|
|
181
|
-
throw new Error("Cannot find project.json configuration");
|
|
182
|
-
}
|
|
183
|
-
if (!options.projectConfigurations?.projects?.[options.projectName]) {
|
|
184
|
-
throw new Error("The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project.");
|
|
185
|
-
}
|
|
186
|
-
const packageJsonPath = joinPathFragments(options.projectRoot, "project.json");
|
|
187
|
-
if (!await hfs.isFile(packageJsonPath)) {
|
|
188
|
-
throw new Error("Cannot find package.json configuration");
|
|
189
|
-
}
|
|
190
|
-
const packageJson = await hfs.json(joinPathFragments(options.workspaceRoot.dir, options.projectRoot, "package.json"));
|
|
191
|
-
const projectDependencies = calculateProjectBuildableDependencies(void 0, options.projectGraph, options.workspaceRoot.dir, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
192
|
-
const localPackages = projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && dep.node.data.root !== options.projectRoot && dep.node.data.root !== options.workspaceRoot.dir).reduce((ret, project) => {
|
|
193
|
-
const projectNode = project.node;
|
|
194
|
-
if (projectNode.data.root) {
|
|
195
|
-
const projectPackageJsonPath = joinPathFragments(options.workspaceRoot.dir, projectNode.data.root, "package.json");
|
|
196
|
-
if (existsSync(projectPackageJsonPath)) {
|
|
197
|
-
const projectPackageJson = readJsonFile(projectPackageJsonPath);
|
|
198
|
-
if (projectPackageJson.private !== false) {
|
|
199
|
-
ret.push(projectPackageJson);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
177
|
+
if (options.generatePackageJson !== false && await hfs.isFile(joinPathFragments(options.projectRoot, "package.json"))) {
|
|
178
|
+
writeDebug("\u270D\uFE0F Writing package.json file", options.config);
|
|
179
|
+
const packageJsonPath = joinPathFragments(options.projectRoot, "project.json");
|
|
180
|
+
if (!await hfs.isFile(packageJsonPath)) {
|
|
181
|
+
throw new Error("Cannot find package.json configuration");
|
|
202
182
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
packageJson
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
packageJson.peerDependenciesMeta = localPackages.reduce((ret, localPackage) => {
|
|
214
|
-
if (!ret[localPackage.name]) {
|
|
215
|
-
ret[localPackage.name] = {
|
|
216
|
-
optional: false
|
|
217
|
-
};
|
|
183
|
+
let packageJson = await hfs.json(joinPathFragments(options.workspaceRoot.dir, options.projectRoot, "package.json"));
|
|
184
|
+
if (!packageJson) {
|
|
185
|
+
throw new Error("Cannot find package.json configuration file");
|
|
186
|
+
}
|
|
187
|
+
packageJson = await addPackageDependencies(options.workspaceRoot.dir, options.projectRoot, options.projectName, packageJson);
|
|
188
|
+
packageJson = await addWorkspacePackageJsonFields(options.config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
189
|
+
let entryPoints = [
|
|
190
|
+
{
|
|
191
|
+
in: "./src/index.ts",
|
|
192
|
+
out: "./src/index.ts"
|
|
218
193
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
194
|
+
];
|
|
195
|
+
if (options.entryPoints) {
|
|
196
|
+
if (Array.isArray(options.entryPoints)) {
|
|
197
|
+
entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
|
|
198
|
+
in: entryPoint,
|
|
199
|
+
out: entryPoint
|
|
200
|
+
} : entryPoint);
|
|
201
|
+
} else {
|
|
202
|
+
entryPoints = Object.entries(options.entryPoints).map(([key, value]) => ({
|
|
203
|
+
in: key,
|
|
204
|
+
out: value
|
|
205
|
+
}));
|
|
224
206
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
207
|
+
}
|
|
208
|
+
for (const entryPoint of entryPoints) {
|
|
209
|
+
const split = entryPoint.out.split(".");
|
|
210
|
+
split.pop();
|
|
211
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
212
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry);
|
|
213
|
+
}
|
|
214
|
+
packageJson.exports["./package.json"] ??= "./package.json";
|
|
215
|
+
packageJson.exports["."] ??= addPackageJsonExport("./src/index.ts");
|
|
216
|
+
packageJson.main = "./dist/index.cjs";
|
|
217
|
+
packageJson.module = "./dist/index.js";
|
|
218
|
+
packageJson.types = "./dist/index.d.ts";
|
|
219
|
+
await writeJsonFile(joinPathFragments(options.outdir, "package.json"), packageJson);
|
|
229
220
|
}
|
|
230
|
-
packageJson.main = "./dist/index.cjs";
|
|
231
|
-
packageJson.module = "./dist/index.mjs";
|
|
232
|
-
packageJson.types = "./dist/index.d.ts";
|
|
233
|
-
await writeJsonFile(joinPathFragments(options.outdir, "package.json"), packageJson);
|
|
234
221
|
return options;
|
|
235
222
|
}, "generatePackageJson");
|
|
236
223
|
async function createOptions(options) {
|
|
@@ -245,6 +232,7 @@ async function computeOptions(options) {
|
|
|
245
232
|
}
|
|
246
233
|
__name(computeOptions, "computeOptions");
|
|
247
234
|
async function executeEsBuild(options) {
|
|
235
|
+
const stopwatch = getStopwatch(`${options.name} build`);
|
|
248
236
|
if (process.env.WATCH === "true") {
|
|
249
237
|
const context2 = await esbuild.context(omit(options, [
|
|
250
238
|
"name",
|
|
@@ -253,21 +241,41 @@ async function executeEsBuild(options) {
|
|
|
253
241
|
]));
|
|
254
242
|
watch(context2, options);
|
|
255
243
|
}
|
|
256
|
-
const
|
|
244
|
+
const result = await esbuild.build(omit(options, [
|
|
257
245
|
"name",
|
|
258
246
|
"emitTypes",
|
|
259
247
|
"emitMetafile"
|
|
260
248
|
]));
|
|
261
|
-
if (
|
|
249
|
+
if (result.metafile && options.emitMetafile) {
|
|
262
250
|
const metafilePath = `${options.outdir}/${options.name}.meta.json`;
|
|
263
|
-
await hfs.write(metafilePath, JSON.stringify(
|
|
251
|
+
await hfs.write(metafilePath, JSON.stringify(result.metafile));
|
|
264
252
|
}
|
|
253
|
+
stopwatch();
|
|
265
254
|
return [
|
|
266
255
|
options,
|
|
267
|
-
|
|
256
|
+
result
|
|
268
257
|
];
|
|
269
258
|
}
|
|
270
259
|
__name(executeEsBuild, "executeEsBuild");
|
|
260
|
+
async function copyBuildAssets([options, result]) {
|
|
261
|
+
if (result.errors.length === 0) {
|
|
262
|
+
await copyAssets(options.config, options.assets ?? [], options.outdir, options.projectRoot, options.projectName, options.sourceRoot, true, false);
|
|
263
|
+
}
|
|
264
|
+
return [
|
|
265
|
+
options,
|
|
266
|
+
result
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
__name(copyBuildAssets, "copyBuildAssets");
|
|
270
|
+
async function reportResults([options, result]) {
|
|
271
|
+
if (result.errors.length === 0) {
|
|
272
|
+
if (result.warnings.length > 0) {
|
|
273
|
+
writeWarning(`The following warnings occurred during the build: ${result.warnings.map((warning) => warning.text).join("\n")}`, options.config);
|
|
274
|
+
}
|
|
275
|
+
writeSuccess(`The ${options.name} build completed successfully`, options.config);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
__name(reportResults, "reportResults");
|
|
271
279
|
async function dependencyCheck(options) {
|
|
272
280
|
if (process.env.DEV === "true") return void 0;
|
|
273
281
|
if (process.env.CI && !process.env.BUILDKITE) return void 0;
|
|
@@ -295,8 +303,14 @@ async function dependencyCheck(options) {
|
|
|
295
303
|
}
|
|
296
304
|
__name(dependencyCheck, "dependencyCheck");
|
|
297
305
|
async function build2(options) {
|
|
298
|
-
|
|
299
|
-
|
|
306
|
+
const stopwatch = getStopwatch("full build");
|
|
307
|
+
try {
|
|
308
|
+
void transduce.async(options, dependencyCheck);
|
|
309
|
+
await transduce.async(await createOptions(options), pipe.async(computeOptions, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
|
|
310
|
+
} catch (error) {
|
|
311
|
+
writeFatal("Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.");
|
|
312
|
+
}
|
|
313
|
+
stopwatch();
|
|
300
314
|
}
|
|
301
315
|
__name(build2, "build");
|
|
302
316
|
var watch = /* @__PURE__ */ __name((context2, options) => {
|
|
@@ -318,9 +332,9 @@ var watch = /* @__PURE__ */ __name((context2, options) => {
|
|
|
318
332
|
return context2.rebuild();
|
|
319
333
|
});
|
|
320
334
|
if (rebuildResult instanceof Error) {
|
|
321
|
-
|
|
335
|
+
writeError(rebuildResult.message);
|
|
322
336
|
}
|
|
323
|
-
|
|
337
|
+
writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
|
|
324
338
|
}, 10);
|
|
325
339
|
changeWatcher.on("change", fastRebuild);
|
|
326
340
|
return void 0;
|
|
@@ -335,3 +349,4 @@ export {
|
|
|
335
349
|
pipe,
|
|
336
350
|
build2 as build
|
|
337
351
|
};
|
|
352
|
+
//# sourceMappingURL=chunk-CMEDJ4L4.js.map
|