@storm-software/cloudflare-tools 0.71.228 → 0.71.232
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/CHANGELOG.md +52 -0
- package/README.md +1 -1
- package/dist/{chunk-BNDZQ5HW.mjs → chunk-25R2FOVY.mjs} +2 -2
- package/dist/{chunk-WWFVS2ZA.mjs → chunk-3YYDX3BD.mjs} +2 -2
- package/dist/{chunk-HNG7IGJA.js → chunk-CDNW3MSR.js} +1 -1
- package/dist/{chunk-JOAXEOFI.mjs → chunk-FYFU3RR3.mjs} +435 -829
- package/dist/{chunk-MLWWR6XQ.js → chunk-HB4NFY6P.js} +2 -2
- package/dist/{chunk-5H4QGC4P.mjs → chunk-IW423EUR.mjs} +1 -1
- package/dist/{chunk-5ISL3L4A.js → chunk-NONOZEPD.js} +2 -2
- package/dist/{chunk-R2PRPZWR.js → chunk-P7Q2HVL4.js} +1 -1
- package/dist/{chunk-B7UW2BLF.mjs → chunk-T3EHTZK6.mjs} +2 -2
- package/dist/{chunk-4MIUPZ4C.js → chunk-TXSHBEGN.js} +388 -782
- package/dist/{chunk-62VEZ3M7.mjs → chunk-VYO5EAVN.mjs} +1 -1
- package/dist/{chunk-AZGMVNDA.mjs → chunk-YZQ56DII.mjs} +2 -2
- package/dist/executors.js +1 -1
- package/dist/executors.mjs +3 -3
- package/dist/generators.js +3 -3
- package/dist/generators.mjs +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/dist/src/executors/cloudflare-publish/executor.js +1 -1
- package/dist/src/executors/cloudflare-publish/executor.mjs +3 -3
- package/dist/src/executors/r2-upload-publish/executor.mjs +1 -1
- package/dist/src/executors/r2-upload-publish/untyped.mjs +1 -1
- package/dist/src/executors/serve/executor.d.mts +1 -1
- package/dist/src/executors/serve/executor.d.ts +1 -1
- package/dist/src/executors/serve/executor.js +2 -2
- package/dist/src/executors/serve/executor.mjs +2 -2
- package/dist/src/executors/serve/schema.d.ts +1 -1
- package/dist/src/generators/init/generator.js +2 -2
- package/dist/src/generators/init/generator.mjs +2 -2
- package/dist/src/generators/worker/generator.js +3 -3
- package/dist/src/generators/worker/generator.mjs +3 -3
- package/dist/src/plugins/index.mjs +1 -1
- package/dist/src/utils/http-handler.mjs +1 -1
- package/dist/src/utils/index.mjs +1 -1
- package/dist/src/utils/r2-bucket-helpers.mjs +1 -1
- package/package.json +5 -5
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "./chunk-K4H5ZMYA.mjs";
|
|
31
31
|
import {
|
|
32
32
|
__dirname
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-IW423EUR.mjs";
|
|
34
34
|
|
|
35
35
|
// ../config-tools/src/utilities/apply-workspace-tokens.ts
|
|
36
36
|
var applyWorkspaceBaseTokens = async (option, tokenParams) => {
|
|
@@ -473,17 +473,249 @@ import { readFileSync as readFileSync2 } from "node:fs";
|
|
|
473
473
|
import https from "node:https";
|
|
474
474
|
var LARGE_BUFFER = 1024 * 1e6;
|
|
475
475
|
|
|
476
|
+
// ../workspace-tools/src/executors/esbuild/executor.ts
|
|
477
|
+
import { createJiti } from "jiti";
|
|
478
|
+
async function esbuildExecutorFn(options, context, config) {
|
|
479
|
+
writeInfo("\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
|
|
480
|
+
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
481
|
+
throw new Error(
|
|
482
|
+
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
const jiti = createJiti(config?.workspaceRoot || process.cwd(), {
|
|
486
|
+
fsCache: config?.skipCache ? false : joinPaths(
|
|
487
|
+
config?.workspaceRoot || process.cwd(),
|
|
488
|
+
config?.directories?.cache || "node_modules/.cache/storm",
|
|
489
|
+
"jiti"
|
|
490
|
+
),
|
|
491
|
+
interopDefault: true
|
|
492
|
+
});
|
|
493
|
+
const { build: build2 } = await jiti.import(jiti.esmResolve("@storm-software/esbuild"));
|
|
494
|
+
await build2({
|
|
495
|
+
...options,
|
|
496
|
+
projectRoot: (
|
|
497
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
498
|
+
context.projectsConfigurations.projects?.[context.projectName].root
|
|
499
|
+
),
|
|
500
|
+
name: context.projectName,
|
|
501
|
+
sourceRoot: context.projectsConfigurations.projects?.[context.projectName]?.sourceRoot,
|
|
502
|
+
format: options.format,
|
|
503
|
+
platform: options.platform
|
|
504
|
+
});
|
|
505
|
+
return {
|
|
506
|
+
success: true
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
var executor_default6 = withRunExecutor(
|
|
510
|
+
"Storm ESBuild build",
|
|
511
|
+
esbuildExecutorFn,
|
|
512
|
+
{
|
|
513
|
+
skipReadingConfig: false,
|
|
514
|
+
hooks: {
|
|
515
|
+
applyDefaultOptions: async (options) => {
|
|
516
|
+
options.entry ??= ["src/index.ts"];
|
|
517
|
+
options.outputPath ??= "dist/{projectRoot}";
|
|
518
|
+
options.tsconfig ??= "{projectRoot}/tsconfig.json";
|
|
519
|
+
return options;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
// ../workspace-tools/src/executors/napi/executor.ts
|
|
526
|
+
import { createJiti as createJiti2 } from "jiti";
|
|
527
|
+
import { fileExists } from "nx/src/utils/fileutils";
|
|
528
|
+
async function napiExecutor(options, context, config) {
|
|
529
|
+
const jiti = createJiti2(config.workspaceRoot, {
|
|
530
|
+
fsCache: config.skipCache ? false : joinPaths(
|
|
531
|
+
config.workspaceRoot,
|
|
532
|
+
config.directories.cache || "node_modules/.cache/storm",
|
|
533
|
+
"jiti"
|
|
534
|
+
),
|
|
535
|
+
interopDefault: true
|
|
536
|
+
});
|
|
537
|
+
const { NapiCli } = await jiti.import(
|
|
538
|
+
jiti.esmResolve("@napi-rs/cli")
|
|
539
|
+
);
|
|
540
|
+
if (!context.projectGraph?.nodes[context.projectName ?? ""]) {
|
|
541
|
+
throw new Error(
|
|
542
|
+
"The Napi Build process failed because the project could not be found in the project graph. Please run this command from a workspace root directory."
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
const projectRoot = context.projectGraph?.nodes[context.projectName ?? ""]?.data.root;
|
|
546
|
+
const packageJson = joinPaths(projectRoot ?? ".", "package.json");
|
|
547
|
+
if (!fileExists(packageJson)) {
|
|
548
|
+
throw new Error(`Could not find package.json at ${packageJson}`);
|
|
549
|
+
}
|
|
550
|
+
const napi = new NapiCli();
|
|
551
|
+
const normalizedOptions = { ...options };
|
|
552
|
+
const metadata = cargoMetadata();
|
|
553
|
+
normalizedOptions.targetDir = options.targetDir || metadata?.target_directory || joinPaths(config.workspaceRoot, "dist", "target");
|
|
554
|
+
normalizedOptions.outputDir = options.outputPath;
|
|
555
|
+
normalizedOptions.packageJsonPath ??= packageJson;
|
|
556
|
+
if (options.cwd) {
|
|
557
|
+
normalizedOptions.cwd = correctPaths(options.cwd);
|
|
558
|
+
} else {
|
|
559
|
+
const absoluteProjectRoot = correctPaths(
|
|
560
|
+
joinPaths(config.workspaceRoot, projectRoot || ".")
|
|
561
|
+
);
|
|
562
|
+
normalizedOptions.cwd = absoluteProjectRoot;
|
|
563
|
+
if (normalizedOptions.outputDir) {
|
|
564
|
+
normalizedOptions.outputDir = relative(
|
|
565
|
+
normalizedOptions.cwd,
|
|
566
|
+
correctPaths(
|
|
567
|
+
isAbsolute(normalizedOptions.outputDir) ? normalizedOptions.outputDir : joinPaths(config.workspaceRoot, normalizedOptions.outputDir)
|
|
568
|
+
)
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
if (normalizedOptions.packageJsonPath) {
|
|
572
|
+
normalizedOptions.packageJsonPath = relative(
|
|
573
|
+
normalizedOptions.cwd,
|
|
574
|
+
correctPaths(
|
|
575
|
+
isAbsolute(normalizedOptions.packageJsonPath) ? normalizedOptions.packageJsonPath : joinPaths(config.workspaceRoot, normalizedOptions.packageJsonPath)
|
|
576
|
+
)
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
if (normalizedOptions.configPath) {
|
|
580
|
+
normalizedOptions.configPath = relative(
|
|
581
|
+
normalizedOptions.cwd,
|
|
582
|
+
correctPaths(
|
|
583
|
+
isAbsolute(normalizedOptions.configPath) ? normalizedOptions.configPath : joinPaths(config.workspaceRoot, normalizedOptions.configPath)
|
|
584
|
+
)
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
if (normalizedOptions.manifestPath) {
|
|
588
|
+
normalizedOptions.manifestPath = relative(
|
|
589
|
+
normalizedOptions.cwd,
|
|
590
|
+
correctPaths(
|
|
591
|
+
isAbsolute(normalizedOptions.manifestPath) ? normalizedOptions.manifestPath : joinPaths(config.workspaceRoot, normalizedOptions.manifestPath)
|
|
592
|
+
)
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
if (process.env.VERCEL) {
|
|
597
|
+
return { success: true };
|
|
598
|
+
}
|
|
599
|
+
writeDebug(
|
|
600
|
+
`Normalized Napi Options:
|
|
601
|
+
packageJsonPath: ${normalizedOptions.packageJsonPath}
|
|
602
|
+
outputDir: ${normalizedOptions.outputDir}
|
|
603
|
+
targetDir: ${normalizedOptions.targetDir}
|
|
604
|
+
manifestPath: ${normalizedOptions.manifestPath}
|
|
605
|
+
configPath: ${normalizedOptions.configPath}
|
|
606
|
+
cwd: ${normalizedOptions.cwd}`,
|
|
607
|
+
config
|
|
608
|
+
);
|
|
609
|
+
const { task } = await napi.build(normalizedOptions);
|
|
610
|
+
return { success: true, terminalOutput: await task };
|
|
611
|
+
}
|
|
612
|
+
var executor_default7 = withRunExecutor(
|
|
613
|
+
"Napi - Build Bindings",
|
|
614
|
+
napiExecutor,
|
|
615
|
+
{
|
|
616
|
+
skipReadingConfig: false,
|
|
617
|
+
hooks: {
|
|
618
|
+
applyDefaultOptions: (options) => {
|
|
619
|
+
options.outputPath ??= "{sourceRoot}";
|
|
620
|
+
options.toolchain ??= "stable";
|
|
621
|
+
options.dtsCache ??= true;
|
|
622
|
+
options.platform ??= true;
|
|
623
|
+
options.constEnum ??= false;
|
|
624
|
+
options.verbose ??= false;
|
|
625
|
+
options.jsBinding ??= "binding.js";
|
|
626
|
+
options.dts ??= "binding.d.ts";
|
|
627
|
+
return options;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
// ../npm-tools/src/helpers/get-version.ts
|
|
634
|
+
import { exec as exec2 } from "node:child_process";
|
|
635
|
+
import { valid } from "semver";
|
|
636
|
+
import stripAnsi from "strip-ansi";
|
|
637
|
+
|
|
638
|
+
// ../npm-tools/src/helpers/get-registry.ts
|
|
639
|
+
import { exec } from "node:child_process";
|
|
640
|
+
|
|
641
|
+
// ../pnpm-tools/src/helpers/catalog.ts
|
|
642
|
+
import { coerce, gt, valid as valid2 } from "semver";
|
|
643
|
+
|
|
644
|
+
// ../pnpm-tools/src/helpers/pnpm-workspace.ts
|
|
645
|
+
import { existsSync } from "node:fs";
|
|
646
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
647
|
+
import { parse, stringify } from "yaml";
|
|
648
|
+
|
|
649
|
+
// ../pnpm-tools/src/helpers/replace-deps-aliases.ts
|
|
650
|
+
import {
|
|
651
|
+
createProjectGraphAsync,
|
|
652
|
+
readCachedProjectGraph
|
|
653
|
+
} from "@nx/devkit";
|
|
654
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
655
|
+
import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
656
|
+
import { format } from "prettier";
|
|
657
|
+
|
|
658
|
+
// ../workspace-tools/src/executors/npm-publish/executor.ts
|
|
659
|
+
import { createJiti as createJiti4 } from "jiti";
|
|
660
|
+
import { execSync as execSync3 } from "node:child_process";
|
|
661
|
+
import { readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
|
|
662
|
+
import { format as format2 } from "prettier";
|
|
663
|
+
|
|
664
|
+
// ../workspace-tools/src/utils/github.ts
|
|
665
|
+
import { createJiti as createJiti3 } from "jiti";
|
|
666
|
+
|
|
667
|
+
// ../workspace-tools/src/executors/npm-publish/executor.ts
|
|
668
|
+
var LARGE_BUFFER2 = 1024 * 1e6;
|
|
669
|
+
|
|
670
|
+
// ../workspace-tools/src/executors/size-limit/executor.ts
|
|
671
|
+
import { joinPathFragments as joinPathFragments3 } from "@nx/devkit";
|
|
672
|
+
import esBuildPlugin from "@size-limit/esbuild";
|
|
673
|
+
import esBuildWhyPlugin from "@size-limit/esbuild-why";
|
|
674
|
+
import filePlugin from "@size-limit/file";
|
|
675
|
+
import sizeLimit from "size-limit";
|
|
676
|
+
async function sizeLimitExecutorFn(options, context, config) {
|
|
677
|
+
if (!context?.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName]) {
|
|
678
|
+
throw new Error(
|
|
679
|
+
"The Size-Limit process failed because the context is not valid. Please run this command from a workspace."
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
writeInfo(`\u{1F4CF} Running Size-Limit on ${context.projectName}`, config);
|
|
683
|
+
sizeLimit([filePlugin, esBuildPlugin, esBuildWhyPlugin], {
|
|
684
|
+
checks: options.entry ?? context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? joinPathFragments3(
|
|
685
|
+
context.projectsConfigurations.projects[context.projectName]?.root ?? "./",
|
|
686
|
+
"src"
|
|
687
|
+
)
|
|
688
|
+
}).then((result) => {
|
|
689
|
+
writeInfo(
|
|
690
|
+
`\u{1F4CF} ${context.projectName} Size-Limit result: ${JSON.stringify(result)}`,
|
|
691
|
+
config
|
|
692
|
+
);
|
|
693
|
+
});
|
|
694
|
+
return {
|
|
695
|
+
success: true
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
var executor_default8 = withRunExecutor(
|
|
699
|
+
"Size-Limit Performance Test Executor",
|
|
700
|
+
sizeLimitExecutorFn,
|
|
701
|
+
{
|
|
702
|
+
skipReadingConfig: false,
|
|
703
|
+
hooks: {
|
|
704
|
+
applyDefaultOptions: (options) => {
|
|
705
|
+
return options;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
|
|
711
|
+
// ../tsdown/src/build.ts
|
|
712
|
+
import {
|
|
713
|
+
createProjectGraphAsync as createProjectGraphAsync3,
|
|
714
|
+
readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2,
|
|
715
|
+
writeJsonFile
|
|
716
|
+
} from "@nx/devkit";
|
|
717
|
+
|
|
476
718
|
// ../build-tools/src/config.ts
|
|
477
|
-
var DEFAULT_JS_BANNER = `
|
|
478
|
-
// ---------------------------------------
|
|
479
|
-
// \u{1F5F2} Built by Storm Software
|
|
480
|
-
// ---------------------------------------
|
|
481
|
-
`;
|
|
482
|
-
var DEFAULT_CSS_BANNER = `
|
|
483
|
-
/* ---------------------------------------
|
|
484
|
-
\u{1F5F2} Built by Storm Software
|
|
485
|
-
--------------------------------------- */
|
|
486
|
-
`;
|
|
487
719
|
var DEFAULT_ENVIRONMENT = "production";
|
|
488
720
|
var DEFAULT_TARGET = "esnext";
|
|
489
721
|
var DEFAULT_ORGANIZATION = "storm-software";
|
|
@@ -504,8 +736,8 @@ import { relative as relative3 } from "path";
|
|
|
504
736
|
// ../build-tools/src/utilities/copy-assets.ts
|
|
505
737
|
import { CopyAssetsHandler } from "@nx/js/internal";
|
|
506
738
|
import { glob } from "glob";
|
|
507
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
508
|
-
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot,
|
|
739
|
+
import { readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
|
|
740
|
+
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
509
741
|
const pendingAssets = Array.from(assets ?? []);
|
|
510
742
|
pendingAssets.push({
|
|
511
743
|
input: projectRoot,
|
|
@@ -517,7 +749,7 @@ var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, gen
|
|
|
517
749
|
glob: "LICENSE",
|
|
518
750
|
output: "."
|
|
519
751
|
});
|
|
520
|
-
if (
|
|
752
|
+
if (generatePackageJson2 === false) {
|
|
521
753
|
pendingAssets.push({
|
|
522
754
|
input: projectRoot,
|
|
523
755
|
glob: "package.json",
|
|
@@ -560,11 +792,11 @@ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${p
|
|
|
560
792
|
]);
|
|
561
793
|
await Promise.allSettled(
|
|
562
794
|
files.map(
|
|
563
|
-
async (file) =>
|
|
795
|
+
async (file) => writeFile4(
|
|
564
796
|
file,
|
|
565
797
|
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
566
798
|
|
|
567
|
-
${await
|
|
799
|
+
${await readFile4(file, "utf8")}
|
|
568
800
|
|
|
569
801
|
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
570
802
|
)
|
|
@@ -576,20 +808,20 @@ ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `//
|
|
|
576
808
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
577
809
|
import { calculateProjectBuildableDependencies } from "@nx/js/internal";
|
|
578
810
|
import { Glob } from "glob";
|
|
579
|
-
import { existsSync, readFileSync as readFileSync3 } from "node:fs";
|
|
580
|
-
import { readFile as
|
|
811
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
812
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
581
813
|
import {
|
|
582
|
-
createProjectGraphAsync,
|
|
583
|
-
readCachedProjectGraph,
|
|
814
|
+
createProjectGraphAsync as createProjectGraphAsync2,
|
|
815
|
+
readCachedProjectGraph as readCachedProjectGraph2,
|
|
584
816
|
readProjectsConfigurationFromProjectGraph
|
|
585
817
|
} from "nx/src/project-graph/project-graph";
|
|
586
818
|
var addPackageDependencies = async (workspaceRoot2, projectRoot, projectName, packageJson) => {
|
|
587
819
|
let projectGraph;
|
|
588
820
|
try {
|
|
589
|
-
projectGraph =
|
|
821
|
+
projectGraph = readCachedProjectGraph2();
|
|
590
822
|
} catch {
|
|
591
|
-
await
|
|
592
|
-
projectGraph =
|
|
823
|
+
await createProjectGraphAsync2();
|
|
824
|
+
projectGraph = readCachedProjectGraph2();
|
|
593
825
|
}
|
|
594
826
|
if (!projectGraph) {
|
|
595
827
|
throw new Error(
|
|
@@ -613,800 +845,174 @@ var addPackageDependencies = async (workspaceRoot2, projectRoot, projectName, pa
|
|
|
613
845
|
if (projectNode.data.root) {
|
|
614
846
|
const projectPackageJsonPath = joinPaths(
|
|
615
847
|
workspaceRoot2,
|
|
616
|
-
projectNode.data.root,
|
|
617
|
-
"package.json"
|
|
618
|
-
);
|
|
619
|
-
if (existsSync(projectPackageJsonPath)) {
|
|
620
|
-
const projectPackageJsonContent = await readFile2(
|
|
621
|
-
projectPackageJsonPath,
|
|
622
|
-
"utf8"
|
|
623
|
-
);
|
|
624
|
-
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
625
|
-
if (projectPackageJson.private !== true) {
|
|
626
|
-
localPackages.push(projectPackageJson);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
if (localPackages.length > 0) {
|
|
632
|
-
writeTrace(
|
|
633
|
-
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
634
|
-
);
|
|
635
|
-
const projectJsonFile = await readFile2(
|
|
636
|
-
joinPaths(projectRoot, "project.json"),
|
|
637
|
-
"utf8"
|
|
638
|
-
);
|
|
639
|
-
const projectJson = JSON.parse(projectJsonFile);
|
|
640
|
-
const projectName2 = projectJson.name;
|
|
641
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
642
|
-
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
643
|
-
throw new Error(
|
|
644
|
-
"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."
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
648
|
-
if (projectConfigurations.projects?.[dep]) {
|
|
649
|
-
const depPackageJsonPath = joinPaths(
|
|
650
|
-
workspaceRoot2,
|
|
651
|
-
projectConfigurations.projects[dep].root,
|
|
652
|
-
"package.json"
|
|
653
|
-
);
|
|
654
|
-
if (existsSync(depPackageJsonPath)) {
|
|
655
|
-
const depPackageJsonContent = readFileSync3(
|
|
656
|
-
depPackageJsonPath,
|
|
657
|
-
"utf8"
|
|
658
|
-
);
|
|
659
|
-
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
660
|
-
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
661
|
-
ret.push(depPackageJson.name);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return ret;
|
|
666
|
-
}, []);
|
|
667
|
-
packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
|
|
668
|
-
if (!ret[localPackage.name] && !implicitDependencies?.includes(localPackage.name) && packageJson.devDependencies?.[localPackage.name] === void 0) {
|
|
669
|
-
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
670
|
-
}
|
|
671
|
-
return ret;
|
|
672
|
-
}, packageJson.dependencies ?? {});
|
|
673
|
-
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
674
|
-
if (!ret[localPackage.name] && implicitDependencies?.includes(localPackage.name) && packageJson.dependencies?.[localPackage.name] === void 0) {
|
|
675
|
-
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
676
|
-
}
|
|
677
|
-
return ret;
|
|
678
|
-
}, packageJson.devDependencies ?? {});
|
|
679
|
-
} else {
|
|
680
|
-
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
681
|
-
}
|
|
682
|
-
return packageJson;
|
|
683
|
-
};
|
|
684
|
-
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
685
|
-
const workspaceRoot2 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
686
|
-
const workspacePackageJsonContent = await readFile2(
|
|
687
|
-
joinPaths(workspaceRoot2, "package.json"),
|
|
688
|
-
"utf8"
|
|
689
|
-
);
|
|
690
|
-
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
691
|
-
packageJson.type ??= "module";
|
|
692
|
-
packageJson.sideEffects ??= false;
|
|
693
|
-
if (includeSrc === true) {
|
|
694
|
-
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
695
|
-
if (distSrc.startsWith("/")) {
|
|
696
|
-
distSrc = distSrc.substring(1);
|
|
697
|
-
}
|
|
698
|
-
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
699
|
-
}
|
|
700
|
-
packageJson.files ??= ["dist/**/*"];
|
|
701
|
-
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
702
|
-
packageJson.files.push("src/**/*");
|
|
703
|
-
}
|
|
704
|
-
packageJson.publishConfig ??= {
|
|
705
|
-
access: "public"
|
|
706
|
-
};
|
|
707
|
-
packageJson.description ??= workspacePackageJson.description;
|
|
708
|
-
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
709
|
-
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
710
|
-
packageJson.license ??= workspacePackageJson.license;
|
|
711
|
-
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
712
|
-
packageJson.funding ??= workspacePackageJson.funding;
|
|
713
|
-
packageJson.author ??= workspacePackageJson.author;
|
|
714
|
-
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
715
|
-
if (!packageJson.maintainers && packageJson.author) {
|
|
716
|
-
packageJson.maintainers = [packageJson.author];
|
|
717
|
-
}
|
|
718
|
-
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
719
|
-
if (!packageJson.contributors && packageJson.author) {
|
|
720
|
-
packageJson.contributors = [packageJson.author];
|
|
721
|
-
}
|
|
722
|
-
packageJson.repository ??= workspacePackageJson.repository;
|
|
723
|
-
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
724
|
-
return packageJson;
|
|
725
|
-
};
|
|
726
|
-
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
|
|
727
|
-
let entry = file.replaceAll("\\", "/");
|
|
728
|
-
if (sourceRoot) {
|
|
729
|
-
entry = entry.replace(sourceRoot, "");
|
|
730
|
-
}
|
|
731
|
-
return {
|
|
732
|
-
import: {
|
|
733
|
-
types: `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
734
|
-
default: `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
735
|
-
},
|
|
736
|
-
require: {
|
|
737
|
-
types: `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
738
|
-
default: `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
739
|
-
},
|
|
740
|
-
default: {
|
|
741
|
-
types: `./dist/${entry}.d.${type !== "fixed" ? "ts" : "mts"}`,
|
|
742
|
-
default: `./dist/${entry}.${type !== "fixed" ? "js" : "mjs"}`
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
// ../build-tools/src/utilities/get-entry-points.ts
|
|
748
|
-
import { glob as glob2 } from "glob";
|
|
749
|
-
|
|
750
|
-
// ../build-tools/src/utilities/get-env.ts
|
|
751
|
-
var getEnv = (builder, options) => {
|
|
752
|
-
return {
|
|
753
|
-
STORM_BUILD: builder,
|
|
754
|
-
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
|
|
755
|
-
STORM_NAME: options.name,
|
|
756
|
-
STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
|
|
757
|
-
STORM_PLATFORM: options.platform,
|
|
758
|
-
STORM_FORMAT: JSON.stringify(options.format),
|
|
759
|
-
STORM_TARGET: JSON.stringify(options.target),
|
|
760
|
-
...options.env
|
|
761
|
-
};
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// ../build-tools/src/utilities/read-nx-config.ts
|
|
765
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
766
|
-
import { readFile as readFile3 } from "node:fs/promises";
|
|
767
|
-
|
|
768
|
-
// ../build-tools/src/utilities/task-graph.ts
|
|
769
|
-
import {
|
|
770
|
-
createTaskGraph,
|
|
771
|
-
mapTargetDefaultsToDependencies
|
|
772
|
-
} from "nx/src/tasks-runner/create-task-graph";
|
|
773
|
-
|
|
774
|
-
// ../esbuild/src/assets.ts
|
|
775
|
-
async function copyBuildAssets(context) {
|
|
776
|
-
if (!context.result?.errors.length && context.options.assets?.length) {
|
|
777
|
-
writeDebug(
|
|
778
|
-
` \u{1F4CB} Copying ${context.options.assets.length} asset files to output directory: ${context.outputPath}`,
|
|
779
|
-
context.workspaceConfig
|
|
780
|
-
);
|
|
781
|
-
const stopwatch = getStopwatch(`${context.options.name} asset copy`);
|
|
782
|
-
await copyAssets(
|
|
783
|
-
context.workspaceConfig,
|
|
784
|
-
context.options.assets ?? [],
|
|
785
|
-
context.outputPath,
|
|
786
|
-
context.options.projectRoot,
|
|
787
|
-
context.sourceRoot,
|
|
788
|
-
true,
|
|
789
|
-
false
|
|
790
|
-
);
|
|
791
|
-
stopwatch();
|
|
792
|
-
}
|
|
793
|
-
return context;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// ../esbuild/src/clean.ts
|
|
797
|
-
import { rm } from "node:fs/promises";
|
|
798
|
-
async function cleanDirectories(directory) {
|
|
799
|
-
await rm(directory, { recursive: true, force: true });
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
// ../esbuild/src/context.ts
|
|
803
|
-
import {
|
|
804
|
-
createProjectGraphAsync as createProjectGraphAsync2,
|
|
805
|
-
readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph2
|
|
806
|
-
} from "@nx/devkit";
|
|
807
|
-
import defu2 from "defu";
|
|
808
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
809
|
-
import hf from "node:fs/promises";
|
|
810
|
-
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
811
|
-
|
|
812
|
-
// ../esbuild/src/config.ts
|
|
813
|
-
var DEFAULT_BUILD_OPTIONS = {
|
|
814
|
-
platform: "node",
|
|
815
|
-
target: "node22",
|
|
816
|
-
format: "esm",
|
|
817
|
-
mode: "production",
|
|
818
|
-
generatePackageJson: true,
|
|
819
|
-
includeSrc: false,
|
|
820
|
-
keepNames: true,
|
|
821
|
-
metafile: false,
|
|
822
|
-
treeshake: true,
|
|
823
|
-
splitting: true,
|
|
824
|
-
shims: false,
|
|
825
|
-
watch: false,
|
|
826
|
-
bundle: true,
|
|
827
|
-
distDir: "dist",
|
|
828
|
-
loader: {
|
|
829
|
-
".aac": "file",
|
|
830
|
-
".css": "file",
|
|
831
|
-
".eot": "file",
|
|
832
|
-
".flac": "file",
|
|
833
|
-
".gif": "file",
|
|
834
|
-
".jpeg": "file",
|
|
835
|
-
".jpg": "file",
|
|
836
|
-
".mp3": "file",
|
|
837
|
-
".mp4": "file",
|
|
838
|
-
".ogg": "file",
|
|
839
|
-
".otf": "file",
|
|
840
|
-
".png": "file",
|
|
841
|
-
".svg": "file",
|
|
842
|
-
".ttf": "file",
|
|
843
|
-
".wav": "file",
|
|
844
|
-
".webm": "file",
|
|
845
|
-
".webp": "file",
|
|
846
|
-
".woff": "file",
|
|
847
|
-
".woff2": "file"
|
|
848
|
-
},
|
|
849
|
-
banner: {
|
|
850
|
-
js: DEFAULT_JS_BANNER,
|
|
851
|
-
css: DEFAULT_CSS_BANNER
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
|
|
855
|
-
// ../esbuild/src/context.ts
|
|
856
|
-
async function resolveContext(userOptions) {
|
|
857
|
-
const projectRoot = userOptions.projectRoot;
|
|
858
|
-
const workspaceRoot2 = findWorkspaceRoot2(projectRoot);
|
|
859
|
-
if (!workspaceRoot2) {
|
|
860
|
-
throw new Error("Cannot find Nx workspace root");
|
|
861
|
-
}
|
|
862
|
-
const workspaceConfig = await getWorkspaceConfig(true, {
|
|
863
|
-
workspaceRoot: workspaceRoot2.dir
|
|
864
|
-
});
|
|
865
|
-
writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
|
|
866
|
-
const stopwatch = getStopwatch("Build options resolution");
|
|
867
|
-
const projectGraph = await createProjectGraphAsync2({
|
|
868
|
-
exitOnError: true
|
|
869
|
-
});
|
|
870
|
-
const projectJsonPath = joinPaths(
|
|
871
|
-
workspaceRoot2.dir,
|
|
872
|
-
projectRoot,
|
|
873
|
-
"project.json"
|
|
874
|
-
);
|
|
875
|
-
if (!existsSync3(projectJsonPath)) {
|
|
876
|
-
throw new Error("Cannot find project.json configuration");
|
|
877
|
-
}
|
|
878
|
-
const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
|
|
879
|
-
const projectJson = JSON.parse(projectJsonFile);
|
|
880
|
-
const projectName = projectJson.name || userOptions.name;
|
|
881
|
-
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
882
|
-
if (!projectConfigurations?.projects?.[projectName]) {
|
|
883
|
-
throw new Error(
|
|
884
|
-
"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."
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
|
-
const options = defu2(userOptions, DEFAULT_BUILD_OPTIONS);
|
|
888
|
-
options.name ??= projectName;
|
|
889
|
-
const packageJsonPath = joinPaths(
|
|
890
|
-
workspaceRoot2.dir,
|
|
891
|
-
options.projectRoot,
|
|
892
|
-
"package.json"
|
|
893
|
-
);
|
|
894
|
-
if (!existsSync3(packageJsonPath)) {
|
|
895
|
-
throw new Error("Cannot find package.json configuration");
|
|
896
|
-
}
|
|
897
|
-
const env = getEnv("esbuild", options);
|
|
898
|
-
const define = defu2(options.define ?? {}, env ?? {});
|
|
899
|
-
const resolvedOptions = {
|
|
900
|
-
...options,
|
|
901
|
-
tsconfig: userOptions.tsconfig === null ? void 0 : userOptions.tsconfig ? userOptions.tsconfig : joinPaths(workspaceRoot2.dir, projectRoot, "tsconfig.json"),
|
|
902
|
-
metafile: userOptions.mode === "development",
|
|
903
|
-
clean: false,
|
|
904
|
-
env,
|
|
905
|
-
define: {
|
|
906
|
-
STORM_FORMAT: JSON.stringify(options.format),
|
|
907
|
-
...Object.keys(define).filter((key) => define[key] !== void 0).reduce((res, key) => {
|
|
908
|
-
const value = JSON.stringify(define[key]);
|
|
909
|
-
const safeKey = key.replaceAll("(", "").replaceAll(")", "");
|
|
910
|
-
return {
|
|
911
|
-
...res,
|
|
912
|
-
[`process.env.${safeKey}`]: value,
|
|
913
|
-
[`import.meta.env.${safeKey}`]: value
|
|
914
|
-
};
|
|
915
|
-
}, {})
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
stopwatch();
|
|
919
|
-
const context = {
|
|
920
|
-
options: resolvedOptions,
|
|
921
|
-
clean: userOptions.clean !== false,
|
|
922
|
-
workspaceConfig,
|
|
923
|
-
projectConfigurations,
|
|
924
|
-
projectName,
|
|
925
|
-
projectGraph,
|
|
926
|
-
sourceRoot: resolvedOptions.sourceRoot || projectJson.sourceRoot || joinPaths(resolvedOptions.projectRoot, "src"),
|
|
927
|
-
outputPath: resolvedOptions.outputPath || joinPaths(
|
|
928
|
-
workspaceConfig.workspaceRoot,
|
|
929
|
-
"dist",
|
|
930
|
-
resolvedOptions.projectRoot
|
|
931
|
-
),
|
|
932
|
-
minify: resolvedOptions.minify || resolvedOptions.mode === "production"
|
|
933
|
-
};
|
|
934
|
-
context.options.esbuildPlugins = [...context.options.esbuildPlugins ?? []];
|
|
935
|
-
if (context.options.verbose) {
|
|
936
|
-
writeDebug(
|
|
937
|
-
` \u2699\uFE0F Build options resolved:
|
|
938
|
-
|
|
939
|
-
${formatLogMessage(context.options)}`,
|
|
940
|
-
workspaceConfig
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
return context;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
// ../esbuild/src/package-json.ts
|
|
947
|
-
import { writeJsonFile } from "@nx/devkit";
|
|
948
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
949
|
-
import hf2 from "node:fs/promises";
|
|
950
|
-
async function generatePackageJson(context) {
|
|
951
|
-
if (context.options.generatePackageJson !== false && existsSync4(joinPaths(context.options.projectRoot, "package.json"))) {
|
|
952
|
-
writeDebug(" \u270D\uFE0F Writing package.json file", context.workspaceConfig);
|
|
953
|
-
const stopwatch = getStopwatch("Write package.json file");
|
|
954
|
-
const packageJsonPath = joinPaths(
|
|
955
|
-
context.options.projectRoot,
|
|
956
|
-
"project.json"
|
|
957
|
-
);
|
|
958
|
-
if (!existsSync4(packageJsonPath)) {
|
|
959
|
-
throw new Error("Cannot find package.json configuration");
|
|
960
|
-
}
|
|
961
|
-
const packageJsonFile = await hf2.readFile(
|
|
962
|
-
joinPaths(
|
|
963
|
-
context.workspaceConfig.workspaceRoot,
|
|
964
|
-
context.options.projectRoot,
|
|
965
|
-
"package.json"
|
|
966
|
-
),
|
|
967
|
-
"utf8"
|
|
968
|
-
);
|
|
969
|
-
let packageJson = JSON.parse(packageJsonFile);
|
|
970
|
-
if (!packageJson) {
|
|
971
|
-
throw new Error("Cannot find package.json configuration file");
|
|
972
|
-
}
|
|
973
|
-
packageJson = await addPackageDependencies(
|
|
974
|
-
context.workspaceConfig.workspaceRoot,
|
|
975
|
-
context.options.projectRoot,
|
|
976
|
-
context.projectName,
|
|
977
|
-
packageJson
|
|
978
|
-
);
|
|
979
|
-
packageJson = await addWorkspacePackageJsonFields(
|
|
980
|
-
context.workspaceConfig,
|
|
981
|
-
context.options.projectRoot,
|
|
982
|
-
context.sourceRoot,
|
|
983
|
-
context.projectName,
|
|
984
|
-
false,
|
|
985
|
-
packageJson
|
|
986
|
-
);
|
|
987
|
-
if (context.options.entry) {
|
|
988
|
-
packageJson.exports ??= {};
|
|
989
|
-
packageJson.exports["./package.json"] ??= "./package.json";
|
|
990
|
-
const entryPoints = Array.isArray(context.options.entry) ? context.options.entry : Object.keys(context.options.entry);
|
|
991
|
-
if (entryPoints.length > 0) {
|
|
992
|
-
const defaultEntry = entryPoints.includes("index") ? `.${context.options.distDir ? `/${context.options.distDir}` : ""}/index` : `.${context.options.distDir ? `/${context.options.distDir}` : ""}/${entryPoints[0]}`;
|
|
993
|
-
const isEsm = Array.isArray(context.options.format) ? context.options.format.includes("esm") : context.options.format === "esm";
|
|
994
|
-
const isCjs = Array.isArray(context.options.format) ? context.options.format.includes("cjs") : context.options.format === "cjs";
|
|
995
|
-
const isDts = context.options.dts || context.options.experimentalDts;
|
|
996
|
-
packageJson.exports["."] ??= `${defaultEntry}.${isEsm ? "mjs" : isCjs ? "cjs" : "js"}`;
|
|
997
|
-
for (const entryPoint of entryPoints) {
|
|
998
|
-
packageJson.exports[`./${entryPoint}`] ??= {};
|
|
999
|
-
if (isEsm) {
|
|
1000
|
-
if (isDts) {
|
|
1001
|
-
packageJson.exports[`./${entryPoint}`].import = {
|
|
1002
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
1003
|
-
default: `./dist/${entryPoint}.mjs`
|
|
1004
|
-
};
|
|
1005
|
-
} else {
|
|
1006
|
-
packageJson.exports[`./${entryPoint}`].import = `./dist/${entryPoint}.mjs`;
|
|
1007
|
-
}
|
|
1008
|
-
if (isDts) {
|
|
1009
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
1010
|
-
types: `./dist/${entryPoint}.d.mts`,
|
|
1011
|
-
default: `./dist/${entryPoint}.mjs`
|
|
1012
|
-
};
|
|
1013
|
-
} else {
|
|
1014
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.mjs`;
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
if (isCjs) {
|
|
1018
|
-
if (isDts) {
|
|
1019
|
-
packageJson.exports[`./${entryPoint}`].require = {
|
|
1020
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
1021
|
-
default: `./dist/${entryPoint}.cjs`
|
|
1022
|
-
};
|
|
1023
|
-
} else {
|
|
1024
|
-
packageJson.exports[`./${entryPoint}`].require = `./dist/${entryPoint}.cjs`;
|
|
1025
|
-
}
|
|
1026
|
-
if (!isEsm) {
|
|
1027
|
-
if (isDts) {
|
|
1028
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
1029
|
-
types: `./dist/${entryPoint}.d.cts`,
|
|
1030
|
-
default: `./dist/${entryPoint}.cjs`
|
|
1031
|
-
};
|
|
1032
|
-
} else {
|
|
1033
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.cjs`;
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
if (!isEsm && !isCjs) {
|
|
1038
|
-
if (isDts) {
|
|
1039
|
-
packageJson.exports[`./${entryPoint}`].default = {
|
|
1040
|
-
types: `./dist/${entryPoint}.d.ts`,
|
|
1041
|
-
default: `./dist/${entryPoint}.js`
|
|
1042
|
-
};
|
|
1043
|
-
} else {
|
|
1044
|
-
packageJson.exports[`./${entryPoint}`].default = `./dist/${entryPoint}.js`;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
if (isEsm) {
|
|
1049
|
-
packageJson.module = `${defaultEntry}.mjs`;
|
|
1050
|
-
} else {
|
|
1051
|
-
packageJson.main = `${defaultEntry}.cjs`;
|
|
1052
|
-
}
|
|
1053
|
-
if (isDts) {
|
|
1054
|
-
packageJson.types = `${defaultEntry}.d.${isEsm ? "mts" : isCjs ? "cts" : "ts"}`;
|
|
1055
|
-
}
|
|
1056
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
1057
|
-
(ret, key) => {
|
|
1058
|
-
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
1059
|
-
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
1060
|
-
}
|
|
1061
|
-
return ret;
|
|
1062
|
-
},
|
|
1063
|
-
packageJson.exports
|
|
1064
|
-
);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
await writeJsonFile(
|
|
1068
|
-
joinPaths(context.outputPath, "package.json"),
|
|
1069
|
-
packageJson
|
|
1070
|
-
);
|
|
1071
|
-
stopwatch();
|
|
1072
|
-
}
|
|
1073
|
-
return context;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
// ../tsup/src/index.ts
|
|
1077
|
-
import { build as tsup } from "tsup";
|
|
1078
|
-
async function build(options) {
|
|
1079
|
-
if (!options.silent) {
|
|
1080
|
-
writeDebug(
|
|
1081
|
-
` \u{1F680} Running ${options.name || "tsup"} build`,
|
|
1082
|
-
options.workspaceConfig
|
|
1083
|
-
);
|
|
1084
|
-
}
|
|
1085
|
-
const stopwatch = getStopwatch(`${options.name || "tsup"} build`);
|
|
1086
|
-
await tsup(options);
|
|
1087
|
-
if (!options.silent) {
|
|
1088
|
-
stopwatch();
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// ../esbuild/src/tsup.ts
|
|
1093
|
-
async function executeTsup(context) {
|
|
1094
|
-
writeDebug(
|
|
1095
|
-
` \u{1F680} Running ${context.options.name} build`,
|
|
1096
|
-
context.workspaceConfig
|
|
1097
|
-
);
|
|
1098
|
-
const stopwatch = getStopwatch(`${context.options.name} build`);
|
|
1099
|
-
await build({
|
|
1100
|
-
...context.options,
|
|
1101
|
-
outDir: context.options.distDir ? joinPaths(context.outputPath, context.options.distDir) : context.outputPath,
|
|
1102
|
-
workspaceConfig: context.workspaceConfig
|
|
1103
|
-
});
|
|
1104
|
-
stopwatch();
|
|
1105
|
-
return context;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// ../esbuild/src/build.ts
|
|
1109
|
-
async function reportResults(context) {
|
|
1110
|
-
if (context.result?.errors.length === 0) {
|
|
1111
|
-
if (context.result.warnings.length > 0) {
|
|
1112
|
-
writeWarning(
|
|
1113
|
-
` \u{1F6A7} The following warnings occurred during the build: ${context.result.warnings.map((warning) => warning.text).join("\n")}`,
|
|
1114
|
-
context.workspaceConfig
|
|
1115
|
-
);
|
|
1116
|
-
}
|
|
1117
|
-
writeSuccess(
|
|
1118
|
-
` \u{1F4E6} The ${context.options.name} build completed successfully`,
|
|
1119
|
-
context.workspaceConfig
|
|
1120
|
-
);
|
|
1121
|
-
} else if (context.result?.errors && context.result?.errors.length > 0) {
|
|
1122
|
-
writeError(
|
|
1123
|
-
` \u274C The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`,
|
|
1124
|
-
context.workspaceConfig
|
|
1125
|
-
);
|
|
1126
|
-
throw new Error(
|
|
1127
|
-
`The ${context.options.name} build failed with the following errors: ${context.result.errors.map((error) => error.text).join("\n")}`
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
async function cleanOutputPath(context) {
|
|
1132
|
-
if (context.clean !== false && context.outputPath) {
|
|
1133
|
-
writeDebug(
|
|
1134
|
-
` \u{1F9F9} Cleaning ${context.options.name} output path: ${context.outputPath}`,
|
|
1135
|
-
context.workspaceConfig
|
|
1136
|
-
);
|
|
1137
|
-
const stopwatch = getStopwatch(`${context.options.name} output clean`);
|
|
1138
|
-
await cleanDirectories(context.outputPath);
|
|
1139
|
-
stopwatch();
|
|
1140
|
-
}
|
|
1141
|
-
return context;
|
|
1142
|
-
}
|
|
1143
|
-
async function build2(options) {
|
|
1144
|
-
writeDebug(` ${brandIcon()} Executing Storm ESBuild pipeline`);
|
|
1145
|
-
const stopwatch = getStopwatch("ESBuild pipeline");
|
|
1146
|
-
try {
|
|
1147
|
-
const opts = Array.isArray(options) ? options : [options];
|
|
1148
|
-
if (opts.length === 0) {
|
|
1149
|
-
throw new Error("No build options were provided");
|
|
1150
|
-
}
|
|
1151
|
-
const context = await resolveContext(options);
|
|
1152
|
-
await cleanOutputPath(context);
|
|
1153
|
-
await Promise.all([
|
|
1154
|
-
// dependencyCheck(context.options),
|
|
1155
|
-
generatePackageJson(context),
|
|
1156
|
-
copyBuildAssets(context),
|
|
1157
|
-
executeTsup(context)
|
|
1158
|
-
]);
|
|
1159
|
-
await reportResults(context);
|
|
1160
|
-
writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
|
|
1161
|
-
} catch (error) {
|
|
1162
|
-
writeFatal(
|
|
1163
|
-
"Fatal errors that the build process could not recover from have occured. The build process has been terminated."
|
|
1164
|
-
);
|
|
1165
|
-
throw error;
|
|
1166
|
-
} finally {
|
|
1167
|
-
stopwatch();
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
// ../workspace-tools/src/executors/esbuild/executor.ts
|
|
1172
|
-
async function esbuildExecutorFn(options, context, config) {
|
|
1173
|
-
writeInfo("\u{1F4E6} Running Storm ESBuild executor on the workspace", config);
|
|
1174
|
-
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName] || !context.projectsConfigurations.projects[context.projectName]?.root) {
|
|
1175
|
-
throw new Error(
|
|
1176
|
-
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
await build2({
|
|
1180
|
-
...options,
|
|
1181
|
-
projectRoot: (
|
|
1182
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1183
|
-
context.projectsConfigurations.projects?.[context.projectName].root
|
|
1184
|
-
),
|
|
1185
|
-
name: context.projectName,
|
|
1186
|
-
sourceRoot: context.projectsConfigurations.projects?.[context.projectName]?.sourceRoot,
|
|
1187
|
-
format: options.format,
|
|
1188
|
-
platform: options.platform
|
|
1189
|
-
});
|
|
1190
|
-
return {
|
|
1191
|
-
success: true
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
var executor_default6 = withRunExecutor(
|
|
1195
|
-
"Storm ESBuild build",
|
|
1196
|
-
esbuildExecutorFn,
|
|
1197
|
-
{
|
|
1198
|
-
skipReadingConfig: false,
|
|
1199
|
-
hooks: {
|
|
1200
|
-
applyDefaultOptions: async (options) => {
|
|
1201
|
-
options.entry ??= ["src/index.ts"];
|
|
1202
|
-
options.outputPath ??= "dist/{projectRoot}";
|
|
1203
|
-
options.tsconfig ??= "{projectRoot}/tsconfig.json";
|
|
1204
|
-
return options;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
);
|
|
1209
|
-
|
|
1210
|
-
// ../workspace-tools/src/executors/napi/executor.ts
|
|
1211
|
-
import { createJiti } from "jiti";
|
|
1212
|
-
import { fileExists } from "nx/src/utils/fileutils";
|
|
1213
|
-
async function napiExecutor(options, context, config) {
|
|
1214
|
-
const jiti = createJiti(config.workspaceRoot, {
|
|
1215
|
-
fsCache: config.skipCache ? false : joinPaths(
|
|
1216
|
-
config.workspaceRoot,
|
|
1217
|
-
config.directories.cache || "node_modules/.cache/storm",
|
|
1218
|
-
"jiti"
|
|
1219
|
-
),
|
|
1220
|
-
interopDefault: true
|
|
1221
|
-
});
|
|
1222
|
-
const { NapiCli } = await jiti.import(
|
|
1223
|
-
jiti.esmResolve("@napi-rs/cli")
|
|
1224
|
-
);
|
|
1225
|
-
if (!context.projectGraph?.nodes[context.projectName ?? ""]) {
|
|
1226
|
-
throw new Error(
|
|
1227
|
-
"The Napi Build process failed because the project could not be found in the project graph. Please run this command from a workspace root directory."
|
|
1228
|
-
);
|
|
1229
|
-
}
|
|
1230
|
-
const projectRoot = context.projectGraph?.nodes[context.projectName ?? ""]?.data.root;
|
|
1231
|
-
const packageJson = joinPaths(projectRoot ?? ".", "package.json");
|
|
1232
|
-
if (!fileExists(packageJson)) {
|
|
1233
|
-
throw new Error(`Could not find package.json at ${packageJson}`);
|
|
1234
|
-
}
|
|
1235
|
-
const napi = new NapiCli();
|
|
1236
|
-
const normalizedOptions = { ...options };
|
|
1237
|
-
const metadata = cargoMetadata();
|
|
1238
|
-
normalizedOptions.targetDir = options.targetDir || metadata?.target_directory || joinPaths(config.workspaceRoot, "dist", "target");
|
|
1239
|
-
normalizedOptions.outputDir = options.outputPath;
|
|
1240
|
-
normalizedOptions.packageJsonPath ??= packageJson;
|
|
1241
|
-
if (options.cwd) {
|
|
1242
|
-
normalizedOptions.cwd = correctPaths(options.cwd);
|
|
1243
|
-
} else {
|
|
1244
|
-
const absoluteProjectRoot = correctPaths(
|
|
1245
|
-
joinPaths(config.workspaceRoot, projectRoot || ".")
|
|
1246
|
-
);
|
|
1247
|
-
normalizedOptions.cwd = absoluteProjectRoot;
|
|
1248
|
-
if (normalizedOptions.outputDir) {
|
|
1249
|
-
normalizedOptions.outputDir = relative(
|
|
1250
|
-
normalizedOptions.cwd,
|
|
1251
|
-
correctPaths(
|
|
1252
|
-
isAbsolute(normalizedOptions.outputDir) ? normalizedOptions.outputDir : joinPaths(config.workspaceRoot, normalizedOptions.outputDir)
|
|
1253
|
-
)
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1256
|
-
if (normalizedOptions.packageJsonPath) {
|
|
1257
|
-
normalizedOptions.packageJsonPath = relative(
|
|
1258
|
-
normalizedOptions.cwd,
|
|
1259
|
-
correctPaths(
|
|
1260
|
-
isAbsolute(normalizedOptions.packageJsonPath) ? normalizedOptions.packageJsonPath : joinPaths(config.workspaceRoot, normalizedOptions.packageJsonPath)
|
|
1261
|
-
)
|
|
1262
|
-
);
|
|
1263
|
-
}
|
|
1264
|
-
if (normalizedOptions.configPath) {
|
|
1265
|
-
normalizedOptions.configPath = relative(
|
|
1266
|
-
normalizedOptions.cwd,
|
|
1267
|
-
correctPaths(
|
|
1268
|
-
isAbsolute(normalizedOptions.configPath) ? normalizedOptions.configPath : joinPaths(config.workspaceRoot, normalizedOptions.configPath)
|
|
1269
|
-
)
|
|
1270
|
-
);
|
|
1271
|
-
}
|
|
1272
|
-
if (normalizedOptions.manifestPath) {
|
|
1273
|
-
normalizedOptions.manifestPath = relative(
|
|
1274
|
-
normalizedOptions.cwd,
|
|
1275
|
-
correctPaths(
|
|
1276
|
-
isAbsolute(normalizedOptions.manifestPath) ? normalizedOptions.manifestPath : joinPaths(config.workspaceRoot, normalizedOptions.manifestPath)
|
|
1277
|
-
)
|
|
848
|
+
projectNode.data.root,
|
|
849
|
+
"package.json"
|
|
1278
850
|
);
|
|
851
|
+
if (existsSync3(projectPackageJsonPath)) {
|
|
852
|
+
const projectPackageJsonContent = await readFile5(
|
|
853
|
+
projectPackageJsonPath,
|
|
854
|
+
"utf8"
|
|
855
|
+
);
|
|
856
|
+
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
857
|
+
if (projectPackageJson.private !== true) {
|
|
858
|
+
localPackages.push(projectPackageJson);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
1279
861
|
}
|
|
1280
862
|
}
|
|
1281
|
-
if (
|
|
1282
|
-
|
|
863
|
+
if (localPackages.length > 0) {
|
|
864
|
+
writeTrace(
|
|
865
|
+
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
866
|
+
);
|
|
867
|
+
const projectJsonFile = await readFile5(
|
|
868
|
+
joinPaths(projectRoot, "project.json"),
|
|
869
|
+
"utf8"
|
|
870
|
+
);
|
|
871
|
+
const projectJson = JSON.parse(projectJsonFile);
|
|
872
|
+
const projectName2 = projectJson.name;
|
|
873
|
+
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
874
|
+
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
875
|
+
throw new Error(
|
|
876
|
+
"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."
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
880
|
+
if (projectConfigurations.projects?.[dep]) {
|
|
881
|
+
const depPackageJsonPath = joinPaths(
|
|
882
|
+
workspaceRoot2,
|
|
883
|
+
projectConfigurations.projects[dep].root,
|
|
884
|
+
"package.json"
|
|
885
|
+
);
|
|
886
|
+
if (existsSync3(depPackageJsonPath)) {
|
|
887
|
+
const depPackageJsonContent = readFileSync3(
|
|
888
|
+
depPackageJsonPath,
|
|
889
|
+
"utf8"
|
|
890
|
+
);
|
|
891
|
+
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
892
|
+
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
893
|
+
ret.push(depPackageJson.name);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return ret;
|
|
898
|
+
}, []);
|
|
899
|
+
packageJson.dependencies = localPackages.reduce((ret, localPackage) => {
|
|
900
|
+
if (!ret[localPackage.name] && !implicitDependencies?.includes(localPackage.name) && packageJson.devDependencies?.[localPackage.name] === void 0) {
|
|
901
|
+
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
902
|
+
}
|
|
903
|
+
return ret;
|
|
904
|
+
}, packageJson.dependencies ?? {});
|
|
905
|
+
packageJson.devDependencies = localPackages.reduce((ret, localPackage) => {
|
|
906
|
+
if (!ret[localPackage.name] && implicitDependencies?.includes(localPackage.name) && packageJson.dependencies?.[localPackage.name] === void 0) {
|
|
907
|
+
ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`;
|
|
908
|
+
}
|
|
909
|
+
return ret;
|
|
910
|
+
}, packageJson.devDependencies ?? {});
|
|
911
|
+
} else {
|
|
912
|
+
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
1283
913
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
cwd: ${normalizedOptions.cwd}`,
|
|
1292
|
-
config
|
|
914
|
+
return packageJson;
|
|
915
|
+
};
|
|
916
|
+
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
917
|
+
const workspaceRoot2 = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
918
|
+
const workspacePackageJsonContent = await readFile5(
|
|
919
|
+
joinPaths(workspaceRoot2, "package.json"),
|
|
920
|
+
"utf8"
|
|
1293
921
|
);
|
|
1294
|
-
const
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
skipReadingConfig: false,
|
|
1302
|
-
hooks: {
|
|
1303
|
-
applyDefaultOptions: (options) => {
|
|
1304
|
-
options.outputPath ??= "{sourceRoot}";
|
|
1305
|
-
options.toolchain ??= "stable";
|
|
1306
|
-
options.dtsCache ??= true;
|
|
1307
|
-
options.platform ??= true;
|
|
1308
|
-
options.constEnum ??= false;
|
|
1309
|
-
options.verbose ??= false;
|
|
1310
|
-
options.jsBinding ??= "binding.js";
|
|
1311
|
-
options.dts ??= "binding.d.ts";
|
|
1312
|
-
return options;
|
|
1313
|
-
}
|
|
922
|
+
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
923
|
+
packageJson.type ??= "module";
|
|
924
|
+
packageJson.sideEffects ??= false;
|
|
925
|
+
if (includeSrc === true) {
|
|
926
|
+
let distSrc = sourceRoot.replace(projectRoot, "");
|
|
927
|
+
if (distSrc.startsWith("/")) {
|
|
928
|
+
distSrc = distSrc.substring(1);
|
|
1314
929
|
}
|
|
930
|
+
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
1315
931
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
932
|
+
packageJson.files ??= ["dist/**/*"];
|
|
933
|
+
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
934
|
+
packageJson.files.push("src/**/*");
|
|
935
|
+
}
|
|
936
|
+
packageJson.publishConfig ??= {
|
|
937
|
+
access: "public"
|
|
938
|
+
};
|
|
939
|
+
packageJson.description ??= workspacePackageJson.description;
|
|
940
|
+
packageJson.homepage ??= workspacePackageJson.homepage;
|
|
941
|
+
packageJson.bugs ??= workspacePackageJson.bugs;
|
|
942
|
+
packageJson.license ??= workspacePackageJson.license;
|
|
943
|
+
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
944
|
+
packageJson.funding ??= workspacePackageJson.funding;
|
|
945
|
+
packageJson.author ??= workspacePackageJson.author;
|
|
946
|
+
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
947
|
+
if (!packageJson.maintainers && packageJson.author) {
|
|
948
|
+
packageJson.maintainers = [packageJson.author];
|
|
949
|
+
}
|
|
950
|
+
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
951
|
+
if (!packageJson.contributors && packageJson.author) {
|
|
952
|
+
packageJson.contributors = [packageJson.author];
|
|
953
|
+
}
|
|
954
|
+
packageJson.repository ??= workspacePackageJson.repository;
|
|
955
|
+
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
956
|
+
return packageJson;
|
|
957
|
+
};
|
|
958
|
+
var addPackageJsonExport = (file, type = "module", sourceRoot) => {
|
|
959
|
+
let entry = file.replaceAll("\\", "/");
|
|
960
|
+
if (sourceRoot) {
|
|
961
|
+
entry = entry.replace(sourceRoot, "");
|
|
962
|
+
}
|
|
963
|
+
return {
|
|
964
|
+
import: {
|
|
965
|
+
types: `./dist/${entry}.d.${type === "module" ? "ts" : "mts"}`,
|
|
966
|
+
default: `./dist/${entry}.${type === "module" ? "js" : "mjs"}`
|
|
967
|
+
},
|
|
968
|
+
require: {
|
|
969
|
+
types: `./dist/${entry}.d.${type === "commonjs" ? "ts" : "cts"}`,
|
|
970
|
+
default: `./dist/${entry}.${type === "commonjs" ? "js" : "cjs"}`
|
|
971
|
+
},
|
|
972
|
+
default: {
|
|
973
|
+
types: `./dist/${entry}.d.${type !== "fixed" ? "ts" : "mts"}`,
|
|
974
|
+
default: `./dist/${entry}.${type !== "fixed" ? "js" : "mjs"}`
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
};
|
|
1350
978
|
|
|
1351
|
-
// ../
|
|
1352
|
-
|
|
979
|
+
// ../build-tools/src/utilities/get-entry-points.ts
|
|
980
|
+
import { glob as glob2 } from "glob";
|
|
1353
981
|
|
|
1354
|
-
// ../
|
|
1355
|
-
|
|
1356
|
-
import esBuildPlugin from "@size-limit/esbuild";
|
|
1357
|
-
import esBuildWhyPlugin from "@size-limit/esbuild-why";
|
|
1358
|
-
import filePlugin from "@size-limit/file";
|
|
1359
|
-
import sizeLimit from "size-limit";
|
|
1360
|
-
async function sizeLimitExecutorFn(options, context, config) {
|
|
1361
|
-
if (!context?.projectName || !context.projectsConfigurations?.projects || !context.projectsConfigurations.projects[context.projectName]) {
|
|
1362
|
-
throw new Error(
|
|
1363
|
-
"The Size-Limit process failed because the context is not valid. Please run this command from a workspace."
|
|
1364
|
-
);
|
|
1365
|
-
}
|
|
1366
|
-
writeInfo(`\u{1F4CF} Running Size-Limit on ${context.projectName}`, config);
|
|
1367
|
-
sizeLimit([filePlugin, esBuildPlugin, esBuildWhyPlugin], {
|
|
1368
|
-
checks: options.entry ?? context.projectsConfigurations.projects[context.projectName]?.sourceRoot ?? joinPathFragments3(
|
|
1369
|
-
context.projectsConfigurations.projects[context.projectName]?.root ?? "./",
|
|
1370
|
-
"src"
|
|
1371
|
-
)
|
|
1372
|
-
}).then((result) => {
|
|
1373
|
-
writeInfo(
|
|
1374
|
-
`\u{1F4CF} ${context.projectName} Size-Limit result: ${JSON.stringify(result)}`,
|
|
1375
|
-
config
|
|
1376
|
-
);
|
|
1377
|
-
});
|
|
982
|
+
// ../build-tools/src/utilities/get-env.ts
|
|
983
|
+
var getEnv = (builder, options) => {
|
|
1378
984
|
return {
|
|
1379
|
-
|
|
985
|
+
STORM_BUILD: builder,
|
|
986
|
+
STORM_ORG: options.orgName || DEFAULT_ORGANIZATION,
|
|
987
|
+
STORM_NAME: options.name,
|
|
988
|
+
STORM_MODE: options.mode || DEFAULT_ENVIRONMENT,
|
|
989
|
+
STORM_PLATFORM: options.platform,
|
|
990
|
+
STORM_FORMAT: JSON.stringify(options.format),
|
|
991
|
+
STORM_TARGET: JSON.stringify(options.target),
|
|
992
|
+
...options.env
|
|
1380
993
|
};
|
|
1381
|
-
}
|
|
1382
|
-
var executor_default8 = withRunExecutor(
|
|
1383
|
-
"Size-Limit Performance Test Executor",
|
|
1384
|
-
sizeLimitExecutorFn,
|
|
1385
|
-
{
|
|
1386
|
-
skipReadingConfig: false,
|
|
1387
|
-
hooks: {
|
|
1388
|
-
applyDefaultOptions: (options) => {
|
|
1389
|
-
return options;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
);
|
|
994
|
+
};
|
|
1394
995
|
|
|
1395
|
-
// ../
|
|
996
|
+
// ../build-tools/src/utilities/read-nx-config.ts
|
|
997
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
998
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
999
|
+
|
|
1000
|
+
// ../build-tools/src/utilities/task-graph.ts
|
|
1396
1001
|
import {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
import
|
|
1403
|
-
import
|
|
1002
|
+
createTaskGraph,
|
|
1003
|
+
mapTargetDefaultsToDependencies
|
|
1004
|
+
} from "nx/src/tasks-runner/create-task-graph";
|
|
1005
|
+
|
|
1006
|
+
// ../tsdown/src/build.ts
|
|
1007
|
+
import defu2 from "defu";
|
|
1008
|
+
import { existsSync as existsSync5 } from "node:fs";
|
|
1009
|
+
import hf from "node:fs/promises";
|
|
1404
1010
|
import { build as tsdown } from "tsdown";
|
|
1405
1011
|
|
|
1406
1012
|
// ../tsdown/src/clean.ts
|
|
1407
|
-
import { rm
|
|
1408
|
-
async function
|
|
1409
|
-
await
|
|
1013
|
+
import { rm } from "node:fs/promises";
|
|
1014
|
+
async function cleanDirectories(name = "TSDown", directory, config) {
|
|
1015
|
+
await rm(directory, { recursive: true, force: true });
|
|
1410
1016
|
}
|
|
1411
1017
|
|
|
1412
1018
|
// ../tsdown/src/config.ts
|
|
@@ -1449,7 +1055,7 @@ var resolveOptions = async (userOptions) => {
|
|
|
1449
1055
|
});
|
|
1450
1056
|
writeDebug(" \u2699\uFE0F Resolving build options", workspaceConfig);
|
|
1451
1057
|
const stopwatch = getStopwatch("Build options resolution");
|
|
1452
|
-
const projectGraph = await
|
|
1058
|
+
const projectGraph = await createProjectGraphAsync3({
|
|
1453
1059
|
exitOnError: true
|
|
1454
1060
|
});
|
|
1455
1061
|
const projectJsonPath = joinPaths(
|
|
@@ -1457,13 +1063,13 @@ var resolveOptions = async (userOptions) => {
|
|
|
1457
1063
|
options.projectRoot,
|
|
1458
1064
|
"project.json"
|
|
1459
1065
|
);
|
|
1460
|
-
if (!
|
|
1066
|
+
if (!existsSync5(projectJsonPath)) {
|
|
1461
1067
|
throw new Error("Cannot find project.json configuration");
|
|
1462
1068
|
}
|
|
1463
|
-
const projectJsonFile = await
|
|
1069
|
+
const projectJsonFile = await hf.readFile(projectJsonPath, "utf8");
|
|
1464
1070
|
const projectJson = JSON.parse(projectJsonFile);
|
|
1465
1071
|
const projectName = projectJson.name;
|
|
1466
|
-
const projectConfigurations =
|
|
1072
|
+
const projectConfigurations = readProjectsConfigurationFromProjectGraph2(projectGraph);
|
|
1467
1073
|
if (!projectConfigurations?.projects?.[projectName]) {
|
|
1468
1074
|
throw new Error(
|
|
1469
1075
|
"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."
|
|
@@ -1474,7 +1080,7 @@ var resolveOptions = async (userOptions) => {
|
|
|
1474
1080
|
options.projectRoot,
|
|
1475
1081
|
"package.json"
|
|
1476
1082
|
);
|
|
1477
|
-
if (!
|
|
1083
|
+
if (!existsSync5(packageJsonPath)) {
|
|
1478
1084
|
throw new Error("Cannot find package.json configuration");
|
|
1479
1085
|
}
|
|
1480
1086
|
const debug = options.debug ?? (options.mode || workspaceConfig.mode) === "development";
|
|
@@ -1511,22 +1117,22 @@ var resolveOptions = async (userOptions) => {
|
|
|
1511
1117
|
projectGraph,
|
|
1512
1118
|
projectConfigurations
|
|
1513
1119
|
};
|
|
1514
|
-
result.env =
|
|
1120
|
+
result.env = defu2(
|
|
1515
1121
|
options.env,
|
|
1516
1122
|
getEnv("tsdown", result)
|
|
1517
1123
|
);
|
|
1518
1124
|
stopwatch();
|
|
1519
1125
|
return result;
|
|
1520
1126
|
};
|
|
1521
|
-
async function
|
|
1522
|
-
if (options.generatePackageJson !== false &&
|
|
1127
|
+
async function generatePackageJson(options) {
|
|
1128
|
+
if (options.generatePackageJson !== false && existsSync5(joinPaths(options.projectRoot, "package.json"))) {
|
|
1523
1129
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.workspaceConfig);
|
|
1524
1130
|
const stopwatch = getStopwatch("Write package.json file");
|
|
1525
1131
|
const packageJsonPath = joinPaths(options.projectRoot, "project.json");
|
|
1526
|
-
if (!
|
|
1132
|
+
if (!existsSync5(packageJsonPath)) {
|
|
1527
1133
|
throw new Error("Cannot find package.json configuration");
|
|
1528
1134
|
}
|
|
1529
|
-
const packageJsonFile = await
|
|
1135
|
+
const packageJsonFile = await hf.readFile(
|
|
1530
1136
|
joinPaths(
|
|
1531
1137
|
options.workspaceConfig.workspaceRoot,
|
|
1532
1138
|
options.projectRoot,
|
|
@@ -1589,7 +1195,7 @@ async function generatePackageJson2(options) {
|
|
|
1589
1195
|
},
|
|
1590
1196
|
packageJson.exports
|
|
1591
1197
|
);
|
|
1592
|
-
await
|
|
1198
|
+
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
1593
1199
|
stopwatch();
|
|
1594
1200
|
}
|
|
1595
1201
|
return options;
|
|
@@ -1605,7 +1211,7 @@ async function executeTSDown(options) {
|
|
|
1605
1211
|
stopwatch();
|
|
1606
1212
|
return options;
|
|
1607
1213
|
}
|
|
1608
|
-
async function
|
|
1214
|
+
async function copyBuildAssets(options) {
|
|
1609
1215
|
writeDebug(
|
|
1610
1216
|
` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`,
|
|
1611
1217
|
options.workspaceConfig
|
|
@@ -1623,20 +1229,20 @@ async function copyBuildAssets2(options) {
|
|
|
1623
1229
|
stopwatch();
|
|
1624
1230
|
return options;
|
|
1625
1231
|
}
|
|
1626
|
-
async function
|
|
1232
|
+
async function reportResults(options) {
|
|
1627
1233
|
writeSuccess(
|
|
1628
1234
|
` \u{1F4E6} The ${options.name} build completed successfully`,
|
|
1629
1235
|
options.workspaceConfig
|
|
1630
1236
|
);
|
|
1631
1237
|
}
|
|
1632
|
-
async function
|
|
1238
|
+
async function cleanOutputPath(options) {
|
|
1633
1239
|
if (options.clean !== false && options.workspaceConfig) {
|
|
1634
1240
|
writeDebug(
|
|
1635
1241
|
` \u{1F9F9} Cleaning ${options.name} output path: ${options.workspaceConfig}`,
|
|
1636
1242
|
options.workspaceConfig
|
|
1637
1243
|
);
|
|
1638
1244
|
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
1639
|
-
await
|
|
1245
|
+
await cleanDirectories(
|
|
1640
1246
|
options.name,
|
|
1641
1247
|
options.outDir,
|
|
1642
1248
|
options.workspaceConfig
|
|
@@ -1645,7 +1251,7 @@ async function cleanOutputPath2(options) {
|
|
|
1645
1251
|
}
|
|
1646
1252
|
return options;
|
|
1647
1253
|
}
|
|
1648
|
-
async function
|
|
1254
|
+
async function build(options) {
|
|
1649
1255
|
writeDebug(` ${brandIcon()} Executing Storm TSDown pipeline`);
|
|
1650
1256
|
const stopwatch = getStopwatch("TSDown pipeline");
|
|
1651
1257
|
try {
|
|
@@ -1657,13 +1263,13 @@ async function build3(options) {
|
|
|
1657
1263
|
opts.map(async (opt) => await resolveOptions(opt))
|
|
1658
1264
|
);
|
|
1659
1265
|
if (resolved.length > 0) {
|
|
1660
|
-
await
|
|
1661
|
-
await
|
|
1266
|
+
await cleanOutputPath(resolved[0]);
|
|
1267
|
+
await generatePackageJson(resolved[0]);
|
|
1662
1268
|
await Promise.all(
|
|
1663
1269
|
resolved.map(async (opt) => {
|
|
1664
1270
|
await executeTSDown(opt);
|
|
1665
|
-
await
|
|
1666
|
-
await
|
|
1271
|
+
await copyBuildAssets(opt);
|
|
1272
|
+
await reportResults(opt);
|
|
1667
1273
|
})
|
|
1668
1274
|
);
|
|
1669
1275
|
} else {
|
|
@@ -1690,7 +1296,7 @@ async function tsdownExecutorFn(options, context, config) {
|
|
|
1690
1296
|
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
1691
1297
|
);
|
|
1692
1298
|
}
|
|
1693
|
-
await
|
|
1299
|
+
await build({
|
|
1694
1300
|
...options,
|
|
1695
1301
|
projectRoot: (
|
|
1696
1302
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -1761,8 +1367,8 @@ var executor_default10 = withRunExecutor(
|
|
|
1761
1367
|
);
|
|
1762
1368
|
|
|
1763
1369
|
// ../workspace-tools/src/executors/unbuild/executor.ts
|
|
1764
|
-
import { defu as
|
|
1765
|
-
import { createJiti as
|
|
1370
|
+
import { defu as defu3 } from "defu";
|
|
1371
|
+
import { createJiti as createJiti5 } from "jiti";
|
|
1766
1372
|
async function unbuildExecutorFn(options, context, config) {
|
|
1767
1373
|
writeInfo("\u{1F4E6} Running Storm Unbuild executor on the workspace", config);
|
|
1768
1374
|
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
|
|
@@ -1780,7 +1386,7 @@ async function unbuildExecutorFn(options, context, config) {
|
|
|
1780
1386
|
"The Build process failed because the project's source root is not valid. Please run this command from a workspace root directory."
|
|
1781
1387
|
);
|
|
1782
1388
|
}
|
|
1783
|
-
const jiti =
|
|
1389
|
+
const jiti = createJiti5(config.workspaceRoot, {
|
|
1784
1390
|
fsCache: config.skipCache ? false : joinPaths(
|
|
1785
1391
|
config.workspaceRoot,
|
|
1786
1392
|
config.directories.cache || "node_modules/.cache/storm",
|
|
@@ -1792,7 +1398,7 @@ async function unbuildExecutorFn(options, context, config) {
|
|
|
1792
1398
|
jiti.esmResolve("@storm-software/unbuild/build")
|
|
1793
1399
|
);
|
|
1794
1400
|
await stormUnbuild.build(
|
|
1795
|
-
|
|
1401
|
+
defu3(
|
|
1796
1402
|
{
|
|
1797
1403
|
...options,
|
|
1798
1404
|
projectRoot: context.projectsConfigurations.projects[context.projectName].root,
|
|
@@ -3131,7 +2737,7 @@ import {
|
|
|
3131
2737
|
readJsonFile,
|
|
3132
2738
|
workspaceRoot
|
|
3133
2739
|
} from "@nx/devkit";
|
|
3134
|
-
import { existsSync as
|
|
2740
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
3135
2741
|
import { join as join2 } from "node:path";
|
|
3136
2742
|
import {
|
|
3137
2743
|
getNpmLockfileDependencies,
|
|
@@ -3400,8 +3006,8 @@ var RELEASE = recommended_default.release;
|
|
|
3400
3006
|
import {
|
|
3401
3007
|
readJsonFile as readJsonFile2
|
|
3402
3008
|
} from "@nx/devkit";
|
|
3403
|
-
import
|
|
3404
|
-
import { existsSync as
|
|
3009
|
+
import defu4 from "defu";
|
|
3010
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
3405
3011
|
import { dirname, join as join3 } from "node:path";
|
|
3406
3012
|
|
|
3407
3013
|
// ../workspace-tools/src/utils/typia-transform.ts
|