@storm-software/esbuild 0.2.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 +6 -6
- package/dist/build.d.cts +5 -3
- package/dist/build.d.ts +5 -3
- package/dist/build.js +5 -5
- package/dist/{chunk-T5H2LBQA.cjs → chunk-263L44RM.cjs} +6 -21
- 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-IDO67KEL.js → chunk-CMEDJ4L4.js} +89 -57
- package/dist/chunk-CMEDJ4L4.js.map +1 -0
- package/dist/{chunk-7U3F23ZZ.js → chunk-CMWXE5MF.js} +4 -6
- package/dist/chunk-CMWXE5MF.js.map +1 -0
- package/dist/chunk-J34FQYKV.cjs +24 -0
- package/dist/chunk-J34FQYKV.cjs.map +1 -0
- package/dist/{chunk-QBYHNHXL.js → chunk-KJ7ZHAFS.js} +5 -20
- package/dist/chunk-KJ7ZHAFS.js.map +1 -0
- package/dist/{chunk-Z2M426LD.cjs → chunk-KVBDKVBU.cjs} +4 -6
- package/dist/chunk-KVBDKVBU.cjs.map +1 -0
- package/dist/{chunk-PRNPZZSV.cjs → chunk-MVLEDP7K.cjs} +5 -7
- package/dist/chunk-MVLEDP7K.cjs.map +1 -0
- package/dist/{chunk-75SHW3Z4.cjs → chunk-PBHOTQGA.cjs} +89 -57
- package/dist/chunk-PBHOTQGA.cjs.map +1 -0
- package/dist/{chunk-CMF37LBT.js → chunk-X5TLV7MF.js} +4 -6
- package/dist/chunk-X5TLV7MF.js.map +1 -0
- package/dist/config.d.cts +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/index.cjs +6 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.js +6 -12
- package/dist/types.d.cts +1167 -0
- package/dist/types.d.ts +1167 -0
- package/package.json +3 -6
- package/dist/chunk-4ZPYEZJO.cjs +0 -15
- package/dist/chunk-4ZPYEZJO.cjs.map +0 -1
- package/dist/chunk-75SHW3Z4.cjs.map +0 -1
- package/dist/chunk-7U3F23ZZ.js.map +0 -1
- package/dist/chunk-CMF37LBT.js.map +0 -1
- package/dist/chunk-IDO67KEL.js.map +0 -1
- package/dist/chunk-PRNPZZSV.cjs.map +0 -1
- package/dist/chunk-QBYHNHXL.js.map +0 -1
- package/dist/chunk-T5H2LBQA.cjs.map +0 -1
- package/dist/chunk-Z2M426LD.cjs.map +0 -1
- package/dist/chunk-ZQ5NVDFP.js +0 -15
- package/dist/chunk-ZQ5NVDFP.js.map +0 -1
package/dist/build.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-PRNPZZSV.cjs');
|
|
3
|
+
var _chunkPBHOTQGAcjs = require('./chunk-PBHOTQGA.cjs');
|
|
5
4
|
require('./chunk-BF5W6GVP.cjs');
|
|
6
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-263L44RM.cjs');
|
|
7
6
|
require('./chunk-D5PRB2E2.cjs');
|
|
8
|
-
require('./chunk-
|
|
9
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-KVBDKVBU.cjs');
|
|
8
|
+
require('./chunk-J34FQYKV.cjs');
|
|
10
9
|
require('./chunk-DFGHPRBD.cjs');
|
|
10
|
+
require('./chunk-MVLEDP7K.cjs');
|
|
11
11
|
require('./chunk-WGEGR3DF.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.build =
|
|
14
|
+
exports.build = _chunkPBHOTQGAcjs.build;
|
|
15
15
|
//# sourceMappingURL=build.cjs.map
|
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,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-CMF37LBT.js";
|
|
3
|
+
} from "./chunk-CMEDJ4L4.js";
|
|
5
4
|
import "./chunk-TTHABTDU.js";
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-KJ7ZHAFS.js";
|
|
7
6
|
import "./chunk-DRRPNILS.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-CMWXE5MF.js";
|
|
8
|
+
import "./chunk-437F3SFI.js";
|
|
10
9
|
import "./chunk-YQBU3FSL.js";
|
|
10
|
+
import "./chunk-X5TLV7MF.js";
|
|
11
11
|
import "./chunk-WCQVDF3K.js";
|
|
12
12
|
export {
|
|
13
13
|
build
|
|
@@ -1,28 +1,13 @@
|
|
|
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 _chunk4ZPYEZJOcjs = require('./chunk-4ZPYEZJO.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
3
|
|
|
7
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
|
-
_chunkWGEGR3DFcjs.__name.call(void 0, run, "run");
|
|
24
|
-
|
|
25
|
-
// src/plugins/tsc.ts
|
|
26
11
|
function bundleTypeDefinitions(filename, outfile, externals) {
|
|
27
12
|
const { dependencies, peerDependencies, devDependencies } = _chunkWGEGR3DFcjs.__require.call(void 0, `${process.cwd()}/package.json`);
|
|
28
13
|
const dependenciesKeys = Object.keys(_nullishCoalesce(dependencies, () => ( {}))).flatMap((p) => [
|
|
@@ -74,7 +59,7 @@ 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
|
}
|
|
@@ -85,8 +70,9 @@ var tscPlugin = /* @__PURE__ */ _chunkWGEGR3DFcjs.__name.call(void 0, (emitTypes
|
|
|
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
78
|
const tsconfig = _chunkWGEGR3DFcjs.__require.call(void 0, `${process.cwd()}/${options.tsconfig}`);
|
|
@@ -122,6 +108,5 @@ _chunkWGEGR3DFcjs.__name.call(void 0, getTypeDependencyPackageName, "getTypeDepe
|
|
|
122
108
|
|
|
123
109
|
|
|
124
110
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=chunk-T5H2LBQA.cjs.map
|
|
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,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
onErrorPlugin
|
|
3
|
-
} from "./chunk-CMF37LBT.js";
|
|
4
1
|
import {
|
|
5
2
|
resolvePathsPlugin
|
|
6
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
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
18
|
} from "./chunk-YQBU3FSL.js";
|
|
19
|
+
import {
|
|
20
|
+
onErrorPlugin
|
|
21
|
+
} from "./chunk-X5TLV7MF.js";
|
|
22
22
|
import {
|
|
23
23
|
__name
|
|
24
24
|
} from "./chunk-WCQVDF3K.js";
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
// src/build.ts
|
|
27
27
|
import { hfs } from "@humanfs/node";
|
|
28
28
|
import { createProjectGraphAsync, joinPathFragments, readProjectsConfigurationFromProjectGraph, writeJsonFile } from "@nx/devkit";
|
|
29
|
-
import { addPackageDependencies, addPackageJsonExport, addWorkspacePackageJsonFields } from "@storm-software/build-tools";
|
|
30
|
-
import { loadStormConfig } from "@storm-software/config-tools";
|
|
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";
|
|
31
31
|
import { watch as createWatcher } from "chokidar";
|
|
32
32
|
import { debounce, flatten, omit } from "es-toolkit";
|
|
33
33
|
import { map } from "es-toolkit/compat";
|
|
@@ -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"
|
|
@@ -156,6 +158,7 @@ var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
|
156
158
|
...options.plugins ?? [],
|
|
157
159
|
resolvePathsPlugin,
|
|
158
160
|
fixImportsPlugin,
|
|
161
|
+
esmSplitCodeToCjsPlugin,
|
|
159
162
|
tscPlugin(options.emitTypes),
|
|
160
163
|
onErrorPlugin
|
|
161
164
|
],
|
|
@@ -171,48 +174,50 @@ var resolveOptions = /* @__PURE__ */ __name(async (options) => {
|
|
|
171
174
|
};
|
|
172
175
|
}, "resolveOptions");
|
|
173
176
|
var generatePackageJson = /* @__PURE__ */ __name(async (options) => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
let packageJson = await hfs.json(joinPathFragments(options.workspaceRoot.dir, options.projectRoot, "package.json"));
|
|
180
|
-
if (!packageJson) {
|
|
181
|
-
throw new Error("Cannot find package.json configuration file");
|
|
182
|
-
}
|
|
183
|
-
packageJson = await addPackageDependencies(options.workspaceRoot.dir, options.projectRoot, options.projectName, packageJson);
|
|
184
|
-
packageJson = await addWorkspacePackageJsonFields(config, options.projectRoot, options.sourceRoot, options.projectName, false, packageJson);
|
|
185
|
-
let entryPoints = [
|
|
186
|
-
{
|
|
187
|
-
in: "./src/index.ts",
|
|
188
|
-
out: "./src/index.ts"
|
|
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");
|
|
189
182
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
entryPoints = options.entryPoints.map((entryPoint) => typeof entryPoint === "string" ? {
|
|
194
|
-
in: entryPoint,
|
|
195
|
-
out: entryPoint
|
|
196
|
-
} : entryPoint);
|
|
197
|
-
} else {
|
|
198
|
-
entryPoints = Object.entries(options.entryPoints).map(([key, value]) => ({
|
|
199
|
-
in: key,
|
|
200
|
-
out: value
|
|
201
|
-
}));
|
|
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");
|
|
202
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"
|
|
193
|
+
}
|
|
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
|
+
}));
|
|
206
|
+
}
|
|
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);
|
|
203
220
|
}
|
|
204
|
-
for (const entryPoint of entryPoints) {
|
|
205
|
-
const split = entryPoint.out.split(".");
|
|
206
|
-
split.pop();
|
|
207
|
-
const entry = split.join(".").replaceAll("\\", "/");
|
|
208
|
-
packageJson.entry[`./${entry}`] ??= addPackageJsonExport(entry);
|
|
209
|
-
}
|
|
210
|
-
packageJson.entry["./package.json"] = "./package.json";
|
|
211
|
-
packageJson.entry["."] ??= addPackageJsonExport("./src/index.ts");
|
|
212
|
-
packageJson.main = "./dist/index.cjs";
|
|
213
|
-
packageJson.module = "./dist/index.js";
|
|
214
|
-
packageJson.types = "./dist/index.d.ts";
|
|
215
|
-
await writeJsonFile(joinPathFragments(options.outdir, "package.json"), packageJson);
|
|
216
221
|
return options;
|
|
217
222
|
}, "generatePackageJson");
|
|
218
223
|
async function createOptions(options) {
|
|
@@ -227,6 +232,7 @@ async function computeOptions(options) {
|
|
|
227
232
|
}
|
|
228
233
|
__name(computeOptions, "computeOptions");
|
|
229
234
|
async function executeEsBuild(options) {
|
|
235
|
+
const stopwatch = getStopwatch(`${options.name} build`);
|
|
230
236
|
if (process.env.WATCH === "true") {
|
|
231
237
|
const context2 = await esbuild.context(omit(options, [
|
|
232
238
|
"name",
|
|
@@ -235,21 +241,41 @@ async function executeEsBuild(options) {
|
|
|
235
241
|
]));
|
|
236
242
|
watch(context2, options);
|
|
237
243
|
}
|
|
238
|
-
const
|
|
244
|
+
const result = await esbuild.build(omit(options, [
|
|
239
245
|
"name",
|
|
240
246
|
"emitTypes",
|
|
241
247
|
"emitMetafile"
|
|
242
248
|
]));
|
|
243
|
-
if (
|
|
249
|
+
if (result.metafile && options.emitMetafile) {
|
|
244
250
|
const metafilePath = `${options.outdir}/${options.name}.meta.json`;
|
|
245
|
-
await hfs.write(metafilePath, JSON.stringify(
|
|
251
|
+
await hfs.write(metafilePath, JSON.stringify(result.metafile));
|
|
246
252
|
}
|
|
253
|
+
stopwatch();
|
|
247
254
|
return [
|
|
248
255
|
options,
|
|
249
|
-
|
|
256
|
+
result
|
|
250
257
|
];
|
|
251
258
|
}
|
|
252
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");
|
|
253
279
|
async function dependencyCheck(options) {
|
|
254
280
|
if (process.env.DEV === "true") return void 0;
|
|
255
281
|
if (process.env.CI && !process.env.BUILDKITE) return void 0;
|
|
@@ -277,8 +303,14 @@ async function dependencyCheck(options) {
|
|
|
277
303
|
}
|
|
278
304
|
__name(dependencyCheck, "dependencyCheck");
|
|
279
305
|
async function build2(options) {
|
|
280
|
-
|
|
281
|
-
|
|
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();
|
|
282
314
|
}
|
|
283
315
|
__name(build2, "build");
|
|
284
316
|
var watch = /* @__PURE__ */ __name((context2, options) => {
|
|
@@ -300,9 +332,9 @@ var watch = /* @__PURE__ */ __name((context2, options) => {
|
|
|
300
332
|
return context2.rebuild();
|
|
301
333
|
});
|
|
302
334
|
if (rebuildResult instanceof Error) {
|
|
303
|
-
|
|
335
|
+
writeError(rebuildResult.message);
|
|
304
336
|
}
|
|
305
|
-
|
|
337
|
+
writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? ""}]`);
|
|
306
338
|
}, 10);
|
|
307
339
|
changeWatcher.on("change", fastRebuild);
|
|
308
340
|
return void 0;
|
|
@@ -317,4 +349,4 @@ export {
|
|
|
317
349
|
pipe,
|
|
318
350
|
build2 as build
|
|
319
351
|
};
|
|
320
|
-
//# sourceMappingURL=chunk-
|
|
352
|
+
//# sourceMappingURL=chunk-CMEDJ4L4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build.ts","../src/utilities/helpers.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 { hfs } from \"@humanfs/node\";\nimport {\n createProjectGraphAsync,\n joinPathFragments,\n readProjectsConfigurationFromProjectGraph,\n writeJsonFile\n} from \"@nx/devkit\";\nimport {\n addPackageDependencies,\n addPackageJsonExport,\n addWorkspacePackageJsonFields,\n copyAssets\n} from \"@storm-software/build-tools\";\nimport {\n getStopwatch,\n loadStormConfig,\n writeDebug,\n writeError,\n writeFatal,\n writeSuccess,\n writeTrace,\n writeWarning\n} from \"@storm-software/config-tools\";\nimport { watch as createWatcher } from \"chokidar\";\nimport { debounce, flatten, omit } from \"es-toolkit\";\nimport { map } from \"es-toolkit/compat\";\nimport * as esbuild from \"esbuild\";\nimport { BuildContext } from \"esbuild\";\nimport { globbySync } from \"globby\";\nimport { findWorkspaceRoot } from \"nx/src/utils/find-workspace-root\";\nimport { DEFAULT_BUILD_OPTIONS } from \"./config\";\nimport { depsCheckPlugin } from \"./plugins/deps-check\";\nimport { esmSplitCodeToCjsPlugin } from \"./plugins/esm-split-code-to-cjs\";\nimport { fixImportsPlugin } from \"./plugins/fix-imports\";\nimport { onErrorPlugin } from \"./plugins/on-error\";\nimport { resolvePathsPlugin } from \"./plugins/resolve-paths\";\nimport { tscPlugin } from \"./plugins/tsc\";\nimport { ESBuildResolvedOptions, type ESBuildOptions } from \"./types\";\nimport { handle, pipe, transduce } from \"./utilities/helpers\";\n\n/**\n * Apply defaults to the original build options\n *\n * @param options - the original build options\n * @returns the build options with defaults applied\n */\nconst resolveOptions = async (\n options: ESBuildOptions\n): Promise<ESBuildResolvedOptions> => {\n const projectRoot = options.projectRoot;\n\n const workspaceRoot = findWorkspaceRoot(projectRoot);\n if (!workspaceRoot) {\n throw new Error(\"Cannot find Nx workspace root\");\n }\n\n const nxJsonPath = joinPathFragments(workspaceRoot.dir, \"nx.json\");\n if (!(await hfs.isFile(nxJsonPath))) {\n throw new Error(\"Cannot find Nx workspace configuration\");\n }\n\n const projectGraph = await createProjectGraphAsync({\n exitOnError: true\n });\n\n const projectJsonPath = joinPathFragments(\n workspaceRoot.dir,\n projectRoot,\n \"project.json\"\n );\n if (!(await hfs.isFile(projectJsonPath))) {\n throw new Error(\"Cannot find project.json configuration\");\n }\n\n const projectJson = await hfs.json(projectJsonPath);\n const projectName = projectJson.name;\n\n const projectConfigurations =\n readProjectsConfigurationFromProjectGraph(projectGraph);\n if (!projectConfigurations?.projects?.[projectName]) {\n throw new Error(\n \"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.\"\n );\n }\n\n const config = await loadStormConfig(workspaceRoot.dir);\n\n return {\n ...DEFAULT_BUILD_OPTIONS,\n config,\n format: \"cjs\",\n outExtension: { \".js\": \".js\" },\n resolveExtensions: [\".ts\", \".js\", \".node\"],\n mainFields: [\"module\", \"main\"],\n ...options,\n entryPoints: options.entryPoints || [\"./src/index.ts\"],\n outdir:\n options.outdir ||\n joinPathFragments(workspaceRoot.dir, \"dist\", projectRoot),\n plugins: [\n ...(options.plugins ?? []),\n resolvePathsPlugin,\n fixImportsPlugin,\n esmSplitCodeToCjsPlugin,\n tscPlugin(options.emitTypes),\n onErrorPlugin\n ],\n external: [...(options.external ?? [])],\n name: `${options.name || projectName}-${options.format || \"cjs\"}`,\n projectConfigurations,\n projectName,\n projectGraph,\n workspaceRoot,\n sourceRoot:\n options.sourceRoot ||\n joinPathFragments(workspaceRoot.dir, projectRoot, \"src\")\n };\n};\n\nconst generatePackageJson = async (options: ESBuildResolvedOptions) => {\n if (\n options.generatePackageJson !== false &&\n (await hfs.isFile(joinPathFragments(options.projectRoot, \"package.json\")))\n ) {\n writeDebug(\"✍️ Writing package.json file\", options.config);\n\n const packageJsonPath = joinPathFragments(\n options.projectRoot,\n \"project.json\"\n );\n if (!(await hfs.isFile(packageJsonPath))) {\n throw new Error(\"Cannot find package.json configuration\");\n }\n\n let packageJson = await hfs.json(\n joinPathFragments(\n options.workspaceRoot.dir,\n options.projectRoot,\n \"package.json\"\n )\n );\n if (!packageJson) {\n throw new Error(\"Cannot find package.json configuration file\");\n }\n\n packageJson = await addPackageDependencies(\n options.workspaceRoot.dir,\n options.projectRoot,\n options.projectName,\n packageJson\n );\n\n packageJson = await addWorkspacePackageJsonFields(\n options.config,\n options.projectRoot,\n options.sourceRoot,\n options.projectName,\n false,\n packageJson\n );\n\n let entryPoints = [{ in: \"./src/index.ts\", out: \"./src/index.ts\" }];\n if (options.entryPoints) {\n if (Array.isArray(options.entryPoints)) {\n entryPoints = (\n options.entryPoints as (string | { in: string; out: string })[]\n ).map(entryPoint =>\n typeof entryPoint === \"string\"\n ? { in: entryPoint, out: entryPoint }\n : entryPoint\n );\n } else {\n entryPoints = Object.entries(options.entryPoints).map(\n ([key, value]) => ({\n in: key,\n out: value\n })\n );\n }\n }\n\n for (const entryPoint of entryPoints) {\n const split = entryPoint.out.split(\".\");\n split.pop();\n const entry = split.join(\".\").replaceAll(\"\\\\\", \"/\");\n\n packageJson.exports[`./${entry}`] ??= addPackageJsonExport(entry);\n }\n\n packageJson.exports[\"./package.json\"] ??= \"./package.json\";\n packageJson.exports[\".\"] ??= addPackageJsonExport(\"./src/index.ts\");\n\n packageJson.main = \"./dist/index.cjs\";\n packageJson.module = \"./dist/index.js\";\n packageJson.types = \"./dist/index.d.ts\";\n\n await writeJsonFile(\n joinPathFragments(options.outdir, \"package.json\"),\n packageJson\n );\n }\n\n return options;\n};\n\n/**\n * Create two deferred builds for esm and cjs. The one follows the other:\n * - 1. The code gets compiled to an optimized tree-shaken esm output\n * - 2. We take that output and compile it to an optimized cjs output\n *\n * @param options - the original build options\n * @returns if options = [a, b], we get [a-esm, a-cjs, b-esm, b-cjs]\n */\nasync function createOptions(options: ESBuildOptions[]) {\n return flatten(\n await Promise.all(\n map(options, options => [\n // we defer it so that we don't trigger glob immediately\n () => resolveOptions(options)\n ])\n )\n );\n}\n\n/**\n * We only want to trigger the glob search once we are ready, and that is when\n * the previous build has finished. We get the build options from the deferred.\n */\nasync function computeOptions(\n options: () => Promise<ESBuildResolvedOptions>\n): Promise<ESBuildResolvedOptions> {\n return options();\n}\n\n// /**\n// * Extensions are not automatically by esbuild set for `options.outfile`. We\n// * look at the set `options.outExtension` and we add that to `options.outfile`.\n// */\n// function addExtensionFormat(options: ESBuildOptions) {\n// if (options.outfile && options.outExtension) {\n// const ext = options.outExtension[\".js\"];\n\n// options.outfile = `${options.outfile}${ext}`;\n// }\n\n// return options;\n// }\n\n// /**\n// * If we don't have `options.outfile`, we default `options.outdir`\n// */\n// function addDefaultOutDir(options: ESBuildOptions) {\n// if (options.outfile === undefined) {\n// options.outdir = getOutDir(options);\n// }\n\n// return options;\n// }\n\n/**\n * Execute esbuild with all the configurations we pass\n */\nasync function executeEsBuild(options: ESBuildResolvedOptions) {\n const stopwatch = getStopwatch(`${options.name} build`);\n\n if (process.env.WATCH === \"true\") {\n const context = await esbuild.context(\n omit(options, [\"name\", \"emitTypes\", \"emitMetafile\"]) as any\n );\n\n watch(context, options);\n }\n\n const result = await esbuild.build(\n omit(options, [\"name\", \"emitTypes\", \"emitMetafile\"]) as any\n );\n\n if (result.metafile && options.emitMetafile) {\n const metafilePath = `${options.outdir}/${options.name}.meta.json`;\n await hfs.write(metafilePath, JSON.stringify(result.metafile));\n }\n\n stopwatch();\n\n return [options, result] as const;\n}\n\n/**\n * Copy the assets to the build directory\n */\nasync function copyBuildAssets([options, result]: [\n ESBuildResolvedOptions,\n esbuild.BuildResult\n]) {\n if (result.errors.length === 0) {\n await copyAssets(\n options.config,\n options.assets ?? [],\n options.outdir,\n options.projectRoot,\n options.projectName,\n options.sourceRoot,\n true,\n false\n );\n }\n\n return [options, result] as const;\n}\n\n/**\n * Report the results of the build\n */\nasync function reportResults([options, result]: [\n ESBuildResolvedOptions,\n esbuild.BuildResult\n]) {\n if (result.errors.length === 0) {\n if (result.warnings.length > 0) {\n writeWarning(\n `The following warnings occurred during the build: ${result.warnings\n .map(warning => warning.text)\n .join(\"\\n\")}`,\n options.config\n );\n }\n\n writeSuccess(\n `The ${options.name} build completed successfully`,\n options.config\n );\n }\n}\n\n/**\n * A blank esbuild run to do an analysis of our deps\n */\nasync function dependencyCheck(options: ESBuildResolvedOptions) {\n // we only check our dependencies for a full build\n if (process.env.DEV === \"true\") return undefined;\n // Only run on test and publish pipelines on Buildkite\n // Meaning we skip on GitHub Actions\n // Because it's slow and runs for each job, during setup, making each job slower\n if (process.env.CI && !process.env.BUILDKITE) return undefined;\n\n // we need to bundle everything to do the analysis\n const buildPromise = esbuild.build({\n entryPoints: globbySync(\"**/*.{j,t}s\", {\n // We don't check dependencies in ecosystem tests because tests are isolated from the build.\n ignore: [\"./src/__tests__/**/*\", \"./tests/e2e/**/*\", \"./dist/**/*\"],\n gitignore: true\n }),\n logLevel: \"silent\", // there will be errors\n bundle: true, // we bundle to get everything\n write: false, // no need to write for analysis\n outdir: \"out\",\n plugins: [depsCheckPlugin(options.bundle)]\n });\n\n // we absolutely don't care if it has any errors\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n await buildPromise.catch(() => {});\n\n return undefined;\n}\n\n/**\n * Execution pipeline that applies a set of actions\n *\n * @param options - the build options\n * @returns the build result\n */\nexport async function build(options: ESBuildOptions[]) {\n const stopwatch = getStopwatch(\"full build\");\n\n try {\n void transduce.async(options, dependencyCheck);\n\n await transduce.async(\n await createOptions(options),\n pipe.async(\n computeOptions,\n generatePackageJson,\n executeEsBuild,\n copyBuildAssets,\n reportResults\n )\n );\n } catch (error) {\n writeFatal(\n \"Fatal errors occurred during the build that could not be recovered from. The build process has been terminated.\"\n );\n }\n\n stopwatch();\n}\n\n/**\n * Executes the build and rebuilds what is necessary\n *\n * @param context - the build context\n * @param options - the build options\n * @returns the build result\n */\nconst watch = (context: BuildContext, options: ESBuildResolvedOptions) => {\n if (process.env.WATCH !== \"true\") return context;\n\n // common chokidar options for the watchers\n const config = {\n ignoreInitial: true,\n useFsEvents: true,\n ignored: [\"./src/__tests__/**/*\", \"./package.json\"]\n };\n\n // prepare the incremental builds watcher\n const changeWatcher = createWatcher([\"./src/**/*\"], config);\n\n // triggers quick rebuild on file change\n const fastRebuild = debounce(async () => {\n const timeBefore = Date.now();\n\n // we handle possible rebuild exceptions\n const rebuildResult = await handle.async(() => {\n return context.rebuild();\n });\n\n if (rebuildResult instanceof Error) {\n writeError(rebuildResult.message);\n }\n\n writeTrace(`${Date.now() - timeBefore}ms [${options.name ?? \"\"}]`);\n }, 10);\n\n changeWatcher.on(\"change\", fastRebuild);\n\n return undefined;\n};\n\n// Utils ::::::::::::::::::::::::::::::::::::::::::::::::::\n\n// get the current project externals this helps to mark dependencies as external\n// by having convention in the package.json (dev = bundled, non-dev = external)\n// function getProjectExternals(options: ESBuildOptions) {\n// const pkg = require(`${process.cwd()}/package.json`);\n// const peerDeps = Object.keys(pkg.peerDependencies ?? {});\n// const regDeps = Object.keys(pkg.dependencies ?? {});\n\n// // when bundling, only the devDeps will be bundled\n// if (!process.env.IGNORE_EXTERNALS && options.bundle === true) {\n// return [...new Set([...peerDeps, ...regDeps])];\n// }\n\n// // otherwise, all the dependencies will be bundled\n// return [];\n// }\n","/*-------------------------------------------------------------------\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\nfunction handleSync<R, E = Error>(fn: () => R): R | E {\n try {\n return fn();\n } catch (error_: unknown) {\n return error_ as E;\n }\n}\n\nasync function handleAsync<R, E = Error>(\n fn: () => Promise<R> | R\n): Promise<R | E> {\n try {\n return await fn();\n } catch (error_: unknown) {\n return error_ as E;\n }\n}\n\n/**\n * Executes a function, catches exceptions, and returns any outcome.\n * @param fn - to be executed\n */\nconst handle = handleSync as typeof handleSync & {\n async: typeof handleAsync;\n};\n\nhandle.async = handleAsync;\n\nexport { handle };\n\nconst skip = Symbol(\"skip\");\n\ntype SyncTransformer<I, R> = (item: I, key: number) => R | typeof skip;\ntype ASyncTransformer<I, R> = (\n item: I,\n key: number\n) => Promise<R | typeof skip>;\n\nfunction transduceSync<I, R>(\n list: Array<I>,\n transformer: SyncTransformer<I, R>\n) {\n const transduced = [] as R[];\n\n for (const [i, element_] of list.entries()) {\n const transformed = transformer(element_, i);\n\n if (transformed !== skip) {\n transduced[transduced.length] = transformed;\n }\n }\n\n return transduced;\n}\n\nasync function transduceAsync<I, R>(\n list: Array<I>,\n transformer: ASyncTransformer<I, R>\n) {\n const transduced = [] as R[];\n\n await Promise.all(\n list.entries().map(async ([i, element_]) => {\n const transformed = await transformer(element_, i);\n\n if (transformed !== skip) {\n transduced[transduced.length] = transformed;\n }\n })\n );\n\n return transduced;\n}\n\nconst Filter =\n <I>(filter: (item: I) => boolean) =>\n (item: I) => {\n return filter(item) ? item : (skip as never);\n };\n\nconst Mapper =\n <I, R>(mapper: (item: I) => R) =>\n (item: I) => {\n return mapper(item);\n };\n\n/**\n * Transducers enable efficient data processing. They allow the composition of\n * mappers and filters to be applied on a list. And this is applied in a single\n * pass, that's the efficient pipeline processing.\n *\n * (does not reduce at the same time)\n *\n * @see https://medium.com/javascript-scene/7985330fe73d\n *\n * @param list - to transform\n * @param transformer - to apply\n\n * @example\n * ```ts\n * const filterEven = Filter(<U>(unit: U) =>\n * typeof unit === 'number' ? !(unit % 2) : true,\n * )\n * const mapTimes2 = Mapper(<U>(unit: U) =>\n * typeof unit === 'number' ? unit * 2 : unit,\n * )\n * const mapString = Mapper(<U>(unit: U) => `${unit}`)\n *\n * const test0 = transduce(\n * [1, 2, 3, 4, 5, 6, 7, 'a'],\n * pipe(filterEven, mapTimes2, mapTimes2, mapString, filterEven),\n * )\n * ```\n */\nconst transduce = transduceSync as typeof transduceSync & {\n async: typeof transduceAsync;\n};\n\ntransduce.async = transduceAsync;\n\nexport { Filter, Mapper, skip, transduce };\n\ntype FunctionLike<P extends Array<any> = any, R = any> = (...args: P) => R;\ntype Await<P> = P extends Promise<infer A> ? A : P;\n\nfunction pipeSync(fn: FunctionLike, ...fns: FunctionLike[]) {\n return (...args: unknown[]) => {\n let result = fn(...args);\n\n for (let i = 0; result !== skip && i < fns.length; ++i) {\n result = fns[i]?.(result);\n }\n\n return result;\n };\n}\n\nfunction pipeAsync(fn: FunctionLike, ...fns: FunctionLike[]) {\n return async (...args: unknown[]) => {\n let result = await fn(...args);\n\n for (let i = 0; result !== skip && i < fns.length; ++i) {\n // eslint-disable-next-line no-await-in-loop\n result = await fns[i]?.(result);\n }\n\n return result;\n };\n}\n\n/**\n * Pipe the input and output of functions.\n *\n * @param fn - parameter-taking function\n * @param fns - subsequent piped functions\n * @returns\n */\nconst pipe = pipeSync as PipeMultiSync & {\n async: PipeMultiAsync;\n};\n\npipe.async = pipeAsync;\n\n// TODO: use the one from ts-toolbelt (broken atm since ts 4.1)\nexport declare type PipeMultiSync = {\n <R0, P extends any[]>(...fns: [FunctionLike<P, R0>]): FunctionLike<P, R0>;\n <R0, R1, P extends any[]>(\n ...fns: [FunctionLike<P, R0>, FunctionLike<[R0], R1>]\n ): FunctionLike<P, R1>;\n <R0, R1, R2, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>\n ]\n ): FunctionLike<P, R2>;\n <R0, R1, R2, R3, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>\n ]\n ): FunctionLike<P, R3>;\n <R0, R1, R2, R3, R4, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>\n ]\n ): FunctionLike<P, R4>;\n <R0, R1, R2, R3, R4, R5, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>\n ]\n ): FunctionLike<P, R5>;\n <R0, R1, R2, R3, R4, R5, R6, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>\n ]\n ): FunctionLike<P, R6>;\n <R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>\n ]\n ): FunctionLike<P, R7>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>,\n FunctionLike<[R7], R8>\n ]\n ): FunctionLike<P, R8>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[R0], R1>,\n FunctionLike<[R1], R2>,\n FunctionLike<[R2], R3>,\n FunctionLike<[R3], R4>,\n FunctionLike<[R4], R5>,\n FunctionLike<[R5], R6>,\n FunctionLike<[R6], R7>,\n FunctionLike<[R7], R8>,\n FunctionLike<[R8], R9>\n ]\n ): FunctionLike<P, R9>;\n};\n\nexport declare type PipeMultiAsync = {\n <R0, P extends any[]>(\n ...fns: [FunctionLike<P, R0>]\n ): FunctionLike<P, Promise<Await<R0>>>;\n <R0, R1, P extends any[]>(\n ...fns: [FunctionLike<P, R0>, FunctionLike<[Await<R0>], R1>]\n ): FunctionLike<P, Promise<Await<R1>>>;\n <R0, R1, R2, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>\n ]\n ): FunctionLike<P, Promise<Await<R2>>>;\n <R0, R1, R2, R3, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>\n ]\n ): FunctionLike<P, Promise<Await<R3>>>;\n <R0, R1, R2, R3, R4, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>\n ]\n ): FunctionLike<P, Promise<Await<R4>>>;\n <R0, R1, R2, R3, R4, R5, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>\n ]\n ): FunctionLike<P, Promise<Await<R5>>>;\n <R0, R1, R2, R3, R4, R5, R6, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>\n ]\n ): FunctionLike<P, Promise<Await<R6>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>\n ]\n ): FunctionLike<P, Promise<Await<R7>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>,\n FunctionLike<[Await<R7>], R8>\n ]\n ): FunctionLike<P, Promise<Await<R8>>>;\n <R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, P extends any[]>(\n ...fns: [\n FunctionLike<P, R0>,\n FunctionLike<[Await<R0>], R1>,\n FunctionLike<[Await<R1>], R2>,\n FunctionLike<[Await<R2>], R3>,\n FunctionLike<[Await<R3>], R4>,\n FunctionLike<[Await<R4>], R5>,\n FunctionLike<[Await<R5>], R6>,\n FunctionLike<[Await<R6>], R7>,\n FunctionLike<[Await<R7>], R8>,\n FunctionLike<[Await<R8>], R9>\n ]\n ): FunctionLike<P, Promise<Await<R9>>>;\n};\n\nexport { pipe };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAASA,WAAW;AACpB,SACEC,yBACAC,mBACAC,2CACAC,qBACK;AACP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C,KAAKC,IAAG;AAG3B,UAAMC,gBAAgB,MAAMC,OAAOf,MAAM,MAAA;AACvC,aAAOpC,SAAQoD,QAAO;IACxB,CAAA;AAEA,QAAIF,yBAAyB3H,OAAO;AAClC8H,iBAAWH,cAAcI,OAAO;IAClC;AAEAC,eAAW,GAAGP,KAAKC,IAAG,IAAKF,UAAAA,OAAiB5H,QAAQiB,QAAQ,EAAA,GAAK;EACnE,GAAG,EAAA;AAEHuG,gBAAca,GAAG,UAAUX,WAAAA;AAE3B,SAAOrB;AACT,GAhCc;","names":["hfs","createProjectGraphAsync","joinPathFragments","readProjectsConfigurationFromProjectGraph","writeJsonFile","addPackageDependencies","addPackageJsonExport","addWorkspacePackageJsonFields","copyAssets","getStopwatch","loadStormConfig","writeDebug","writeError","writeFatal","writeSuccess","writeTrace","writeWarning","watch","createWatcher","debounce","flatten","omit","map","esbuild","globbySync","findWorkspaceRoot","handleSync","fn","error_","handleAsync","handle","async","skip","Symbol","transduceSync","list","transformer","transduced","i","element_","entries","transformed","length","transduceAsync","Promise","all","map","Filter","filter","item","Mapper","mapper","transduce","async","pipeSync","fn","fns","args","result","i","skip","length","pipeAsync","pipe","async","resolveOptions","options","projectRoot","workspaceRoot","findWorkspaceRoot","Error","nxJsonPath","joinPathFragments","dir","hfs","isFile","projectGraph","createProjectGraphAsync","exitOnError","projectJsonPath","projectJson","json","projectName","name","projectConfigurations","readProjectsConfigurationFromProjectGraph","projects","config","loadStormConfig","DEFAULT_BUILD_OPTIONS","format","outExtension","resolveExtensions","mainFields","entryPoints","outdir","plugins","resolvePathsPlugin","fixImportsPlugin","esmSplitCodeToCjsPlugin","tscPlugin","emitTypes","onErrorPlugin","external","sourceRoot","generatePackageJson","writeDebug","packageJsonPath","packageJson","addPackageDependencies","addWorkspacePackageJsonFields","in","out","Array","isArray","map","entryPoint","Object","entries","key","value","split","pop","entry","join","replaceAll","exports","addPackageJsonExport","main","module","types","writeJsonFile","createOptions","flatten","Promise","all","computeOptions","executeEsBuild","stopwatch","getStopwatch","process","env","WATCH","context","omit","watch","result","build","metafile","emitMetafile","metafilePath","write","JSON","stringify","copyBuildAssets","errors","length","copyAssets","assets","reportResults","warnings","writeWarning","warning","text","writeSuccess","dependencyCheck","DEV","undefined","CI","BUILDKITE","buildPromise","globbySync","ignore","gitignore","logLevel","bundle","depsCheckPlugin","catch","transduce","async","pipe","error","writeFatal","ignoreInitial","useFsEvents","ignored","changeWatcher","createWatcher","fastRebuild","debounce","timeBefore","Date","now","rebuildResult","handle","rebuild","writeError","message","writeTrace","on"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
writeLog
|
|
3
|
-
} from "./chunk-ZQ5NVDFP.js";
|
|
4
1
|
import {
|
|
5
2
|
__name,
|
|
6
3
|
__require
|
|
7
4
|
} from "./chunk-WCQVDF3K.js";
|
|
8
5
|
|
|
9
6
|
// src/plugins/deps-check.ts
|
|
7
|
+
import { writeError, writeWarning } from "@storm-software/config-tools";
|
|
10
8
|
import { builtinModules } from "node:module";
|
|
11
9
|
import path from "node:path";
|
|
12
10
|
var unusedIgnore = [
|
|
@@ -85,8 +83,8 @@ var depsCheckPlugin = /* @__PURE__ */ __name((bundle) => ({
|
|
|
85
83
|
const filteredMissingDeps = missingDependencies.filter((dep) => {
|
|
86
84
|
return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep);
|
|
87
85
|
});
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
writeWarning(`Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`);
|
|
87
|
+
writeError(`Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`);
|
|
90
88
|
if (filteredMissingDeps.length > 0) {
|
|
91
89
|
throw new Error(`Missing dependencies detected - please install them:
|
|
92
90
|
${JSON.stringify(filteredMissingDeps)}
|
|
@@ -99,4 +97,4 @@ ${JSON.stringify(filteredMissingDeps)}
|
|
|
99
97
|
export {
|
|
100
98
|
depsCheckPlugin
|
|
101
99
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
100
|
+
//# sourceMappingURL=chunk-CMWXE5MF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/deps-check.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 { writeError, writeWarning } from \"@storm-software/config-tools\";\nimport type * as esbuild from \"esbuild\";\nimport { builtinModules } from \"node:module\";\nimport path from \"node:path\";\n\n// packages that aren't detected but used\n// TODO: these could be scoped at the root\nconst unusedIgnore = [\n // these are our dev dependencies\n /@types\\/.*?/,\n /@typescript-eslint.*?/,\n /eslint.*?/,\n \"esbuild\",\n \"husky\",\n \"is-ci\",\n \"lint-staged\",\n \"prettier\",\n \"typescript\",\n \"ts-node\",\n \"ts-jest\",\n \"@swc/core\",\n \"@swc/jest\",\n \"jest\",\n\n // these are missing 3rd party deps\n \"spdx-exceptions\",\n \"spdx-license-ids\",\n\n // type-only, so it is not detected\n \"ts-toolbelt\",\n\n // these are indirectly used by build\n \"buffer\"\n];\n\n// packages that aren't missing but are detected\nconst missingIgnore = [\".prisma\", \"@prisma/client\", \"ts-toolbelt\"];\n\n/**\n * Checks for unused and missing dependencies.\n */\nexport const depsCheckPlugin = (bundle?: boolean): esbuild.Plugin => ({\n name: \"storm:deps-check\",\n setup(build) {\n // we load the package.json of the project do do our analysis\n const pkgJsonPath = path.join(process.cwd(), \"package.json\");\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkgContents = require(pkgJsonPath) as Record<string, object>;\n const regDependencies = Object.keys(pkgContents[\"dependencies\"] ?? {});\n const devDependencies = Object.keys(pkgContents[\"devDependencies\"] ?? {});\n const peerDependencies = Object.keys(pkgContents[\"peerDependencies\"] ?? {});\n const dependencies = [\n ...regDependencies,\n ...(bundle ? devDependencies : [])\n ];\n\n // we prepare to collect dependencies that are only packages\n const collectedDependencies = new Set<string>();\n const onlyPackages = /^[^./](?!:)|^\\.[^./]|^\\.\\.[^/]/;\n build.onResolve({ filter: onlyPackages }, args => {\n // we limit this search to the parent folder, don't go back\n if (args.importer.includes(process.cwd())) {\n // handle cases where there is extra path @org/pkg/folder\n if (args.path[0] === \"@\") {\n // we have a package that lives in org's scope, trim it\n const [org, pkg] = args.path.split(\"/\");\n collectedDependencies.add(`${org}/${pkg}`);\n } else {\n // we have a regular package without scope, we trim it\n const [pkg] = args.path.split(\"/\");\n collectedDependencies.add(pkg!);\n }\n }\n\n return { external: true }; // we don't care for the bundling\n });\n\n build.onEnd(() => {\n // we take all the dependencies that aren't collected and are native\n const unusedDependencies = [...dependencies].filter(dep => {\n return !collectedDependencies.has(dep) || builtinModules.includes(dep);\n });\n\n // we take all the collected deps that aren't deps and aren't native\n const missingDependencies = [...collectedDependencies].filter(dep => {\n return !dependencies.includes(dep) && !builtinModules.includes(dep);\n });\n\n // we exclude the deps that match our unusedIgnore patterns\n const filteredUnusedDeps = unusedDependencies.filter(dep => {\n return !unusedIgnore.some(pattern => dep.match(pattern));\n });\n\n // we exclude the deps that match our unusedIgnore patterns\n const filteredMissingDeps = missingDependencies.filter(dep => {\n return (\n !missingIgnore.some(pattern => dep.match(pattern)) &&\n !peerDependencies.includes(dep)\n );\n });\n\n writeWarning(\n `Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`\n );\n writeError(\n `Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`\n );\n\n if (filteredMissingDeps.length > 0) {\n throw new Error(`Missing dependencies detected - please install them:\n${JSON.stringify(filteredMissingDeps)}\n`);\n }\n });\n }\n});\n"],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AEV,YAAMC,qBAAqB;WAAIf;QAAcK,OAAOW,CAAAA,QAAAA;AAClD,eAAO,CAACf,sBAAsBgB,IAAID,GAAAA,KAAQE,eAAeV,SAASQ,GAAAA;MACpE,CAAA;AAGA,YAAMG,sBAAsB;WAAIlB;QAAuBI,OAAOW,CAAAA,QAAAA;AAC5D,eAAO,CAAChB,aAAaQ,SAASQ,GAAAA,KAAQ,CAACE,eAAeV,SAASQ,GAAAA;MACjE,CAAA;AAGA,YAAMI,qBAAqBL,mBAAmBV,OAAOW,CAAAA,QAAAA;AACnD,eAAO,CAACnC,aAAawC,KAAKC,CAAAA,YAAWN,IAAIO,MAAMD,OAAAA,CAAAA;MACjD,CAAA;AAGA,YAAME,sBAAsBL,oBAAoBd,OAAOW,CAAAA,QAAAA;AACrD,eACE,CAAClC,cAAcuC,KAAKC,CAAAA,YAAWN,IAAIO,MAAMD,OAAAA,CAAAA,KACzC,CAACvB,iBAAiBS,SAASQ,GAAAA;MAE/B,CAAA;AAEAS,mBACE,wBAAwBC,KAAKC,UAAUP,kBAAAA,CAAAA,EAAqB;AAE9DQ,iBACE,yBAAyBF,KAAKC,UAAUH,mBAAAA,CAAAA,EAAsB;AAGhE,UAAIA,oBAAoBK,SAAS,GAAG;AAClC,cAAM,IAAIC,MAAM;EACtBJ,KAAKC,UAAUH,mBAAAA,CAAAA;CAChB;MACK;IACF,CAAA;EACF;AACF,IA1E+B;","names":["writeError","writeWarning","builtinModules","path","unusedIgnore","missingIgnore","depsCheckPlugin","bundle","name","setup","build","pkgJsonPath","path","join","process","cwd","pkgContents","require","regDependencies","Object","keys","devDependencies","peerDependencies","dependencies","collectedDependencies","Set","onlyPackages","onResolve","filter","args","importer","includes","org","pkg","split","add","external","onEnd","unusedDependencies","dep","has","builtinModules","missingDependencies","filteredUnusedDeps","some","pattern","match","filteredMissingDeps","writeWarning","JSON","stringify","writeError","length","Error"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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; }// src/plugins/esm-split-code-to-cjs.ts
|
|
2
|
+
var _esbuild = require('esbuild'); var esbuild = _interopRequireWildcard(_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(_nullishCoalesce(_optionalChain([result, 'access', _ => _.metafile, 'optionalAccess', _2 => _2.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
|
+
|
|
22
|
+
|
|
23
|
+
exports.esmSplitCodeToCjsPlugin = esmSplitCodeToCjsPlugin;
|
|
24
|
+
//# sourceMappingURL=chunk-J34FQYKV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-J34FQYKV.cjs","../src/plugins/esm-split-code-to-cjs.ts"],"names":["esmSplitCodeToCjsPlugin","name","setup","build","onEnd","result","outFiles","Object","keys","metafile","outputs","jsFiles","filter","f","endsWith","outdir","initialOptions","entryPoints","allowOverwrite","format","logLevel","packages"],"mappings":"AAAA;ACiBA,mFAAyB;AAMlB,IAAMA,wBAAAA,EAA0C;ADpBvD,ECqBEC,IAAAA,EAAM,6BAAA;ADpBR,ECqBEC,KAAAA,CAAMC,MAAAA,EAAK;AACTA,IAAAA,MAAAA,CAAMC,KAAAA,CAAM,MAAA,CAAMC,MAAAA,EAAAA,GAAAA;AAChB,MAAA,MAAMC,SAAAA,EAAWC,MAAAA,CAAOC,IAAAA,kCAAKH,MAAAA,mBAAOI,QAAAA,6BAAUC,SAAAA,UAAW,CAAC,GAAA,CAAA;AAC1D,MAAA,MAAMC,QAAAA,EAAUL,QAAAA,CAASM,MAAAA,CAAOC,CAAAA,CAAAA,EAAAA,GAAKA,CAAAA,CAAEC,QAAAA,CAAS,IAAA,CAAA,CAAA;AAEhD,MAAA,MAAcX,OAAAA,CAAAA,KAAAA,CAAM;ADrB1B,QCsBQY,MAAAA,EAAQZ,MAAAA,CAAMa,cAAAA,CAAeD,MAAAA;ADrBrC,QCsBQE,WAAAA,EAAaN,OAAAA;ADrBrB,QCsBQO,cAAAA,EAAgB,IAAA;ADrBxB,QCsBQC,MAAAA,EAAQ,KAAA;ADrBhB,QCsBQC,QAAAA,EAAU,OAAA;ADrBlB,QCsBQC,QAAAA,EAAU;ADrBlB,MCsBM,CAAA,CAAA;ADrBN,ICsBI,CAAA,CAAA;ADrBJ,ECsBE;AACF,CAAA;ADrBA;AACA;AACE;AACF,0DAAC","file":"/home/runner/work/storm-ops/storm-ops/packages/esbuild/dist/chunk-J34FQYKV.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 * 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"]}
|