UNPKG

@storm-software/terraform-tools

Version:

Tools for managing Terraform infrastructure within a Nx workspace.

1,277 lines (1,185 loc) 123 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _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 _chunkOFLYCEQVjs = require('./chunk-OFLYCEQV.js'); var _chunk3GQAWCBQjs = require('./chunk-3GQAWCBQ.js'); // src/generators/init/init.ts var _devkit = require('@nx/devkit'); // ../workspace-tools/src/utils/cargo.ts var _child_process = require('child_process'); var _path = require('path'); var path6 = _interopRequireWildcard(_path); var INVALID_CARGO_ARGS = [ "allFeatures", "allTargets", "main", "outputPath", "package", "tsConfig" ]; var buildCargoCommand = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (baseCommand, options, context2) => { const args = []; if (options.toolchain && options.toolchain !== "stable") { args.push(`+${options.toolchain}`); } args.push(baseCommand); for (const [key, value] of Object.entries(options)) { if (key === "toolchain" || key === "release" || INVALID_CARGO_ARGS.includes(key)) { continue; } if (typeof value === "boolean") { if (value) { args.push(`--${key}`); } } else if (Array.isArray(value)) { for (const item of value) { args.push(`--${key}`, item); } } else { args.push(`--${key}`, String(value)); } } if (context2.projectName) { args.push("-p", context2.projectName); } if (options.allFeatures && !args.includes("--all-features")) { args.push("--all-features"); } if (options.allTargets && !args.includes("--all-targets")) { args.push("--all-targets"); } if (options.release && !args.includes("--profile")) { args.push("--release"); } if (options.outputPath && !args.includes("--target-dir")) { args.push("--target-dir", options.outputPath); } return args; }, "buildCargoCommand"); async function cargoCommand(...args) { console.log(`> cargo ${args.join(" ")}`); args.push("--color", "always"); return await Promise.resolve(runProcess("cargo", ...args)); } _chunk3GQAWCBQjs.__name.call(void 0, cargoCommand, "cargoCommand"); function cargoCommandSync(args = "", options) { const normalizedOptions = { stdio: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _2 => _2.stdio]), () => ( "inherit")), env: { ...process.env, ..._optionalChain([options, 'optionalAccess', _3 => _3.env]) } }; try { return { output: _child_process.execSync.call(void 0, `cargo ${args}`, { encoding: "utf8", windowsHide: true, stdio: normalizedOptions.stdio, env: normalizedOptions.env, maxBuffer: 1024 * 1024 * 10 }), success: true }; } catch (e) { return { output: e, success: false }; } } _chunk3GQAWCBQjs.__name.call(void 0, cargoCommandSync, "cargoCommandSync"); function cargoMetadata() { const output3 = cargoCommandSync("metadata --format-version=1", { stdio: "pipe" }); if (!output3.success) { console.error("Failed to get cargo metadata"); return null; } return JSON.parse(output3.output); } _chunk3GQAWCBQjs.__name.call(void 0, cargoMetadata, "cargoMetadata"); function runProcess(processCmd, ...args) { const metadata = cargoMetadata(); const targetDir = _nullishCoalesce(_optionalChain([metadata, 'optionalAccess', _4 => _4.target_directory]), () => ( _devkit.joinPathFragments.call(void 0, _devkit.workspaceRoot, "dist", "cargo"))); return new Promise((resolve) => { if (process.env.VERCEL) { return resolve({ success: true }); } _child_process.execSync.call(void 0, `${processCmd} ${args.join(" ")}`, { cwd: process.cwd(), env: { ...process.env, RUSTC_WRAPPER: "", CARGO_TARGET_DIR: targetDir, CARGO_BUILD_TARGET_DIR: targetDir }, windowsHide: true, stdio: [ "inherit", "inherit", "inherit" ] }); resolve({ success: true }); }); } _chunk3GQAWCBQjs.__name.call(void 0, runProcess, "runProcess"); // ../workspace-tools/src/executors/cargo-build/executor.ts async function cargoBuildExecutor(options, context2) { const command = buildCargoCommand("build", options, context2); return await cargoCommand(...command); } _chunk3GQAWCBQjs.__name.call(void 0, cargoBuildExecutor, "cargoBuildExecutor"); var executor_default = _chunkOFLYCEQVjs.withRunExecutor.call(void 0, "Cargo Build", cargoBuildExecutor, { skipReadingConfig: false, hooks: { applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options) => { options.outputPath ??= "dist/target/{projectRoot}"; options.toolchain ??= "stable"; return options; }, "applyDefaultOptions") } }); // ../workspace-tools/src/executors/cargo-check/executor.ts async function cargoCheckExecutor(options, context2) { const command = buildCargoCommand("check", options, context2); return await cargoCommand(...command); } _chunk3GQAWCBQjs.__name.call(void 0, cargoCheckExecutor, "cargoCheckExecutor"); var executor_default2 = _chunkOFLYCEQVjs.withRunExecutor.call(void 0, "Cargo Check", cargoCheckExecutor, { skipReadingConfig: false, hooks: { applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options) => { options.toolchain ??= "stable"; return options; }, "applyDefaultOptions") } }); // ../workspace-tools/src/executors/cargo-clippy/executor.ts async function cargoClippyExecutor(options, context2) { const command = buildCargoCommand("clippy", options, context2); return await cargoCommand(...command); } _chunk3GQAWCBQjs.__name.call(void 0, cargoClippyExecutor, "cargoClippyExecutor"); var executor_default3 = _chunkOFLYCEQVjs.withRunExecutor.call(void 0, "Cargo Clippy", cargoClippyExecutor, { skipReadingConfig: false, hooks: { applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options) => { options.toolchain ??= "stable"; options.fix ??= false; return options; }, "applyDefaultOptions") } }); // ../workspace-tools/src/executors/cargo-doc/executor.ts async function cargoDocExecutor(options, context2) { const opts = { ...options }; opts["no-deps"] = opts.noDeps; delete opts.noDeps; const command = buildCargoCommand("doc", options, context2); return await cargoCommand(...command); } _chunk3GQAWCBQjs.__name.call(void 0, cargoDocExecutor, "cargoDocExecutor"); var executor_default4 = _chunkOFLYCEQVjs.withRunExecutor.call(void 0, "Cargo Doc", cargoDocExecutor, { skipReadingConfig: false, hooks: { applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options) => { options.outputPath ??= "dist/docs/{projectRoot}"; options.toolchain ??= "stable"; options.release ??= options.profile ? false : true; options.allFeatures ??= true; options.lib ??= true; options.bins ??= true; options.examples ??= true; options.noDeps ??= false; return options; }, "applyDefaultOptions") } }); // ../workspace-tools/src/executors/cargo-format/executor.ts async function cargoFormatExecutor(options, context2) { const command = buildCargoCommand("fmt", options, context2); return await cargoCommand(...command); } _chunk3GQAWCBQjs.__name.call(void 0, cargoFormatExecutor, "cargoFormatExecutor"); var executor_default5 = _chunkOFLYCEQVjs.withRunExecutor.call(void 0, "Cargo Format", cargoFormatExecutor, { skipReadingConfig: false, hooks: { applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options) => { options.outputPath ??= "dist/target/{projectRoot}"; options.toolchain ??= "stable"; return options; }, "applyDefaultOptions") } }); // ../workspace-tools/src/executors/cargo-publish/executor.ts var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs); var _https = require('https'); var _https2 = _interopRequireDefault(_https); // ../workspace-tools/src/utils/toml.ts var _jtoml = require('@ltd/j-toml'); var _jtoml2 = _interopRequireDefault(_jtoml); // ../workspace-tools/src/executors/cargo-publish/executor.ts var LARGE_BUFFER = 1024 * 1e6; // ../esbuild/src/build.ts // ../build-tools/src/config.ts var DEFAULT_COMPILED_BANNER = `/***************************************** * * \u26A1 Built by Storm Software * *****************************************/ `; var DEFAULT_ENVIRONMENT = "production"; var DEFAULT_TARGET = "esnext"; var DEFAULT_ORGANIZATION = "storm-software"; // ../build-tools/src/plugins/swc.ts var _core = require('@swc/core'); // ../build-tools/src/plugins/ts-resolve.ts var _module = require('module'); var _resolve2 = require('resolve'); var _resolve3 = _interopRequireDefault(_resolve2); // ../build-tools/src/plugins/type-definitions.ts // ../build-tools/src/utilities/copy-assets.ts var _copyassetshandler = require('@nx/js/src/utils/assets/copy-assets-handler'); var _glob = require('glob'); var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises); var copyAssets = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => { const pendingAssets = Array.from(_nullishCoalesce(assets, () => ( []))); pendingAssets.push({ input: projectRoot, glob: "*.md", output: "." }); pendingAssets.push({ input: ".", glob: "LICENSE", output: "." }); if (generatePackageJson2 === false) { pendingAssets.push({ input: projectRoot, glob: "package.json", output: "." }); } if (includeSrc === true) { pendingAssets.push({ input: sourceRoot, glob: "**/{*.ts,*.tsx,*.js,*.jsx}", output: "src/" }); } _chunkOFLYCEQVjs.writeTrace.call(void 0, `\u{1F4DD} Copying the following assets to the output directory: ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${_chunkOFLYCEQVjs.joinPaths.call(void 0, outputPath, pendingAsset.output)}`).join("\n")}`, config); const assetHandler = new (0, _copyassetshandler.CopyAssetsHandler)({ projectDir: projectRoot, rootDir: config.workspaceRoot, outputDir: outputPath, assets: pendingAssets }); await assetHandler.processAllAssetsOnce(); if (includeSrc === true) { _chunkOFLYCEQVjs.writeDebug.call(void 0, `\u{1F4DD} Adding banner and writing source files: ${_chunkOFLYCEQVjs.joinPaths.call(void 0, outputPath, "src")}`, config); const files = await _glob.glob.call(void 0, [ _chunkOFLYCEQVjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.ts"), _chunkOFLYCEQVjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.tsx"), _chunkOFLYCEQVjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.js"), _chunkOFLYCEQVjs.joinPaths.call(void 0, config.workspaceRoot, outputPath, "src/**/*.jsx") ]); await Promise.allSettled(files.map(async (file) => _promises.writeFile.call(void 0, file, `${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""} ${await _promises.readFile.call(void 0, file, "utf8")} ${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`))); } }, "copyAssets"); // ../build-tools/src/utilities/generate-package-json.ts var _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils'); var _projectgraph = require('nx/src/project-graph/project-graph'); var addPackageDependencies = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (workspaceRoot3, projectRoot, projectName, packageJson) => { const projectGraph = _projectgraph.readCachedProjectGraph.call(void 0, ); const projectDependencies = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, projectGraph, workspaceRoot3, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true); const localPackages = []; for (const project of projectDependencies.dependencies.filter((dep) => dep.node.type === "lib" && _optionalChain([dep, 'access', _5 => _5.node, 'access', _6 => _6.data, 'optionalAccess', _7 => _7.root]) !== projectRoot && _optionalChain([dep, 'access', _8 => _8.node, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.root]) !== workspaceRoot3)) { const projectNode = project.node; if (projectNode.data.root) { const projectPackageJsonPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3, projectNode.data.root, "package.json"); if (_fs.existsSync.call(void 0, projectPackageJsonPath)) { const projectPackageJsonContent = await _promises.readFile.call(void 0, projectPackageJsonPath, "utf8"); const projectPackageJson = JSON.parse(projectPackageJsonContent); if (projectPackageJson.private !== true) { localPackages.push(projectPackageJson); } } } } if (localPackages.length > 0) { _chunkOFLYCEQVjs.writeTrace.call(void 0, `\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`); const projectJsonFile = await _promises.readFile.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, projectRoot, "project.json"), "utf8"); const projectJson = JSON.parse(projectJsonFile); const projectName2 = projectJson.name; const projectConfigurations = _projectgraph.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph); if (!_optionalChain([projectConfigurations, 'optionalAccess', _11 => _11.projects, 'optionalAccess', _12 => _12[projectName2]])) { 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."); } const implicitDependencies = _optionalChain([projectConfigurations, 'access', _13 => _13.projects, 'optionalAccess', _14 => _14[projectName2], 'access', _15 => _15.implicitDependencies, 'optionalAccess', _16 => _16.reduce, 'call', _17 => _17((ret, dep) => { if (_optionalChain([projectConfigurations, 'access', _18 => _18.projects, 'optionalAccess', _19 => _19[dep]])) { const depPackageJsonPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3, projectConfigurations.projects[dep].root, "package.json"); if (_fs.existsSync.call(void 0, depPackageJsonPath)) { const depPackageJsonContent = _fs.readFileSync.call(void 0, depPackageJsonPath, "utf8"); const depPackageJson = JSON.parse(depPackageJsonContent); if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) { ret.push(depPackageJson.name); } } } return ret; }, [])]); packageJson.dependencies = localPackages.reduce((ret, localPackage) => { if (!ret[localPackage.name] && !_optionalChain([implicitDependencies, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(localPackage.name)]) && _optionalChain([packageJson, 'access', _22 => _22.devDependencies, 'optionalAccess', _23 => _23[localPackage.name]]) === void 0) { ret[localPackage.name] = `^${localPackage.version || "0.0.1"}`; } return ret; }, _nullishCoalesce(packageJson.dependencies, () => ( {}))); packageJson.devDependencies = localPackages.reduce((ret, localPackage) => { if (!ret[localPackage.name] && _optionalChain([implicitDependencies, 'optionalAccess', _24 => _24.includes, 'call', _25 => _25(localPackage.name)]) && _optionalChain([packageJson, 'access', _26 => _26.dependencies, 'optionalAccess', _27 => _27[localPackage.name]]) === void 0) { ret[localPackage.name] = localPackage.version || "0.0.1"; } return ret; }, _nullishCoalesce(packageJson.devDependencies, () => ( {}))); } else { _chunkOFLYCEQVjs.writeTrace.call(void 0, "\u{1F4E6} No local packages dependencies to add to package.json"); } return packageJson; }, "addPackageDependencies"); var addWorkspacePackageJsonFields = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (config, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => { const workspaceRoot3 = config.workspaceRoot ? config.workspaceRoot : _chunkOFLYCEQVjs.findWorkspaceRoot.call(void 0, ); const workspacePackageJsonContent = await _promises.readFile.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3, "package.json"), "utf8"); const workspacePackageJson = JSON.parse(workspacePackageJsonContent); packageJson.type ??= "module"; packageJson.sideEffects ??= false; if (includeSrc === true) { let distSrc = sourceRoot.replace(projectRoot, ""); if (distSrc.startsWith("/")) { distSrc = distSrc.substring(1); } packageJson.source ??= `${_chunkOFLYCEQVjs.joinPaths.call(void 0, distSrc, "index.ts").replaceAll("\\", "/")}`; } packageJson.files ??= [ "dist/**/*" ]; if (includeSrc === true && !packageJson.files.includes("src")) { packageJson.files.push("src/**/*"); } packageJson.publishConfig ??= { access: "public" }; packageJson.description ??= workspacePackageJson.description; packageJson.homepage ??= workspacePackageJson.homepage; packageJson.bugs ??= workspacePackageJson.bugs; packageJson.license ??= workspacePackageJson.license; packageJson.keywords ??= workspacePackageJson.keywords; packageJson.funding ??= workspacePackageJson.funding; packageJson.author ??= workspacePackageJson.author; packageJson.maintainers ??= workspacePackageJson.maintainers; if (!packageJson.maintainers && packageJson.author) { packageJson.maintainers = [ packageJson.author ]; } packageJson.contributors ??= workspacePackageJson.contributors; if (!packageJson.contributors && packageJson.author) { packageJson.contributors = [ packageJson.author ]; } packageJson.repository ??= workspacePackageJson.repository; packageJson.repository.directory ??= projectRoot ? projectRoot : _chunkOFLYCEQVjs.joinPaths.call(void 0, "packages", projectName); return packageJson; }, "addWorkspacePackageJsonFields"); // ../build-tools/src/utilities/get-entry-points.ts var getEntryPoints = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (config, projectRoot, sourceRoot, entry, emitOnAll = false) => { const workspaceRoot3 = config.workspaceRoot || _chunkOFLYCEQVjs.findWorkspaceRoot.call(void 0, ); const entryPoints = []; if (entry) { if (typeof entry === "string") { entryPoints.push(entry); } else if (Array.isArray(entry)) { entryPoints.push(...entry); } else { entryPoints.push(...Object.values(entry)); } } if (emitOnAll) { entryPoints.push(_chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3, sourceRoot || projectRoot, "**/*.{ts,tsx}")); } const results = await Promise.all(entryPoints.map(async (entryPoint) => { const paths = []; if (entryPoint.includes("*")) { const files = await _glob.glob.call(void 0, entryPoint, { withFileTypes: true, ignore: [ "**/node_modules/**" ] }); paths.push(...files.reduce((ret, filePath) => { const result = _chunkOFLYCEQVjs.correctPaths.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, filePath.path, filePath.name).replaceAll(_chunkOFLYCEQVjs.correctPaths.call(void 0, workspaceRoot3), "").replaceAll(_chunkOFLYCEQVjs.correctPaths.call(void 0, projectRoot), "")); if (result) { _chunkOFLYCEQVjs.writeDebug.call(void 0, `Trying to add entry point ${result} at "${_chunkOFLYCEQVjs.joinPaths.call(void 0, filePath.path, filePath.name)}"`, config); if (!paths.includes(result)) { paths.push(result); } } return ret; }, [])); } else { _chunkOFLYCEQVjs.writeDebug.call(void 0, `Trying to add entry point ${entryPoint}"`, config); if (!paths.includes(entryPoint)) { paths.push(entryPoint); } } return paths; })); return results.filter(Boolean).reduce((ret, result) => { result.forEach((res) => { if (res && !ret.includes(res)) { ret.push(res); } }); return ret; }, []); }, "getEntryPoints"); // ../build-tools/src/utilities/get-env.ts var getEnv = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (builder, options) => { return { STORM_BUILD: builder, STORM_ORG: options.orgName || DEFAULT_ORGANIZATION, STORM_NAME: options.name, STORM_MODE: options.mode || DEFAULT_ENVIRONMENT, STORM_PLATFORM: options.platform, STORM_FORMAT: JSON.stringify(options.format), STORM_TARGET: JSON.stringify(options.target), ...options.env }; }, "getEnv"); // ../build-tools/src/utilities/read-nx-config.ts // ../build-tools/src/utilities/task-graph.ts var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph'); // ../esbuild/src/build.ts var _chokidar = require('chokidar'); var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu); var _estoolkit = require('es-toolkit'); var _compat = require('es-toolkit/compat'); var _esbuild = require('esbuild'); var esbuild2 = _interopRequireWildcard(_esbuild); var esbuild = _interopRequireWildcard(_esbuild); var _globby = require('globby'); var _findworkspaceroot = require('nx/src/utils/find-workspace-root'); // ../esbuild/src/base/renderer-engine.ts var _sourcemap = require('source-map'); // ../esbuild/src/utilities/output-file.ts var outputFile = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (filepath, data, options) => { await _fs2.default.promises.mkdir(path6.default.dirname(filepath), { recursive: true }); await _fs2.default.promises.writeFile(filepath, data, options); }, "outputFile"); // ../esbuild/src/base/renderer-engine.ts var parseSourceMap = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (map2) => { return typeof map2 === "string" ? JSON.parse(map2) : map2; }, "parseSourceMap"); var isJS = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (path7) => /\.(js|mjs|cjs)$/.test(path7), "isJS"); var isCSS = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (path7) => /\.css$/.test(path7), "isCSS"); var getSourcemapComment = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (inline, map2, filepath, isCssFile) => { if (!map2) return ""; const prefix = isCssFile ? "/*" : "//"; const suffix = isCssFile ? " */" : ""; const url = inline ? `data:application/json;base64,${Buffer.from(typeof map2 === "string" ? map2 : JSON.stringify(map2)).toString("base64")}` : `${path6.default.basename(filepath)}.map`; return `${prefix}# sourceMappingURL=${url}${suffix}`; }, "getSourcemapComment"); var RendererEngine = class { static { _chunk3GQAWCBQjs.__name.call(void 0, this, "RendererEngine"); } #renderers; #options; constructor(renderers) { this.#renderers = renderers; } setOptions(options) { this.#options = options; } getOptions() { if (!this.#options) { throw new Error(`Renderer options is not set`); } return this.#options; } modifyEsbuildOptions(options) { for (const renderer of this.#renderers) { if (renderer.esbuildOptions) { renderer.esbuildOptions.call(this.getOptions(), options); } } } async buildStarted() { for (const renderer of this.#renderers) { if (renderer.buildStart) { await renderer.buildStart.call(this.getOptions()); } } } async buildFinished({ outputFiles, metafile }) { const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => { if (isJS(file.path) || isCSS(file.path)) { let relativePath = path6.default.relative(this.getOptions().config.workspaceRoot, file.path); if (!relativePath.startsWith("\\\\?\\")) { relativePath = relativePath.replace(/\\/g, "/"); } const meta = _optionalChain([metafile, 'optionalAccess', _28 => _28.outputs, 'access', _29 => _29[relativePath]]); return { type: "chunk", path: file.path, code: file.text, map: _optionalChain([outputFiles, 'access', _30 => _30.find, 'call', _31 => _31((f) => f.path === `${file.path}.map`), 'optionalAccess', _32 => _32.text]), entryPoint: _optionalChain([meta, 'optionalAccess', _33 => _33.entryPoint]), exports: _optionalChain([meta, 'optionalAccess', _34 => _34.exports]), imports: _optionalChain([meta, 'optionalAccess', _35 => _35.imports]) }; } else { return { type: "asset", path: file.path, contents: file.contents }; } }); const writtenFiles = []; await Promise.all(files.map(async (info) => { for (const renderer of this.#renderers) { if (info.type === "chunk" && renderer.renderChunk) { const result = await renderer.renderChunk.call(this.getOptions(), info.code, info); if (result) { info.code = result.code; if (result.map) { const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(info.map)); const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(parseSourceMap(result.map)); const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer); generator.applySourceMap(originalConsumer, info.path); info.map = generator.toJSON(); originalConsumer.destroy(); newConsumer.destroy(); } } } } const inlineSourceMap = this.#options.sourcemap === "inline"; const contents = info.type === "chunk" ? info.code + getSourcemapComment(inlineSourceMap, info.map, info.path, isCSS(info.path)) : info.contents; await outputFile(info.path, contents, { mode: info.type === "chunk" ? info.mode : void 0 }); writtenFiles.push({ get name() { return path6.default.relative(process.cwd(), info.path); }, get size() { return contents.length; } }); if (info.type === "chunk" && info.map && !inlineSourceMap) { const map2 = typeof info.map === "string" ? JSON.parse(info.map) : info.map; const outPath = `${info.path}.map`; const contents2 = JSON.stringify(map2); await outputFile(outPath, contents2); writtenFiles.push({ get name() { return path6.default.relative(process.cwd(), outPath); }, get size() { return contents2.length; } }); } })); for (const renderer of this.#renderers) { if (renderer.buildEnd) { await renderer.buildEnd.call(this.getOptions(), { writtenFiles }); } } } }; // ../esbuild/src/clean.ts async function cleanDirectories(name = "ESBuild", directory, config) { await _promises.rm.call(void 0, directory, { recursive: true, force: true }); } _chunk3GQAWCBQjs.__name.call(void 0, cleanDirectories, "cleanDirectories"); // ../esbuild/src/plugins/esm-split-code-to-cjs.ts var esmSplitCodeToCjsPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => ({ name: "storm:esm-split-code-to-cjs", setup(build4) { build4.onEnd(async (result) => { const outFiles = Object.keys(_nullishCoalesce(_optionalChain([result, 'access', _36 => _36.metafile, 'optionalAccess', _37 => _37.outputs]), () => ( {}))); const jsFiles = outFiles.filter((f) => f.endsWith("js")); await esbuild.build({ outdir: resolvedOptions.outdir, entryPoints: jsFiles, allowOverwrite: true, format: "cjs", logLevel: "error", packages: "external" }); }); } }), "esmSplitCodeToCjsPlugin"); // ../esbuild/src/plugins/fix-imports.ts var fixImportsPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => ({ name: "storm:fix-imports", setup(build4) { build4.onResolve({ filter: /^spdx-exceptions/ }, () => { return { path: _chunk3GQAWCBQjs.__require.resolve("spdx-exceptions") }; }); build4.onResolve({ filter: /^spdx-license-ids/ }, () => { return { path: _chunk3GQAWCBQjs.__require.resolve("spdx-license-ids") }; }); } }), "fixImportsPlugin"); // ../esbuild/src/plugins/native-node-module.ts var nativeNodeModulesPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => { return { name: "native-node-modules", setup(build4) { build4.onResolve({ filter: /\.node$/, namespace: "file" }, (args) => { const resolvedId = _chunk3GQAWCBQjs.__require.resolve(args.path, { paths: [ args.resolveDir ] }); if (resolvedId.endsWith(".node")) { return { path: resolvedId, namespace: "node-file" }; } return { path: resolvedId }; }); build4.onLoad({ filter: /.*/, namespace: "node-file" }, (args) => { return { contents: ` import path from ${JSON.stringify(args.path)} try { module.exports = require(path) } catch {} `, resolveDir: _path.dirname.call(void 0, args.path) }; }); build4.onResolve({ filter: /\.node$/, namespace: "node-file" }, (args) => ({ path: args.path, namespace: "file" })); const opts = build4.initialOptions; opts.loader = opts.loader || {}; opts.loader[".node"] = "file"; } }; }, "nativeNodeModulesPlugin"); // ../esbuild/src/plugins/node-protocol.ts var nodeProtocolPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => { const nodeProtocol = "node:"; return { name: "node-protocol-plugin", setup({ onResolve }) { onResolve({ filter: /^node:/ }, ({ path: path7 }) => ({ path: path7.slice(nodeProtocol.length), external: true })); } }; }, "nodeProtocolPlugin"); // ../esbuild/src/plugins/on-error.ts var onErrorPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => ({ name: "storm:on-error", setup(build4) { build4.onEnd((result) => { if (result.errors.length > 0 && process.env.WATCH !== "true") { _chunkOFLYCEQVjs.writeError.call(void 0, `The following errors occurred during the build: ${result.errors.map((error) => error.text).join("\n")} `, resolvedOptions.config); throw new Error("Storm esbuild process failed with errors."); } }); } }), "onErrorPlugin"); // ../esbuild/src/plugins/resolve-paths.ts function resolvePathsConfig(options, cwd) { if (_optionalChain([options, 'optionalAccess', _38 => _38.compilerOptions, 'optionalAccess', _39 => _39.paths])) { const paths = Object.entries(options.compilerOptions.paths); const resolvedPaths = paths.map(([key, paths2]) => { return [ key, paths2.map((v) => path6.default.resolve(cwd, v)) ]; }); return Object.fromEntries(resolvedPaths); } if (options.extends) { const extendsPath = path6.default.resolve(cwd, options.extends); const extendsDir = path6.default.dirname(extendsPath); const extendsConfig = _chunk3GQAWCBQjs.__require.call(void 0, extendsPath); return resolvePathsConfig(extendsConfig, extendsDir); } return []; } _chunk3GQAWCBQjs.__name.call(void 0, resolvePathsConfig, "resolvePathsConfig"); var resolvePathsPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => ({ name: "storm:resolve-paths", setup(build4) { const parentTsConfig = build4.initialOptions.tsconfig ? _chunk3GQAWCBQjs.__require.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, build4.initialOptions.tsconfig)) : _chunk3GQAWCBQjs.__require.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, "tsconfig.json")); const resolvedTsPaths = resolvePathsConfig(parentTsConfig, options.projectRoot); const packagesRegex = new RegExp(`^(${Object.keys(resolvedTsPaths).join("|")})$`); build4.onResolve({ filter: packagesRegex }, (args) => { if (_optionalChain([build4, 'access', _40 => _40.initialOptions, 'access', _41 => _41.external, 'optionalAccess', _42 => _42.includes, 'call', _43 => _43(args.path)])) { return { path: args.path, external: true }; } return { path: `${resolvedTsPaths[args.path][0]}/index.ts` }; }); } }), "resolvePathsPlugin"); // ../esbuild/src/plugins/tsc.ts var _apiextractor = require('@microsoft/api-extractor'); function bundleTypeDefinitions(filename, outfile, externals, options) { const { dependencies, peerDependencies, devDependencies } = _chunk3GQAWCBQjs.__require.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, options.projectRoot, "package.json")); const dependenciesKeys = Object.keys(_nullishCoalesce(dependencies, () => ( {}))).flatMap((p) => [ p, getTypeDependencyPackageName(p) ]); const peerDependenciesKeys = Object.keys(_nullishCoalesce(peerDependencies, () => ( {}))).flatMap((p) => [ p, getTypeDependencyPackageName(p) ]); const devDependenciesKeys = Object.keys(_nullishCoalesce(devDependencies, () => ( {}))).flatMap((p) => [ p, getTypeDependencyPackageName(p) ]); const includeDeps = devDependenciesKeys; const excludeDeps = /* @__PURE__ */ new Set([ ...dependenciesKeys, ...peerDependenciesKeys, ...externals ]); const bundledPackages = includeDeps.filter((dep) => !excludeDeps.has(dep)); const extractorConfig = _apiextractor.ExtractorConfig.prepare({ configObject: { projectFolder: options.projectRoot, mainEntryPointFilePath: filename, bundledPackages, compiler: { tsconfigFilePath: options.tsconfig, overrideTsconfig: { compilerOptions: { paths: {} // bug with api extract + paths } } }, dtsRollup: { enabled: true, untrimmedFilePath: _chunkOFLYCEQVjs.joinPaths.call(void 0, options.outdir, `${outfile}.d.ts`) }, tsdocMetadata: { enabled: false } }, packageJsonFullPath: _chunkOFLYCEQVjs.joinPaths.call(void 0, options.projectRoot, "package.json"), configObjectFullPath: void 0 }); const extractorResult = _apiextractor.Extractor.invoke(extractorConfig, { showVerboseMessages: true, localBuild: true }); if (extractorResult.succeeded === false) { _chunkOFLYCEQVjs.writeError.call(void 0, `API Extractor completed with ${extractorResult.errorCount} ${extractorResult.errorCount === 1 ? "error" : "errors"}`); throw new Error("API Extractor completed with errors"); } } _chunk3GQAWCBQjs.__name.call(void 0, bundleTypeDefinitions, "bundleTypeDefinitions"); var tscPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => ({ name: "storm:tsc", setup(build4) { if (options.emitTypes === false) { return; } build4.onStart(async () => { if (process.env.WATCH !== "true" && process.env.DEV !== "true") { await _chunkOFLYCEQVjs.run.call(void 0, resolvedOptions.config, `pnpm exec tsc --project ${resolvedOptions.tsconfig}`, resolvedOptions.config.workspaceRoot); } if (resolvedOptions.bundle && resolvedOptions.entryPoints && resolvedOptions.entryPoints.length > 0 && resolvedOptions.entryPoints[0] && resolvedOptions.entryPoints[0].endsWith(".ts")) { const sourceRoot = resolvedOptions.sourceRoot.replaceAll(resolvedOptions.projectRoot, ""); const typeOutDir = resolvedOptions.outdir; const entryPoint = resolvedOptions.entryPoints[0].replace(sourceRoot, "").replace(/\.ts$/, ""); const bundlePath = _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.outdir, entryPoint); let dtsPath; if (_fs.existsSync.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`))) { dtsPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint}.d.ts`); } else if (_fs.existsSync.call(void 0, _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`))) { dtsPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, resolvedOptions.config.workspaceRoot, typeOutDir, `${entryPoint.replace(/^src\//, "")}.d.ts`); } const ext = resolvedOptions.format === "esm" ? "d.mts" : "d.ts"; if (process.env.WATCH !== "true" && process.env.DEV !== "true") { bundleTypeDefinitions(dtsPath, bundlePath, _nullishCoalesce(resolvedOptions.external, () => ( [])), resolvedOptions); const dtsContents = await _promises2.default.readFile(`${bundlePath}.d.ts`, "utf8"); await _promises2.default.writeFile(`${bundlePath}.${ext}`, dtsContents); } else { await _promises2.default.writeFile(`${bundlePath}.${ext}`, `export * from './${entryPoint}'`); } } }); } }), "tscPlugin"); function getTypeDependencyPackageName(npmPackage) { if (npmPackage.startsWith("@")) { const [scope, name] = npmPackage.split("/"); return `@types/${_optionalChain([scope, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(1)])}__${name}`; } return `@types/${npmPackage}`; } _chunk3GQAWCBQjs.__name.call(void 0, getTypeDependencyPackageName, "getTypeDependencyPackageName"); // ../esbuild/src/config.ts var getDefaultBuildPlugins = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (options, resolvedOptions) => [ nodeProtocolPlugin(options, resolvedOptions), resolvePathsPlugin(options, resolvedOptions), fixImportsPlugin(options, resolvedOptions), nativeNodeModulesPlugin(options, resolvedOptions), esmSplitCodeToCjsPlugin(options, resolvedOptions), tscPlugin(options, resolvedOptions), onErrorPlugin(options, resolvedOptions) ], "getDefaultBuildPlugins"); var DEFAULT_BUILD_OPTIONS = { platform: "node", target: "node22", format: "cjs", external: [], logLevel: "error", tsconfig: "tsconfig.json", mode: "production", keepNames: true, metafile: true, injectShims: true, color: true, watch: false, bundle: true, clean: true, debug: false, resolveExtensions: [ ".tsx", ".ts", ".cts", ".mts", ".jsx", ".js", ".cjs", ".mjs", ".css", ".json" ], loader: { ".aac": "file", ".css": "file", ".eot": "file", ".flac": "file", ".gif": "file", ".jpeg": "file", ".jpg": "file", ".mp3": "file", ".mp4": "file", ".ogg": "file", ".otf": "file", ".png": "file", ".svg": "file", ".ttf": "file", ".wav": "file", ".webm": "file", ".webp": "file", ".woff": "file", ".woff2": "file" }, banner: DEFAULT_COMPILED_BANNER }; // ../esbuild/src/plugins/deps-check.ts var unusedIgnore = [ // these are our dev dependencies /@types\/.*?/, /@typescript-eslint.*?/, /eslint.*?/, "esbuild", "husky", "is-ci", "lint-staged", "prettier", "typescript", "ts-node", "ts-jest", "@swc/core", "@swc/jest", "jest", // these are missing 3rd party deps "spdx-exceptions", "spdx-license-ids", // type-only, so it is not detected "ts-toolbelt", // these are indirectly used by build "buffer" ]; var missingIgnore = [ ".prisma", "@prisma/client", "ts-toolbelt" ]; var depsCheckPlugin = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, (bundle) => ({ name: "storm:deps-check", setup(build4) { const pkgJsonPath = path6.default.join(process.cwd(), "package.json"); const pkgContents = _chunk3GQAWCBQjs.__require.call(void 0, pkgJsonPath); const regDependencies = Object.keys(_nullishCoalesce(pkgContents["dependencies"], () => ( {}))); const devDependencies = Object.keys(_nullishCoalesce(pkgContents["devDependencies"], () => ( {}))); const peerDependencies = Object.keys(_nullishCoalesce(pkgContents["peerDependencies"], () => ( {}))); const dependencies = [ ...regDependencies, ...bundle ? devDependencies : [] ]; const collectedDependencies = /* @__PURE__ */ new Set(); const onlyPackages = /^[^./](?!:)|^\.[^./]|^\.\.[^/]/; build4.onResolve({ filter: onlyPackages }, (args) => { if (args.importer.includes(process.cwd())) { if (args.path[0] === "@") { const [org, pkg] = args.path.split("/"); collectedDependencies.add(`${org}/${pkg}`); } else { const [pkg] = args.path.split("/"); collectedDependencies.add(pkg); } } return { external: true }; }); build4.onEnd(() => { const unusedDependencies = [ ...dependencies ].filter((dep) => { return !collectedDependencies.has(dep) || _module.builtinModules.includes(dep); }); const missingDependencies = [ ...collectedDependencies ].filter((dep) => { return !dependencies.includes(dep) && !_module.builtinModules.includes(dep); }); const filteredUnusedDeps = unusedDependencies.filter((dep) => { return !unusedIgnore.some((pattern) => dep.match(pattern)); }); const filteredMissingDeps = missingDependencies.filter((dep) => { return !missingIgnore.some((pattern) => dep.match(pattern)) && !peerDependencies.includes(dep); }); _chunkOFLYCEQVjs.writeWarning.call(void 0, `Unused Dependencies: ${JSON.stringify(filteredUnusedDeps)}`); _chunkOFLYCEQVjs.writeError.call(void 0, `Missing Dependencies: ${JSON.stringify(filteredMissingDeps)}`); if (filteredMissingDeps.length > 0) { throw new Error(`Missing dependencies detected - please install them: ${JSON.stringify(filteredMissingDeps)} `); } }); } }), "depsCheckPlugin"); // ../esbuild/src/renderers/shebang.ts var shebangRenderer = { name: "shebang", renderChunk(_, __, info) { if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) { info.mode = 493; } } }; // ../esbuild/src/utilities/helpers.ts function handleSync(fn) { try { return fn(); } catch (error_) { return error_; } } _chunk3GQAWCBQjs.__name.call(void 0, handleSync, "handleSync"); async function handleAsync(fn) { try { return await fn(); } catch (error_) { return error_; } } _chunk3GQAWCBQjs.__name.call(void 0, handleAsync, "handleAsync"); var handle = handleSync; handle.async = handleAsync; var skip = Symbol("skip"); function transduceSync(list, transformer) { const transduced = []; for (const [i, element_] of list.entries()) { const transformed = transformer(element_, i); if (transformed !== skip) { transduced[transduced.length] = transformed; } } return transduced; } _chunk3GQAWCBQjs.__name.call(void 0, transduceSync, "transduceSync"); async function transduceAsync(list, transformer) { const transduced = []; await Promise.all(list.entries().map(async ([i, element_]) => { const transformed = await transformer(element_, i); if (transformed !== skip) { transduced[transduced.length] = transformed; } })); return transduced; } _chunk3GQAWCBQjs.__name.call(void 0, transduceAsync, "transduceAsync"); var transduce = transduceSync; transduce.async = transduceAsync; function pipeSync(fn, ...fns) { return (...args) => { let result = fn(...args); for (let i = 0; result !== skip && i < fns.length; ++i) { result = _optionalChain([fns, 'access', _46 => _46[i], 'optionalCall', _47 => _47(result)]); } return result; }; } _chunk3GQAWCBQjs.__name.call(void 0, pipeSync, "pipeSync"); function pipeAsync(fn, ...fns) { return async (...args) => { let result = await fn(...args); for (let i = 0; result !== skip && i < fns.length; ++i) { result = await _optionalChain([fns, 'access', _48 => _48[i], 'optionalCall', _49 => _49(result)]); } return result; }; } _chunk3GQAWCBQjs.__name.call(void 0, pipeAsync, "pipeAsync"); var pipe = pipeSync; pipe.async = pipeAsync; // ../esbuild/src/build.ts var resolveOptions = /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (userOptions) => { const projectRoot = userOptions.projectRoot; const workspaceRoot3 = _findworkspaceroot.findWorkspaceRoot.call(void 0, projectRoot); if (!workspaceRoot3) { throw new Error("Cannot find Nx workspace root"); } const config = await _chunkOFLYCEQVjs.getConfig.call(void 0, workspaceRoot3.dir); _chunkOFLYCEQVjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config); const stopwatch = _chunkOFLYCEQVjs.getStopwatch.call(void 0, "Build options resolution"); const projectGraph = await _devkit.createProjectGraphAsync.call(void 0, { exitOnError: true }); const projectJsonPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3.dir, projectRoot, "project.json"); if (!_fs.existsSync.call(void 0, projectJsonPath)) { throw new Error("Cannot find project.json configuration"); } const projectJsonFile = await _promises2.default.readFile(projectJsonPath, "utf8"); const projectJson = JSON.parse(projectJsonFile); const projectName = projectJson.name; const projectConfigurations = _devkit.readProjectsConfigurationFromProjectGraph.call(void 0, projectGraph); if (!_optionalChain([projectConfigurations, 'optionalAccess', _50 => _50.projects, 'optionalAccess', _51 => _51[projectName]])) { 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."); } const options = _defu2.default.call(void 0, userOptions, DEFAULT_BUILD_OPTIONS); options.name ??= `${projectName}-${options.format}`; options.target ??= DEFAULT_TARGET; const packageJsonPath = _chunkOFLYCEQVjs.joinPaths.call(void 0, workspaceRoot3.dir, options.projectRoot, "package.json"); if (!_fs.existsSync.call(void 0, packageJsonPath)) { throw new Error("Cannot find package.json configuration"); } const env = getEnv("esbuild", options); const result = { ...options, config, mainFields: options.platform === "node" ? [ "module", "main" ] : [ "browser", "module", "main" ], ...userOptions, tsconfig: _chunkOFLYCEQVjs.joinPaths.call(void 0, projectRoot, userOptions.tsconfig ? userOptions.tsconfig.replace(projectRoot, "") : "tsconfig.json"), format: options.format || "cjs", entryPoints: await getEntryPoints(config, projectRoot, projectJson.sourceRoot, _nullishCoalesce(userOptions.entry, () => ( "./src/index.ts")), false), outdir: userOptions.outputPath || _chunkOFLYCEQVjs.joinPaths.call(void 0, "dist", projectRoot), distDir: userOptions.distDir || "dist", plugins: [], name: userOptions.name || projectName, projectConfigurations, projectName, projectGraph, sourceRoot: userOptions.sourceRoot || projectJson.sourceRoot || _chunkOFLYCEQVjs.joinPaths.call(void 0, projectRoot, "src"), minify: userOptions.minify || !userOptions.debug, verbose: userOptions.verbose || _chunkOFLYCEQVjs.isVerbose.call(void 0, ) || userOptions.debug === true, includeSrc: userOptions.includeSrc === true, metafile: userOptions.metafile !== false, generatePackageJson: userOptions.generatePackageJson !== false, clean: userOptions.clean !== false, assets: _nullishCoalesce(userOptions.assets, () => ( [])), injectShims: userOptions.injectShims !== true, bundle: userOptions.bundle !== false, keepNames: true, watch: userOptions.watch === true, footer: userOptions.footer, banner: { js: options.banner || DEFAULT_COMPILED_BANNER, css: options.banner || DEFAULT_COMPILED_BANNER }, splitting: options.format === "iife" ? false : typeof options.splitting === "boolean" ? options.splitting : options.format === "esm", treeShaking: options.format === "esm", env, define: { STORM_FORMAT: JSON.stringify(options.format || "cjs"), ...options.format === "cjs" && options.injectShims ? { "import.meta.url": "importMetaUrl" } : {}, ...options.define, ...Object.keys(env || {}).reduce((res, key) => { const value = JSON.stringify(env[key]); const safeKey = key.replaceAll("(", "").replaceAll(")", ""); return { ...res, [`process.env.${safeKey}`]: value,