@mastra/deployer 0.0.0-a2a-20250421213654

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.
Files changed (58) hide show
  1. package/LICENSE.md +46 -0
  2. package/README.md +159 -0
  3. package/dist/_tsup-dts-rollup.d.cts +548 -0
  4. package/dist/_tsup-dts-rollup.d.ts +548 -0
  5. package/dist/build/analyze.cjs +10 -0
  6. package/dist/build/analyze.d.cts +1 -0
  7. package/dist/build/analyze.d.ts +1 -0
  8. package/dist/build/analyze.js +1 -0
  9. package/dist/build/bundler.cjs +14 -0
  10. package/dist/build/bundler.d.cts +2 -0
  11. package/dist/build/bundler.d.ts +2 -0
  12. package/dist/build/bundler.js +1 -0
  13. package/dist/build/index.cjs +46 -0
  14. package/dist/build/index.d.cts +9 -0
  15. package/dist/build/index.d.ts +9 -0
  16. package/dist/build/index.js +5 -0
  17. package/dist/bundler/index.cjs +10 -0
  18. package/dist/bundler/index.d.cts +1 -0
  19. package/dist/bundler/index.d.ts +1 -0
  20. package/dist/bundler/index.js +1 -0
  21. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  22. package/dist/chunk-4AYFLP6G.js +227 -0
  23. package/dist/chunk-4VC5Z4YR.cjs +391 -0
  24. package/dist/chunk-54KOF3NB.cjs +137 -0
  25. package/dist/chunk-5QD7CDGY.js +306 -0
  26. package/dist/chunk-6QMONK4A.cjs +2 -0
  27. package/dist/chunk-AOSWYZKN.js +138 -0
  28. package/dist/chunk-C4JT7CIH.js +1 -0
  29. package/dist/chunk-IMGVLBV7.cjs +149 -0
  30. package/dist/chunk-KTYDROLB.js +136 -0
  31. package/dist/chunk-LA6Y6GAB.cjs +312 -0
  32. package/dist/chunk-Q6OKTZNC.cjs +316 -0
  33. package/dist/chunk-USZDOFES.js +301 -0
  34. package/dist/chunk-UV4RQQ3R.js +359 -0
  35. package/dist/chunk-WVBUOQT6.js +111 -0
  36. package/dist/chunk-Z7KAM3CZ.cjs +164 -0
  37. package/dist/index.cjs +190 -0
  38. package/dist/index.d.cts +6 -0
  39. package/dist/index.d.ts +6 -0
  40. package/dist/index.js +149 -0
  41. package/dist/server/index.cjs +3952 -0
  42. package/dist/server/index.d.cts +2 -0
  43. package/dist/server/index.d.ts +2 -0
  44. package/dist/server/index.js +3944 -0
  45. package/dist/services/index.cjs +18 -0
  46. package/dist/services/index.d.cts +3 -0
  47. package/dist/services/index.d.ts +3 -0
  48. package/dist/services/index.js +1 -0
  49. package/dist/templates/instrumentation-template.js +89 -0
  50. package/dist/validator/custom-resolver.cjs +52 -0
  51. package/dist/validator/custom-resolver.d.cts +1 -0
  52. package/dist/validator/custom-resolver.d.ts +1 -0
  53. package/dist/validator/custom-resolver.js +50 -0
  54. package/dist/validator/loader.cjs +7 -0
  55. package/dist/validator/loader.d.cts +1 -0
  56. package/dist/validator/loader.d.ts +1 -0
  57. package/dist/validator/loader.js +4 -0
  58. package/package.json +140 -0
@@ -0,0 +1,359 @@
1
+ import { spawn } from 'child_process';
2
+ import { Transform } from 'stream';
3
+ import * as fs3 from 'fs';
4
+ import fs3__default from 'fs';
5
+ import fsPromises from 'fs/promises';
6
+ import path, { dirname } from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ import { MastraBase } from '@mastra/core/base';
9
+ import fsExtra, { readJSON, writeJSON, ensureFile } from 'fs-extra/esm';
10
+
11
+ // src/deploy/log.ts
12
+ var createPinoStream = (logger) => {
13
+ return new Transform({
14
+ transform(chunk, _encoding, callback) {
15
+ const line = chunk.toString().trim();
16
+ if (line) {
17
+ console.log(line);
18
+ logger.info(line);
19
+ }
20
+ callback(null, chunk);
21
+ }
22
+ });
23
+ };
24
+ function createChildProcessLogger({ logger, root }) {
25
+ const pinoStream = createPinoStream(logger);
26
+ return async ({ cmd, args, env }) => {
27
+ try {
28
+ const subprocess = spawn(cmd, args, {
29
+ cwd: root,
30
+ shell: true,
31
+ env
32
+ });
33
+ subprocess.stdout?.pipe(pinoStream);
34
+ subprocess.stderr?.pipe(pinoStream);
35
+ return new Promise((resolve, reject) => {
36
+ subprocess.on("close", (code) => {
37
+ pinoStream.end();
38
+ if (code === 0) {
39
+ resolve({ success: true });
40
+ } else {
41
+ reject(new Error(`Process exited with code ${code}`));
42
+ }
43
+ });
44
+ subprocess.on("error", (error) => {
45
+ pinoStream.end();
46
+ logger.error("Process failed", { error });
47
+ reject(error);
48
+ });
49
+ });
50
+ } catch (error) {
51
+ console.log(error);
52
+ logger.error("Process failed", { error });
53
+ pinoStream.end();
54
+ return { success: false, error };
55
+ }
56
+ };
57
+ }
58
+ var Deps = class extends MastraBase {
59
+ packageManager;
60
+ rootDir;
61
+ constructor(rootDir = process.cwd()) {
62
+ super({ component: "DEPLOYER", name: "DEPS" });
63
+ this.rootDir = rootDir;
64
+ this.packageManager = this.getPackageManager();
65
+ }
66
+ findLockFile(dir) {
67
+ const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
68
+ for (const file of lockFiles) {
69
+ if (fs3__default.existsSync(path.join(dir, file))) {
70
+ return file;
71
+ }
72
+ }
73
+ const parentDir = path.resolve(dir, "..");
74
+ if (parentDir !== dir) {
75
+ return this.findLockFile(parentDir);
76
+ }
77
+ return null;
78
+ }
79
+ getPackageManager() {
80
+ const lockFile = this.findLockFile(this.rootDir);
81
+ switch (lockFile) {
82
+ case "pnpm-lock.yaml":
83
+ return "pnpm";
84
+ case "package-lock.json":
85
+ return "npm";
86
+ case "yarn.lock":
87
+ return "yarn";
88
+ case "bun.lock":
89
+ return "bun";
90
+ default:
91
+ return "npm";
92
+ }
93
+ }
94
+ getWorkspaceDependencyPath({ pkgName, version }) {
95
+ return `file:./workspace-module/${pkgName}-${version}.tgz`;
96
+ }
97
+ async pack({ dir, destination }) {
98
+ const cpLogger = createChildProcessLogger({
99
+ logger: this.logger,
100
+ root: dir
101
+ });
102
+ return cpLogger({
103
+ cmd: `${this.packageManager} pack --pack-destination ${destination}`,
104
+ args: [],
105
+ env: {
106
+ PATH: process.env.PATH
107
+ }
108
+ });
109
+ }
110
+ async writePnpmConfig(dir, options) {
111
+ const packageJsonPath = path.join(dir, "package.json");
112
+ const packageJson = await readJSON(packageJsonPath);
113
+ packageJson.pnpm = {
114
+ ...packageJson.pnpm,
115
+ supportedArchitectures: {
116
+ os: options.os || [],
117
+ cpu: options.cpu || [],
118
+ libc: options.libc || []
119
+ }
120
+ };
121
+ await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
122
+ }
123
+ async writeYarnConfig(dir, options) {
124
+ const yarnrcPath = path.join(dir, ".yarnrc.yml");
125
+ const config = {
126
+ supportedArchitectures: {
127
+ cpu: options.cpu || [],
128
+ os: options.os || [],
129
+ libc: options.libc || []
130
+ }
131
+ };
132
+ await fsPromises.writeFile(
133
+ yarnrcPath,
134
+ `supportedArchitectures:
135
+ ${Object.entries(config.supportedArchitectures).map(([key, value]) => ` ${key}: ${JSON.stringify(value)}`).join("\n")}`
136
+ );
137
+ }
138
+ getNpmArgs(options) {
139
+ const args = [];
140
+ if (options.cpu) args.push(`--cpu=${options.cpu.join(",")}`);
141
+ if (options.os) args.push(`--os=${options.os.join(",")}`);
142
+ if (options.libc) args.push(`--libc=${options.libc.join(",")}`);
143
+ return args;
144
+ }
145
+ async install({
146
+ dir = this.rootDir,
147
+ architecture
148
+ } = {}) {
149
+ let runCommand = this.packageManager;
150
+ let args = [];
151
+ switch (this.packageManager) {
152
+ case "pnpm":
153
+ runCommand = `${this.packageManager} --ignore-workspace install`;
154
+ if (architecture) {
155
+ await this.writePnpmConfig(dir, architecture);
156
+ }
157
+ break;
158
+ case "yarn":
159
+ await ensureFile(path.join(dir, "yarn.lock"));
160
+ if (architecture) {
161
+ await this.writeYarnConfig(dir, architecture);
162
+ }
163
+ runCommand = `${this.packageManager} install`;
164
+ break;
165
+ case "npm":
166
+ runCommand = `${this.packageManager} install`;
167
+ if (architecture) {
168
+ args = this.getNpmArgs(architecture);
169
+ }
170
+ break;
171
+ default:
172
+ runCommand = `${this.packageManager} install`;
173
+ }
174
+ const cpLogger = createChildProcessLogger({
175
+ logger: this.logger,
176
+ root: dir
177
+ });
178
+ return cpLogger({
179
+ cmd: runCommand,
180
+ args,
181
+ env: {
182
+ PATH: process.env.PATH
183
+ }
184
+ });
185
+ }
186
+ async installPackages(packages) {
187
+ let runCommand = this.packageManager;
188
+ if (this.packageManager === "npm") {
189
+ runCommand = `${this.packageManager} i`;
190
+ } else {
191
+ runCommand = `${this.packageManager} add`;
192
+ }
193
+ const cpLogger = createChildProcessLogger({
194
+ logger: this.logger,
195
+ root: ""
196
+ });
197
+ return cpLogger({
198
+ cmd: `${runCommand}`,
199
+ args: packages,
200
+ env: {
201
+ PATH: process.env.PATH
202
+ }
203
+ });
204
+ }
205
+ async checkDependencies(dependencies) {
206
+ try {
207
+ const packageJsonPath = path.join(this.rootDir, "package.json");
208
+ try {
209
+ await fsPromises.access(packageJsonPath);
210
+ } catch {
211
+ return "No package.json file found in the current directory";
212
+ }
213
+ const packageJson = await readJSON(packageJsonPath);
214
+ for (const dependency of dependencies) {
215
+ if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
216
+ return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
217
+ }
218
+ }
219
+ return "ok";
220
+ } catch (err) {
221
+ console.error(err);
222
+ return "Could not check dependencies";
223
+ }
224
+ }
225
+ async getProjectName() {
226
+ try {
227
+ const packageJsonPath = path.join(this.rootDir, "package.json");
228
+ const pkg = await readJSON(packageJsonPath);
229
+ return pkg.name;
230
+ } catch (err) {
231
+ throw err;
232
+ }
233
+ }
234
+ async getPackageVersion() {
235
+ const __filename = fileURLToPath(import.meta.url);
236
+ const __dirname = dirname(__filename);
237
+ const pkgJsonPath = path.join(__dirname, "..", "..", "package.json");
238
+ const content = await readJSON(pkgJsonPath);
239
+ return content.version;
240
+ }
241
+ async addScriptsToPackageJson(scripts) {
242
+ const packageJson = await readJSON("package.json");
243
+ packageJson.scripts = {
244
+ ...packageJson.scripts,
245
+ ...scripts
246
+ };
247
+ await writeJSON("package.json", packageJson, { spaces: 2 });
248
+ }
249
+ };
250
+ var DepsService = class extends Deps {
251
+ };
252
+ var EnvService = class {
253
+ };
254
+ var FileEnvService = class extends EnvService {
255
+ filePath;
256
+ constructor(filePath) {
257
+ super();
258
+ this.filePath = filePath;
259
+ }
260
+ readFile(filePath) {
261
+ return new Promise((resolve, reject) => {
262
+ fs3.readFile(filePath, "utf8", (err, data) => {
263
+ if (err) reject(err);
264
+ else resolve(data);
265
+ });
266
+ });
267
+ }
268
+ writeFile({ filePath, data }) {
269
+ return new Promise((resolve, reject) => {
270
+ fs3.writeFile(filePath, data, "utf8", (err) => {
271
+ if (err) reject(err);
272
+ else resolve();
273
+ });
274
+ });
275
+ }
276
+ async updateEnvData({
277
+ key,
278
+ value,
279
+ filePath = this.filePath,
280
+ data
281
+ }) {
282
+ const regex = new RegExp(`^${key}=.*$`, "m");
283
+ if (data.match(regex)) {
284
+ data = data.replace(regex, `${key}=${value}`);
285
+ } else {
286
+ data += `
287
+ ${key}=${value}`;
288
+ }
289
+ await this.writeFile({ filePath, data });
290
+ console.log(`${key} set to ${value} in ENV file.`);
291
+ return data;
292
+ }
293
+ async getEnvValue(key) {
294
+ try {
295
+ const data = await this.readFile(this.filePath);
296
+ const regex = new RegExp(`^${key}=(.*)$`, "m");
297
+ const match = data.match(regex);
298
+ return match?.[1] || null;
299
+ } catch (err) {
300
+ console.error(`Error reading ENV value: ${err}`);
301
+ return null;
302
+ }
303
+ }
304
+ async setEnvValue(key, value) {
305
+ try {
306
+ const data = await this.readFile(this.filePath);
307
+ await this.updateEnvData({ key, value, data });
308
+ } catch (err) {
309
+ console.error(`Error writing ENV value: ${err}`);
310
+ }
311
+ }
312
+ };
313
+ var FileService = class {
314
+ /**
315
+ *
316
+ * @param inputFile the file in the starter files directory to copy
317
+ * @param outputFilePath the destination path
318
+ * @param replaceIfExists flag to replace if it exists
319
+ * @returns
320
+ */
321
+ async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
322
+ const __filename = fileURLToPath(import.meta.url);
323
+ const __dirname = path.dirname(__filename);
324
+ const filePath = path.resolve(__dirname, "..", "starter-files", inputFile);
325
+ const fileString = fs3__default.readFileSync(filePath, "utf8");
326
+ if (fs3__default.existsSync(outputFilePath) && !replaceIfExists) {
327
+ console.log(`${outputFilePath} already exists`);
328
+ return false;
329
+ }
330
+ await fsExtra.outputFile(outputFilePath, fileString);
331
+ return true;
332
+ }
333
+ async setupEnvFile({ dbUrl }) {
334
+ const envPath = path.join(process.cwd(), ".env.development");
335
+ await fsExtra.ensureFile(envPath);
336
+ const fileEnvService = new FileEnvService(envPath);
337
+ await fileEnvService.setEnvValue("DB_URL", dbUrl);
338
+ }
339
+ getFirstExistingFile(files) {
340
+ for (const f of files) {
341
+ if (fs3__default.existsSync(f)) {
342
+ return f;
343
+ }
344
+ }
345
+ throw new Error("Missing required file, checked the following paths: " + files.join(", "));
346
+ }
347
+ replaceValuesInFile({
348
+ filePath,
349
+ replacements
350
+ }) {
351
+ let fileContent = fs3__default.readFileSync(filePath, "utf8");
352
+ replacements.forEach(({ search, replace }) => {
353
+ fileContent = fileContent.replaceAll(search, replace);
354
+ });
355
+ fs3__default.writeFileSync(filePath, fileContent);
356
+ }
357
+ };
358
+
359
+ export { Deps, DepsService, EnvService, FileService, createChildProcessLogger, createPinoStream };
@@ -0,0 +1,111 @@
1
+ import * as babel from '@babel/core';
2
+ import babel__default from '@babel/core';
3
+ import fs from 'node:fs';
4
+ import path, { normalize } from 'node:path';
5
+ import { createHandler } from 'typescript-paths';
6
+
7
+ // src/build/plugins/remove-deployer.ts
8
+ function removeDeployer() {
9
+ const t = babel__default.types;
10
+ return {
11
+ name: "remove-deployer",
12
+ visitor: {
13
+ NewExpression(path2, state) {
14
+ const varDeclaratorPath = path2.findParent((path3) => t.isVariableDeclarator(path3.node));
15
+ if (!varDeclaratorPath) {
16
+ return;
17
+ }
18
+ const parentNode = path2.parentPath.node;
19
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
20
+ return;
21
+ }
22
+ if (!state.hasReplaced) {
23
+ state.hasReplaced = true;
24
+ const newMastraObj = t.cloneNode(path2.node);
25
+ if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
26
+ const deployer = newMastraObj.arguments[0].properties.find(
27
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === "deployer"
28
+ );
29
+ if (!deployer) {
30
+ return;
31
+ }
32
+ newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
33
+ (prop) => prop !== deployer
34
+ );
35
+ if (t.isObjectProperty(deployer) && t.isIdentifier(deployer.value)) {
36
+ const deployerBinding = state.file.scope.getBinding(deployer.value.name);
37
+ if (deployerBinding) {
38
+ deployerBinding?.path?.parentPath?.remove();
39
+ }
40
+ }
41
+ path2.replaceWith(newMastraObj);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ };
47
+ }
48
+
49
+ // src/build/plugins/remove-deployer.ts
50
+ function removeDeployer2(mastraEntry) {
51
+ return {
52
+ name: "remove-deployer",
53
+ transform(code, id) {
54
+ if (id !== mastraEntry) {
55
+ return;
56
+ }
57
+ return new Promise((resolve, reject) => {
58
+ babel.transform(
59
+ code,
60
+ {
61
+ babelrc: false,
62
+ configFile: false,
63
+ filename: id,
64
+ plugins: [removeDeployer]
65
+ },
66
+ (err, result) => {
67
+ if (err) {
68
+ return reject(err);
69
+ }
70
+ resolve({
71
+ code: result.code,
72
+ map: result.map
73
+ });
74
+ }
75
+ );
76
+ });
77
+ }
78
+ };
79
+ }
80
+ var PLUGIN_NAME = "tsconfig-paths";
81
+ function tsConfigPaths({ tsConfigPath, respectCoreModule } = {}) {
82
+ let handler;
83
+ return {
84
+ name: PLUGIN_NAME,
85
+ buildStart() {
86
+ handler = createHandler({
87
+ log: () => {
88
+ },
89
+ tsConfigPath,
90
+ respectCoreModule,
91
+ falllback: (moduleName) => fs.existsSync(moduleName)
92
+ });
93
+ return;
94
+ },
95
+ async resolveId(request, importer, options) {
96
+ if (!importer || request.startsWith("\0")) {
97
+ return null;
98
+ }
99
+ const moduleName = handler?.(request, normalize(importer));
100
+ if (!moduleName) {
101
+ return this.resolve(request, importer, { skipSelf: true, ...options });
102
+ }
103
+ if (!path.extname(moduleName)) {
104
+ return this.resolve(moduleName, importer, { skipSelf: true, ...options });
105
+ }
106
+ return moduleName;
107
+ }
108
+ };
109
+ }
110
+
111
+ export { removeDeployer2 as removeDeployer, tsConfigPaths };
@@ -0,0 +1,164 @@
1
+ 'use strict';
2
+
3
+ var chunk2ZPQX6BX_cjs = require('./chunk-2ZPQX6BX.cjs');
4
+ var chunkLA6Y6GAB_cjs = require('./chunk-LA6Y6GAB.cjs');
5
+ var chunkIMGVLBV7_cjs = require('./chunk-IMGVLBV7.cjs');
6
+ var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
7
+ var rollup = require('rollup');
8
+ var babel = require('@babel/core');
9
+ var esbuild = require('rollup-plugin-esbuild');
10
+ var commonjs = require('@rollup/plugin-commonjs');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
33
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
34
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
35
+
36
+ async function getInputOptions2(entryFile, platform, env) {
37
+ const inputOptions = await chunkIMGVLBV7_cjs.getInputOptions(
38
+ entryFile,
39
+ {
40
+ dependencies: /* @__PURE__ */ new Map(),
41
+ externalDependencies: /* @__PURE__ */ new Set(),
42
+ invalidChunks: /* @__PURE__ */ new Set()
43
+ },
44
+ platform,
45
+ env
46
+ );
47
+ if (Array.isArray(inputOptions.plugins)) {
48
+ inputOptions.plugins = inputOptions.plugins.filter(
49
+ // @ts-ignore
50
+ (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
51
+ );
52
+ inputOptions.plugins.push(chunkLA6Y6GAB_cjs.aliasHono());
53
+ }
54
+ return inputOptions;
55
+ }
56
+ async function createWatcher(inputOptions, outputOptions) {
57
+ const watcher = await rollup.watch({
58
+ ...inputOptions,
59
+ output: {
60
+ ...outputOptions,
61
+ format: "esm",
62
+ entryFileNames: "[name].mjs",
63
+ chunkFileNames: "[name].mjs"
64
+ }
65
+ });
66
+ return watcher;
67
+ }
68
+
69
+ // src/build/babel/remove-all-options-server.ts
70
+ function removeAllOptionsExceptServer(result) {
71
+ return chunk2ZPQX6BX_cjs.removeAllOptionsFromMastraExcept(result, "server");
72
+ }
73
+ function getServerOptionsBundler(entryFile, result) {
74
+ return rollup.rollup({
75
+ logLevel: "silent",
76
+ input: {
77
+ "server-config": entryFile
78
+ },
79
+ treeshake: "smallest",
80
+ plugins: [
81
+ chunk54KOF3NB_cjs.tsConfigPaths(),
82
+ // transpile typescript to something we understand
83
+ esbuild__default.default({
84
+ target: "node20",
85
+ platform: "node",
86
+ minify: false
87
+ }),
88
+ commonjs__default.default({
89
+ extensions: [".js", ".ts"],
90
+ strictRequires: "strict",
91
+ transformMixedEsModules: true,
92
+ ignoreTryCatch: false
93
+ }),
94
+ {
95
+ name: "get-server-config",
96
+ transform(code, id) {
97
+ if (id !== entryFile) {
98
+ return;
99
+ }
100
+ return new Promise((resolve, reject) => {
101
+ babel__namespace.transform(
102
+ code,
103
+ {
104
+ babelrc: false,
105
+ configFile: false,
106
+ filename: id,
107
+ plugins: [removeAllOptionsExceptServer(result)]
108
+ },
109
+ (err, result2) => {
110
+ if (err) {
111
+ return reject(err);
112
+ }
113
+ resolve({
114
+ code: result2.code,
115
+ map: result2.map
116
+ });
117
+ }
118
+ );
119
+ });
120
+ }
121
+ },
122
+ // let esbuild remove all unused imports
123
+ esbuild__default.default({
124
+ target: "node20",
125
+ platform: "node",
126
+ minify: false
127
+ }),
128
+ {
129
+ name: "cleanup",
130
+ transform(code, id) {
131
+ if (id !== entryFile) {
132
+ return;
133
+ }
134
+ return chunk2ZPQX6BX_cjs.recursiveRemoveNonReferencedNodes(code);
135
+ }
136
+ },
137
+ // let esbuild remove all unused imports
138
+ esbuild__default.default({
139
+ target: "node20",
140
+ platform: "node",
141
+ minify: false
142
+ })
143
+ ]
144
+ });
145
+ }
146
+ async function getServerOptions(entryFile, outputDir) {
147
+ const result = {
148
+ hasCustomConfig: false
149
+ };
150
+ const bundle = await getServerOptionsBundler(entryFile, result);
151
+ await bundle.write({
152
+ dir: outputDir,
153
+ format: "es",
154
+ entryFileNames: "[name].mjs"
155
+ });
156
+ if (result.hasCustomConfig) {
157
+ return (await import(`file:${outputDir}/server-config.mjs`)).server;
158
+ }
159
+ return null;
160
+ }
161
+
162
+ exports.createWatcher = createWatcher;
163
+ exports.getInputOptions = getInputOptions2;
164
+ exports.getServerOptions = getServerOptions;