@storm-software/esbuild 0.31.53 → 0.31.55

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 CHANGED
@@ -1,21 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkTBKEDSCTcjs = require('./chunk-TBKEDSCT.cjs');
4
+ var _chunkCJ75TYKDcjs = require('./chunk-CJ75TYKD.cjs');
5
5
  require('./chunk-HTG42YEH.cjs');
6
- require('./chunk-LT3W6G2F.cjs');
6
+ require('./chunk-QYSYE4DQ.cjs');
7
+ require('./chunk-EZGTDCYM.cjs');
7
8
  require('./chunk-S6M44SSZ.cjs');
8
9
  require('./chunk-WRBUO7H6.cjs');
9
10
  require('./chunk-KYYHVNV4.cjs');
10
11
  require('./chunk-SSEYS7LI.cjs');
11
- require('./chunk-DNS6VZGL.cjs');
12
+ require('./chunk-LRVWPYIC.cjs');
13
+ require('./chunk-OPVRR2SU.cjs');
12
14
  require('./chunk-ASASYO7N.cjs');
13
15
  require('./chunk-OFHMWQZF.cjs');
14
16
  require('./chunk-XITTOHOG.cjs');
15
17
  require('./chunk-CGFDQ5AJ.cjs');
16
- require('./chunk-EZGTDCYM.cjs');
17
18
  require('./chunk-BGYQAVKQ.cjs');
18
19
 
19
20
 
20
21
 
21
- exports.build = _chunkTBKEDSCTcjs.build; exports.cleanOutputPath = _chunkTBKEDSCTcjs.cleanOutputPath;
22
+ exports.build = _chunkCJ75TYKDcjs.build; exports.cleanOutputPath = _chunkCJ75TYKDcjs.cleanOutputPath;
package/dist/build.js CHANGED
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  build,
3
3
  cleanOutputPath
4
- } from "./chunk-UPETSYAV.js";
4
+ } from "./chunk-CEE2QW7F.js";
5
5
  import "./chunk-6AQHAXIU.js";
6
- import "./chunk-L2BA5U5E.js";
6
+ import "./chunk-CFK6TJYF.js";
7
+ import "./chunk-GWG4HOQ6.js";
7
8
  import "./chunk-T5272PC2.js";
8
9
  import "./chunk-LYDEMC26.js";
9
10
  import "./chunk-E4SGSVQK.js";
10
11
  import "./chunk-Q3LOGZKI.js";
11
- import "./chunk-ADHPYHOT.js";
12
+ import "./chunk-6OP2VX6Y.js";
13
+ import "./chunk-A6P3N2E2.js";
12
14
  import "./chunk-SLCDPX5I.js";
13
15
  import "./chunk-E2ITHLMT.js";
14
16
  import "./chunk-YMTDVMD6.js";
15
17
  import "./chunk-YNQ45EAM.js";
16
- import "./chunk-GWG4HOQ6.js";
17
18
  import "./chunk-3GQAWCBQ.js";
18
19
  export {
19
20
  build,
@@ -93,7 +93,7 @@ __name(bundleTypeDefinitions, "bundleTypeDefinitions");
93
93
  var tscPlugin = /* @__PURE__ */ __name((options, resolvedOptions) => ({
94
94
  name: "storm:tsc",
95
95
  setup(build) {
96
- if (options.emitTypes === false) {
96
+ if (options.dts === false) {
97
97
  return;
98
98
  }
99
99
  build.onStart(async () => {
@@ -0,0 +1,163 @@
1
+ import {
2
+ writeError
3
+ } from "./chunk-E2ITHLMT.js";
4
+ import {
5
+ __name
6
+ } from "./chunk-3GQAWCBQ.js";
7
+
8
+ // src/tsc.ts
9
+ import { loadTsConfig } from "bundle-require";
10
+ import defu from "defu";
11
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, normalize } from "node:path";
13
+ import ts from "typescript";
14
+ function ensureTempDeclarationDir(workspaceConfig) {
15
+ const root = workspaceConfig.directories.temp || join(workspaceConfig.workspaceRoot, "tmp");
16
+ const dirPath = join(root, ".tsc", "declaration");
17
+ if (existsSync(dirPath)) {
18
+ return dirPath;
19
+ }
20
+ mkdirSync(dirPath, {
21
+ recursive: true
22
+ });
23
+ const gitIgnorePath = join(root, ".tsc", ".gitignore");
24
+ writeFileSync(gitIgnorePath, "**/*\n");
25
+ return dirPath;
26
+ }
27
+ __name(ensureTempDeclarationDir, "ensureTempDeclarationDir");
28
+ function slash(path) {
29
+ const isExtendedLengthPath = path.startsWith("\\\\?\\");
30
+ if (isExtendedLengthPath) {
31
+ return path;
32
+ }
33
+ return path.replace(/\\/g, "/");
34
+ }
35
+ __name(slash, "slash");
36
+ function toAbsolutePath(workspaceConfig, p, cwd) {
37
+ if (isAbsolute(p)) {
38
+ return p;
39
+ }
40
+ return slash(normalize(join(cwd || workspaceConfig.workspaceRoot, p)));
41
+ }
42
+ __name(toAbsolutePath, "toAbsolutePath");
43
+ var AliasPool = class AliasPool2 {
44
+ static {
45
+ __name(this, "AliasPool");
46
+ }
47
+ seen = /* @__PURE__ */ new Set();
48
+ assign(name) {
49
+ let suffix = 0;
50
+ let alias = name === "default" ? "default_alias" : name;
51
+ while (this.seen.has(alias)) {
52
+ alias = `${name}_alias_${++suffix}`;
53
+ if (suffix >= 1e3) {
54
+ throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
55
+ }
56
+ }
57
+ this.seen.add(alias);
58
+ return alias;
59
+ }
60
+ };
61
+ function getExports(workspaceConfig, program, fileMapping) {
62
+ const checker = program.getTypeChecker();
63
+ const aliasPool = new AliasPool();
64
+ const assignAlias = aliasPool.assign.bind(aliasPool);
65
+ function extractExports(sourceFileName) {
66
+ const cwd = program.getCurrentDirectory();
67
+ sourceFileName = toAbsolutePath(workspaceConfig, sourceFileName, cwd);
68
+ const sourceFile = program.getSourceFile(sourceFileName);
69
+ if (!sourceFile) {
70
+ return [];
71
+ }
72
+ const destFileName = fileMapping.get(sourceFileName);
73
+ if (!destFileName) {
74
+ return [];
75
+ }
76
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
77
+ if (!moduleSymbol) {
78
+ return [];
79
+ }
80
+ const exports = [];
81
+ const exportSymbols = checker.getExportsOfModule(moduleSymbol);
82
+ exportSymbols.forEach((symbol) => {
83
+ const name = symbol.getName();
84
+ exports.push({
85
+ kind: "named",
86
+ sourceFileName,
87
+ destFileName,
88
+ name,
89
+ alias: assignAlias(name),
90
+ isTypeOnly: false
91
+ });
92
+ });
93
+ return exports;
94
+ }
95
+ __name(extractExports, "extractExports");
96
+ return program.getRootFileNames().flatMap(extractExports);
97
+ }
98
+ __name(getExports, "getExports");
99
+ function emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles = true, customTransformers) {
100
+ const fileMapping = /* @__PURE__ */ new Map();
101
+ const writeFile = /* @__PURE__ */ __name((fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
102
+ const sourceFile = sourceFiles?.[0];
103
+ const sourceFileName = sourceFile?.fileName;
104
+ if (sourceFileName && !fileName.endsWith(".map")) {
105
+ const cwd = program.getCurrentDirectory();
106
+ fileMapping.set(toAbsolutePath(workspaceConfig, sourceFileName, cwd), toAbsolutePath(workspaceConfig, fileName, cwd));
107
+ }
108
+ return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
109
+ }, "writeFile");
110
+ const emitResult = program.emit(void 0, writeFile, void 0, emitOnlyDtsFiles, customTransformers);
111
+ const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
112
+ const diagnosticMessages = [];
113
+ diagnostics.forEach((diagnostic) => {
114
+ if (diagnostic.file) {
115
+ const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
116
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
117
+ diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
118
+ } else {
119
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
120
+ diagnosticMessages.push(message);
121
+ }
122
+ });
123
+ const diagnosticMessage = diagnosticMessages.join("\n");
124
+ if (diagnosticMessage) {
125
+ writeError(`Failed to emit declaration files.
126
+
127
+ ${diagnosticMessage}`, workspaceConfig);
128
+ throw new Error("TypeScript compilation failed");
129
+ }
130
+ return fileMapping;
131
+ }
132
+ __name(emitDtsFiles, "emitDtsFiles");
133
+ function emitDts(workspaceConfig, tsconfig, tsconfigRaw, emitOnlyDtsFiles = true, customTransformers) {
134
+ const rawTsconfig = loadTsConfig(workspaceConfig.workspaceRoot, tsconfig);
135
+ if (!rawTsconfig) {
136
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${workspaceConfig.workspaceRoot}`);
137
+ }
138
+ const declarationDir = ensureTempDeclarationDir(workspaceConfig);
139
+ const parsedTsconfig = ts.parseJsonConfigFileContent(defu({
140
+ compilerOptions: {
141
+ // Enable declaration emit and disable javascript emit
142
+ noEmit: false,
143
+ declaration: true,
144
+ declarationMap: true,
145
+ declarationDir,
146
+ emitDeclarationOnly: true
147
+ }
148
+ }, tsconfigRaw?.compilerOptions ?? {}, rawTsconfig.data ?? {}), ts.sys, tsconfig ? dirname(tsconfig) : "./");
149
+ const options = parsedTsconfig.options;
150
+ const host = ts.createCompilerHost(options);
151
+ const program = ts.createProgram(parsedTsconfig.fileNames, options, host);
152
+ const fileMapping = emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles, customTransformers);
153
+ return getExports(workspaceConfig, program, fileMapping);
154
+ }
155
+ __name(emitDts, "emitDts");
156
+
157
+ export {
158
+ ensureTempDeclarationDir,
159
+ slash,
160
+ toAbsolutePath,
161
+ emitDtsFiles,
162
+ emitDts
163
+ };
@@ -11,7 +11,10 @@ import {
11
11
  getConfig,
12
12
  getDefaultBuildPlugins,
13
13
  getEnv
14
- } from "./chunk-L2BA5U5E.js";
14
+ } from "./chunk-CFK6TJYF.js";
15
+ import {
16
+ emitDts
17
+ } from "./chunk-A6P3N2E2.js";
15
18
  import {
16
19
  depsCheckPlugin
17
20
  } from "./chunk-SLCDPX5I.js";
@@ -536,6 +539,7 @@ async function executeEsBuild(context2) {
536
539
  options.inject === {}) {
537
540
  delete options.inject;
538
541
  }
542
+ delete options.dts;
539
543
  delete options.env;
540
544
  delete options.name;
541
545
  delete options.assets;
@@ -571,6 +575,16 @@ ${formatLogMessage({
571
575
  return context2;
572
576
  }
573
577
  __name(executeEsBuild, "executeEsBuild");
578
+ async function executeTypescript(context2) {
579
+ if (context2.result?.errors.length === 0 && context2.options.dts) {
580
+ writeDebug(` \u{1F4CB} Running TypeScript Compiler for ${context2.options.name}`, context2.options.config);
581
+ const stopwatch = getStopwatch(`${context2.options.name} asset copy`);
582
+ await emitDts(context2.options.config, context2.options.tsconfig, context2.options.tsconfigRaw, true);
583
+ stopwatch();
584
+ }
585
+ return context2;
586
+ }
587
+ __name(executeTypescript, "executeTypescript");
574
588
  async function copyBuildAssets(context2) {
575
589
  if (context2.result?.errors.length === 0) {
576
590
  writeDebug(` \u{1F4CB} Copying asset files to output directory: ${context2.options.outdir}`, context2.options.config);
@@ -587,6 +601,9 @@ async function reportResults(context2) {
587
601
  writeWarning(` \u{1F6A7} The following warnings occurred during the build: ${context2.result.warnings.map((warning) => warning.text).join("\n")}`, context2.options.config);
588
602
  }
589
603
  writeSuccess(` \u{1F4E6} The ${context2.options.name} build completed successfully`, context2.options.config);
604
+ } else if (context2.result?.errors && context2.result?.errors.length > 0) {
605
+ writeError(` \u274C The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`, context2.options.config);
606
+ throw new Error(`The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`);
590
607
  }
591
608
  }
592
609
  __name(reportResults, "reportResults");
@@ -641,7 +658,7 @@ async function build2(options) {
641
658
  throw new Error("No build options were provided");
642
659
  }
643
660
  void transduce.async(opts, dependencyCheck);
644
- await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
661
+ await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeTypescript, executeEsBuild, copyBuildAssets, reportResults));
645
662
  writeSuccess(" \u{1F3C1} ESBuild pipeline build completed successfully");
646
663
  } catch (error) {
647
664
  writeFatal("Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
@@ -1,3 +1,6 @@
1
+ import {
2
+ fixImportsPlugin
3
+ } from "./chunk-GWG4HOQ6.js";
1
4
  import {
2
5
  nativeNodeModulesPlugin
3
6
  } from "./chunk-T5272PC2.js";
@@ -12,7 +15,7 @@ import {
12
15
  } from "./chunk-Q3LOGZKI.js";
13
16
  import {
14
17
  tscPlugin
15
- } from "./chunk-ADHPYHOT.js";
18
+ } from "./chunk-6OP2VX6Y.js";
16
19
  import {
17
20
  COLOR_KEYS,
18
21
  LogLevel,
@@ -36,9 +39,6 @@ import {
36
39
  import {
37
40
  esmSplitCodeToCjsPlugin
38
41
  } from "./chunk-YNQ45EAM.js";
39
- import {
40
- fixImportsPlugin
41
- } from "./chunk-GWG4HOQ6.js";
42
42
  import {
43
43
  __name
44
44
  } from "./chunk-3GQAWCBQ.js";
@@ -346,12 +346,12 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
346
346
  configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
347
347
  workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
348
348
  directories: {
349
- cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
350
- data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
351
- config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
352
- temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
353
- log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
354
- build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
349
+ cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : process.env[`${prefix}CACHE_DIRECTORY`] ? correctPaths(process.env[`${prefix}CACHE_DIRECTORY`]) : void 0,
350
+ data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : process.env[`${prefix}DATA_DIRECTORY`] ? correctPaths(process.env[`${prefix}DATA_DIRECTORY`]) : void 0,
351
+ config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : process.env[`${prefix}CONFIG_DIRECTORY`] ? correctPaths(process.env[`${prefix}CONFIG_DIRECTORY`]) : void 0,
352
+ temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : process.env[`${prefix}TEMP_DIRECTORY`] ? correctPaths(process.env[`${prefix}TEMP_DIRECTORY`]) : void 0,
353
+ log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : process.env[`${prefix}LOG_DIRECTORY`] ? correctPaths(process.env[`${prefix}LOG_DIRECTORY`]) : void 0,
354
+ build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : process.env[`${prefix}BUILD_DIRECTORY`] ? correctPaths(process.env[`${prefix}BUILD_DIRECTORY`]) : void 0
355
355
  },
356
356
  skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
357
357
  mode: (process.env[`${prefix}MODE`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
@@ -571,21 +571,27 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
571
571
  if (config.directories) {
572
572
  if (!config.skipCache && config.directories.cache) {
573
573
  process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
574
+ process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
574
575
  }
575
576
  if (config.directories.data) {
576
577
  process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
578
+ process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
577
579
  }
578
580
  if (config.directories.config) {
579
581
  process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
582
+ process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
580
583
  }
581
584
  if (config.directories.temp) {
582
585
  process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
586
+ process.env[`${prefix}TEMP_DIRECTORY`] = process.env[`${prefix}TEMP_DIR`];
583
587
  }
584
588
  if (config.directories.log) {
585
589
  process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
590
+ process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
586
591
  }
587
592
  if (config.directories.build) {
588
593
  process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
594
+ process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
589
595
  }
590
596
  }
591
597
  if (config.skipCache !== void 0) {
@@ -851,7 +857,7 @@ var getDefaultBuildPlugins = /* @__PURE__ */ __name((options, resolvedOptions) =
851
857
  var DEFAULT_BUILD_OPTIONS = {
852
858
  platform: "node",
853
859
  target: "node22",
854
- format: "cjs",
860
+ format: "esm",
855
861
  external: [],
856
862
  logLevel: "error",
857
863
  tsconfig: "tsconfig.json",
@@ -11,7 +11,10 @@ var _chunkHTG42YEHcjs = require('./chunk-HTG42YEH.cjs');
11
11
 
12
12
 
13
13
 
14
- var _chunkLT3W6G2Fcjs = require('./chunk-LT3W6G2F.cjs');
14
+ var _chunkQYSYE4DQcjs = require('./chunk-QYSYE4DQ.cjs');
15
+
16
+
17
+ var _chunkOPVRR2SUcjs = require('./chunk-OPVRR2SU.cjs');
15
18
 
16
19
 
17
20
  var _chunkASASYO7Ncjs = require('./chunk-ASASYO7N.cjs');
@@ -358,7 +361,7 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
358
361
  if (!workspaceRoot) {
359
362
  throw new Error("Cannot find Nx workspace root");
360
363
  }
361
- const config = await _chunkLT3W6G2Fcjs.getConfig.call(void 0, workspaceRoot.dir);
364
+ const config = await _chunkQYSYE4DQcjs.getConfig.call(void 0, workspaceRoot.dir);
362
365
  _chunkOFHMWQZFcjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config);
363
366
  const stopwatch = _chunkOFHMWQZFcjs.getStopwatch.call(void 0, "Build options resolution");
364
367
  const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, {
@@ -375,14 +378,14 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
375
378
  if (!_optionalChain([projectConfigurations, 'optionalAccess', _14 => _14.projects, 'optionalAccess', _15 => _15[projectName]])) {
376
379
  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.");
377
380
  }
378
- const options = _defu2.default.call(void 0, userOptions, _chunkLT3W6G2Fcjs.DEFAULT_BUILD_OPTIONS);
381
+ const options = _defu2.default.call(void 0, userOptions, _chunkQYSYE4DQcjs.DEFAULT_BUILD_OPTIONS);
379
382
  options.name ??= `${projectName}-${options.format}`;
380
- options.target ??= _chunkLT3W6G2Fcjs.DEFAULT_TARGET;
383
+ options.target ??= _chunkQYSYE4DQcjs.DEFAULT_TARGET;
381
384
  const packageJsonPath = _chunkXITTOHOGcjs.joinPaths.call(void 0, workspaceRoot.dir, options.projectRoot, "package.json");
382
385
  if (!_fs.existsSync.call(void 0, packageJsonPath)) {
383
386
  throw new Error("Cannot find package.json configuration");
384
387
  }
385
- const env = _chunkLT3W6G2Fcjs.getEnv.call(void 0, "esbuild", options);
388
+ const env = _chunkQYSYE4DQcjs.getEnv.call(void 0, "esbuild", options);
386
389
  const result = {
387
390
  ...options,
388
391
  config,
@@ -419,8 +422,8 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
419
422
  watch: userOptions.watch === true,
420
423
  footer: userOptions.footer,
421
424
  banner: {
422
- js: options.banner || _chunkLT3W6G2Fcjs.DEFAULT_COMPILED_BANNER,
423
- css: options.banner || _chunkLT3W6G2Fcjs.DEFAULT_COMPILED_BANNER
425
+ js: options.banner || _chunkQYSYE4DQcjs.DEFAULT_COMPILED_BANNER,
426
+ css: options.banner || _chunkQYSYE4DQcjs.DEFAULT_COMPILED_BANNER
424
427
  },
425
428
  splitting: options.format === "iife" ? false : typeof options.splitting === "boolean" ? options.splitting : options.format === "esm",
426
429
  treeShaking: options.format === "esm",
@@ -446,7 +449,7 @@ var resolveOptions = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async
446
449
  options.format === "esm" && options.injectShims && options.platform === "node" ? _chunkXITTOHOGcjs.joinPaths.call(void 0, __dirname, "../assets/esm_shims.js") : void 0
447
450
  ].filter(Boolean)
448
451
  };
449
- result.plugins = _nullishCoalesce(userOptions.plugins, () => ( _chunkLT3W6G2Fcjs.getDefaultBuildPlugins.call(void 0, userOptions, result)));
452
+ result.plugins = _nullishCoalesce(userOptions.plugins, () => ( _chunkQYSYE4DQcjs.getDefaultBuildPlugins.call(void 0, userOptions, result)));
450
453
  if (options.inject && Array.isArray(options.inject) && options.inject.length > 0) {
451
454
  result.inject = options.inject.reduce((ret, inj) => {
452
455
  if (inj && typeof inj === "string" && ret.includes(inj)) {
@@ -473,8 +476,8 @@ async function generatePackageJson(context2) {
473
476
  if (!packageJson) {
474
477
  throw new Error("Cannot find package.json configuration file");
475
478
  }
476
- packageJson = await _chunkLT3W6G2Fcjs.addPackageDependencies.call(void 0, context2.options.config.workspaceRoot, context2.options.projectRoot, context2.options.projectName, packageJson);
477
- packageJson = await _chunkLT3W6G2Fcjs.addWorkspacePackageJsonFields.call(void 0, context2.options.config, context2.options.projectRoot, context2.options.sourceRoot, context2.options.projectName, false, packageJson);
479
+ packageJson = await _chunkQYSYE4DQcjs.addPackageDependencies.call(void 0, context2.options.config.workspaceRoot, context2.options.projectRoot, context2.options.projectName, packageJson);
480
+ packageJson = await _chunkQYSYE4DQcjs.addWorkspacePackageJsonFields.call(void 0, context2.options.config, context2.options.projectRoot, context2.options.sourceRoot, context2.options.projectName, false, packageJson);
478
481
  packageJson.exports ??= {};
479
482
  packageJson.exports["./package.json"] ??= "./package.json";
480
483
  packageJson.exports["."] ??= `.${context2.options.distDir ? `/${context2.options.distDir}` : ""}/index.js`;
@@ -536,6 +539,7 @@ async function executeEsBuild(context2) {
536
539
  options.inject === {}) {
537
540
  delete options.inject;
538
541
  }
542
+ delete options.dts;
539
543
  delete options.env;
540
544
  delete options.name;
541
545
  delete options.assets;
@@ -571,22 +575,35 @@ ${_chunkOFHMWQZFcjs.formatLogMessage.call(void 0, {
571
575
  return context2;
572
576
  }
573
577
  _chunkBGYQAVKQcjs.__name.call(void 0, executeEsBuild, "executeEsBuild");
578
+ async function executeTypescript(context2) {
579
+ if (_optionalChain([context2, 'access', _16 => _16.result, 'optionalAccess', _17 => _17.errors, 'access', _18 => _18.length]) === 0 && context2.options.dts) {
580
+ _chunkOFHMWQZFcjs.writeDebug.call(void 0, ` \u{1F4CB} Running TypeScript Compiler for ${context2.options.name}`, context2.options.config);
581
+ const stopwatch = _chunkOFHMWQZFcjs.getStopwatch.call(void 0, `${context2.options.name} asset copy`);
582
+ await _chunkOPVRR2SUcjs.emitDts.call(void 0, context2.options.config, context2.options.tsconfig, context2.options.tsconfigRaw, true);
583
+ stopwatch();
584
+ }
585
+ return context2;
586
+ }
587
+ _chunkBGYQAVKQcjs.__name.call(void 0, executeTypescript, "executeTypescript");
574
588
  async function copyBuildAssets(context2) {
575
- if (_optionalChain([context2, 'access', _16 => _16.result, 'optionalAccess', _17 => _17.errors, 'access', _18 => _18.length]) === 0) {
589
+ if (_optionalChain([context2, 'access', _19 => _19.result, 'optionalAccess', _20 => _20.errors, 'access', _21 => _21.length]) === 0) {
576
590
  _chunkOFHMWQZFcjs.writeDebug.call(void 0, ` \u{1F4CB} Copying asset files to output directory: ${context2.options.outdir}`, context2.options.config);
577
591
  const stopwatch = _chunkOFHMWQZFcjs.getStopwatch.call(void 0, `${context2.options.name} asset copy`);
578
- await _chunkLT3W6G2Fcjs.copyAssets.call(void 0, context2.options.config, _nullishCoalesce(context2.options.assets, () => ( [])), context2.options.outdir, context2.options.projectRoot, context2.options.sourceRoot, true, false);
592
+ await _chunkQYSYE4DQcjs.copyAssets.call(void 0, context2.options.config, _nullishCoalesce(context2.options.assets, () => ( [])), context2.options.outdir, context2.options.projectRoot, context2.options.sourceRoot, true, false);
579
593
  stopwatch();
580
594
  }
581
595
  return context2;
582
596
  }
583
597
  _chunkBGYQAVKQcjs.__name.call(void 0, copyBuildAssets, "copyBuildAssets");
584
598
  async function reportResults(context2) {
585
- if (_optionalChain([context2, 'access', _19 => _19.result, 'optionalAccess', _20 => _20.errors, 'access', _21 => _21.length]) === 0) {
599
+ if (_optionalChain([context2, 'access', _22 => _22.result, 'optionalAccess', _23 => _23.errors, 'access', _24 => _24.length]) === 0) {
586
600
  if (context2.result.warnings.length > 0) {
587
601
  _chunkOFHMWQZFcjs.writeWarning.call(void 0, ` \u{1F6A7} The following warnings occurred during the build: ${context2.result.warnings.map((warning) => warning.text).join("\n")}`, context2.options.config);
588
602
  }
589
603
  _chunkOFHMWQZFcjs.writeSuccess.call(void 0, ` \u{1F4E6} The ${context2.options.name} build completed successfully`, context2.options.config);
604
+ } else if (_optionalChain([context2, 'access', _25 => _25.result, 'optionalAccess', _26 => _26.errors]) && _optionalChain([context2, 'access', _27 => _27.result, 'optionalAccess', _28 => _28.errors, 'access', _29 => _29.length]) > 0) {
605
+ _chunkOFHMWQZFcjs.writeError.call(void 0, ` \u274C The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`, context2.options.config);
606
+ throw new Error(`The ${context2.options.name} build failed with the following errors: ${context2.result.errors.map((error) => error.text).join("\n")}`);
590
607
  }
591
608
  }
592
609
  _chunkBGYQAVKQcjs.__name.call(void 0, reportResults, "reportResults");
@@ -641,7 +658,7 @@ async function build2(options) {
641
658
  throw new Error("No build options were provided");
642
659
  }
643
660
  void transduce.async(opts, dependencyCheck);
644
- await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeEsBuild, copyBuildAssets, reportResults));
661
+ await transduce.async(await createOptions(opts), pipe.async(generateContext, cleanOutputPath, generatePackageJson, executeTypescript, executeEsBuild, copyBuildAssets, reportResults));
645
662
  _chunkOFHMWQZFcjs.writeSuccess.call(void 0, " \u{1F3C1} ESBuild pipeline build completed successfully");
646
663
  } catch (error) {
647
664
  _chunkOFHMWQZFcjs.writeFatal.call(void 0, "Fatal errors that the build process could not recover from have occured. The build process has been terminated.");
@@ -93,7 +93,7 @@ _chunkBGYQAVKQcjs.__name.call(void 0, bundleTypeDefinitions, "bundleTypeDefiniti
93
93
  var tscPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options, resolvedOptions) => ({
94
94
  name: "storm:tsc",
95
95
  setup(build) {
96
- if (options.emitTypes === false) {
96
+ if (options.dts === false) {
97
97
  return;
98
98
  }
99
99
  build.onStart(async () => {
@@ -0,0 +1,163 @@
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; } var _class;
2
+
3
+ var _chunkOFHMWQZFcjs = require('./chunk-OFHMWQZF.cjs');
4
+
5
+
6
+ var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
7
+
8
+ // src/tsc.ts
9
+ var _bundlerequire = require('bundle-require');
10
+ var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
11
+ var _fs = require('fs');
12
+ var _path = require('path');
13
+ var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
14
+ function ensureTempDeclarationDir(workspaceConfig) {
15
+ const root = workspaceConfig.directories.temp || _path.join.call(void 0, workspaceConfig.workspaceRoot, "tmp");
16
+ const dirPath = _path.join.call(void 0, root, ".tsc", "declaration");
17
+ if (_fs.existsSync.call(void 0, dirPath)) {
18
+ return dirPath;
19
+ }
20
+ _fs.mkdirSync.call(void 0, dirPath, {
21
+ recursive: true
22
+ });
23
+ const gitIgnorePath = _path.join.call(void 0, root, ".tsc", ".gitignore");
24
+ _fs.writeFileSync.call(void 0, gitIgnorePath, "**/*\n");
25
+ return dirPath;
26
+ }
27
+ _chunkBGYQAVKQcjs.__name.call(void 0, ensureTempDeclarationDir, "ensureTempDeclarationDir");
28
+ function slash(path) {
29
+ const isExtendedLengthPath = path.startsWith("\\\\?\\");
30
+ if (isExtendedLengthPath) {
31
+ return path;
32
+ }
33
+ return path.replace(/\\/g, "/");
34
+ }
35
+ _chunkBGYQAVKQcjs.__name.call(void 0, slash, "slash");
36
+ function toAbsolutePath(workspaceConfig, p, cwd) {
37
+ if (_path.isAbsolute.call(void 0, p)) {
38
+ return p;
39
+ }
40
+ return slash(_path.normalize.call(void 0, _path.join.call(void 0, cwd || workspaceConfig.workspaceRoot, p)));
41
+ }
42
+ _chunkBGYQAVKQcjs.__name.call(void 0, toAbsolutePath, "toAbsolutePath");
43
+ var AliasPool = (_class = class AliasPool2 {constructor() { _class.prototype.__init.call(this); }
44
+ static {
45
+ _chunkBGYQAVKQcjs.__name.call(void 0, this, "AliasPool");
46
+ }
47
+ __init() {this.seen = /* @__PURE__ */ new Set()}
48
+ assign(name) {
49
+ let suffix = 0;
50
+ let alias = name === "default" ? "default_alias" : name;
51
+ while (this.seen.has(alias)) {
52
+ alias = `${name}_alias_${++suffix}`;
53
+ if (suffix >= 1e3) {
54
+ throw new Error("Alias generation exceeded limit. Possible infinite loop detected.");
55
+ }
56
+ }
57
+ this.seen.add(alias);
58
+ return alias;
59
+ }
60
+ }, _class);
61
+ function getExports(workspaceConfig, program, fileMapping) {
62
+ const checker = program.getTypeChecker();
63
+ const aliasPool = new AliasPool();
64
+ const assignAlias = aliasPool.assign.bind(aliasPool);
65
+ function extractExports(sourceFileName) {
66
+ const cwd = program.getCurrentDirectory();
67
+ sourceFileName = toAbsolutePath(workspaceConfig, sourceFileName, cwd);
68
+ const sourceFile = program.getSourceFile(sourceFileName);
69
+ if (!sourceFile) {
70
+ return [];
71
+ }
72
+ const destFileName = fileMapping.get(sourceFileName);
73
+ if (!destFileName) {
74
+ return [];
75
+ }
76
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
77
+ if (!moduleSymbol) {
78
+ return [];
79
+ }
80
+ const exports = [];
81
+ const exportSymbols = checker.getExportsOfModule(moduleSymbol);
82
+ exportSymbols.forEach((symbol) => {
83
+ const name = symbol.getName();
84
+ exports.push({
85
+ kind: "named",
86
+ sourceFileName,
87
+ destFileName,
88
+ name,
89
+ alias: assignAlias(name),
90
+ isTypeOnly: false
91
+ });
92
+ });
93
+ return exports;
94
+ }
95
+ _chunkBGYQAVKQcjs.__name.call(void 0, extractExports, "extractExports");
96
+ return program.getRootFileNames().flatMap(extractExports);
97
+ }
98
+ _chunkBGYQAVKQcjs.__name.call(void 0, getExports, "getExports");
99
+ function emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles = true, customTransformers) {
100
+ const fileMapping = /* @__PURE__ */ new Map();
101
+ const writeFile = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
102
+ const sourceFile = _optionalChain([sourceFiles, 'optionalAccess', _ => _[0]]);
103
+ const sourceFileName = _optionalChain([sourceFile, 'optionalAccess', _2 => _2.fileName]);
104
+ if (sourceFileName && !fileName.endsWith(".map")) {
105
+ const cwd = program.getCurrentDirectory();
106
+ fileMapping.set(toAbsolutePath(workspaceConfig, sourceFileName, cwd), toAbsolutePath(workspaceConfig, fileName, cwd));
107
+ }
108
+ return host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
109
+ }, "writeFile");
110
+ const emitResult = program.emit(void 0, writeFile, void 0, emitOnlyDtsFiles, customTransformers);
111
+ const diagnostics = _typescript2.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
112
+ const diagnosticMessages = [];
113
+ diagnostics.forEach((diagnostic) => {
114
+ if (diagnostic.file) {
115
+ const { line, character } = _typescript2.default.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
116
+ const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
117
+ diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
118
+ } else {
119
+ const message = _typescript2.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
120
+ diagnosticMessages.push(message);
121
+ }
122
+ });
123
+ const diagnosticMessage = diagnosticMessages.join("\n");
124
+ if (diagnosticMessage) {
125
+ _chunkOFHMWQZFcjs.writeError.call(void 0, `Failed to emit declaration files.
126
+
127
+ ${diagnosticMessage}`, workspaceConfig);
128
+ throw new Error("TypeScript compilation failed");
129
+ }
130
+ return fileMapping;
131
+ }
132
+ _chunkBGYQAVKQcjs.__name.call(void 0, emitDtsFiles, "emitDtsFiles");
133
+ function emitDts(workspaceConfig, tsconfig, tsconfigRaw, emitOnlyDtsFiles = true, customTransformers) {
134
+ const rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, workspaceConfig.workspaceRoot, tsconfig);
135
+ if (!rawTsconfig) {
136
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${workspaceConfig.workspaceRoot}`);
137
+ }
138
+ const declarationDir = ensureTempDeclarationDir(workspaceConfig);
139
+ const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent(_defu2.default.call(void 0, {
140
+ compilerOptions: {
141
+ // Enable declaration emit and disable javascript emit
142
+ noEmit: false,
143
+ declaration: true,
144
+ declarationMap: true,
145
+ declarationDir,
146
+ emitDeclarationOnly: true
147
+ }
148
+ }, _nullishCoalesce(_optionalChain([tsconfigRaw, 'optionalAccess', _3 => _3.compilerOptions]), () => ( {})), _nullishCoalesce(rawTsconfig.data, () => ( {}))), _typescript2.default.sys, tsconfig ? _path.dirname.call(void 0, tsconfig) : "./");
149
+ const options = parsedTsconfig.options;
150
+ const host = _typescript2.default.createCompilerHost(options);
151
+ const program = _typescript2.default.createProgram(parsedTsconfig.fileNames, options, host);
152
+ const fileMapping = emitDtsFiles(workspaceConfig, program, host, emitOnlyDtsFiles, customTransformers);
153
+ return getExports(workspaceConfig, program, fileMapping);
154
+ }
155
+ _chunkBGYQAVKQcjs.__name.call(void 0, emitDts, "emitDts");
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ exports.ensureTempDeclarationDir = ensureTempDeclarationDir; exports.slash = slash; exports.toAbsolutePath = toAbsolutePath; exports.emitDtsFiles = emitDtsFiles; exports.emitDts = emitDts;