@mastra/deployer 0.2.5 → 0.2.6-alpha.10

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 (40) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +95 -33
  2. package/dist/_tsup-dts-rollup.d.ts +95 -33
  3. package/dist/build/analyze.cjs +2 -2
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/bundler.cjs +3 -3
  6. package/dist/build/bundler.js +1 -1
  7. package/dist/build/index.cjs +22 -24
  8. package/dist/build/index.d.cts +3 -4
  9. package/dist/build/index.d.ts +3 -4
  10. package/dist/build/index.js +6 -4
  11. package/dist/bundler/index.cjs +2 -2
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  14. package/dist/chunk-4AYFLP6G.js +227 -0
  15. package/dist/chunk-5UBGPRKT.js +185 -0
  16. package/dist/{chunk-KLVSED7T.js → chunk-74KZVNKH.js} +8 -4
  17. package/dist/{chunk-OT6UKL2S.cjs → chunk-AE4CVAPK.cjs} +11 -0
  18. package/dist/{chunk-UTZ3434D.js → chunk-BDTZS3JM.js} +3 -0
  19. package/dist/chunk-DYQ225MJ.js +115 -0
  20. package/dist/chunk-I3UVE6EH.cjs +161 -0
  21. package/dist/{chunk-XEFBJH3T.js → chunk-IKPL4RGG.js} +11 -0
  22. package/dist/chunk-NCROGJGB.cjs +142 -0
  23. package/dist/{chunk-NWERLYTR.cjs → chunk-P5SATU7G.cjs} +3 -0
  24. package/dist/chunk-VFZVVUQE.cjs +198 -0
  25. package/dist/chunk-WB3T6NKI.js +133 -0
  26. package/dist/{chunk-NXBTVZHO.cjs → chunk-WFC3CUZ3.cjs} +14 -10
  27. package/dist/index.cjs +12 -11
  28. package/dist/index.js +7 -6
  29. package/dist/server/index.cjs +617 -2682
  30. package/dist/server/index.js +512 -2577
  31. package/dist/services/index.cjs +19 -0
  32. package/dist/services/index.d.cts +3 -0
  33. package/dist/services/index.d.ts +3 -0
  34. package/dist/services/index.js +2 -0
  35. package/dist/templates/instrumentation-template.js +25 -30
  36. package/package.json +15 -4
  37. package/dist/chunk-7GYBZLVN.cjs +0 -286
  38. package/dist/chunk-KFOGAPGX.cjs +0 -433
  39. package/dist/chunk-PUX2FDGX.js +0 -252
  40. package/dist/chunk-ZAXXMFXX.js +0 -399
@@ -1,433 +0,0 @@
1
- 'use strict';
2
-
3
- var child_process = require('child_process');
4
- var stream = require('stream');
5
- var base = require('@mastra/core/base');
6
- var fs = require('fs');
7
- var path = require('path');
8
- var url = require('url');
9
- var fsExtra = require('fs-extra/esm');
10
- var fsPromises = require('fs/promises');
11
- var babel = require('@babel/core');
12
- var rollup = require('rollup');
13
- var esbuild = require('rollup-plugin-esbuild');
14
- var commonjs = require('@rollup/plugin-commonjs');
15
-
16
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- var n = Object.create(null);
22
- if (e) {
23
- Object.keys(e).forEach(function (k) {
24
- if (k !== 'default') {
25
- var d = Object.getOwnPropertyDescriptor(e, k);
26
- Object.defineProperty(n, k, d.get ? d : {
27
- enumerable: true,
28
- get: function () { return e[k]; }
29
- });
30
- }
31
- });
32
- }
33
- n.default = e;
34
- return Object.freeze(n);
35
- }
36
-
37
- var fs__default = /*#__PURE__*/_interopDefault(fs);
38
- var path__default = /*#__PURE__*/_interopDefault(path);
39
- var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
40
- var fsPromises__default = /*#__PURE__*/_interopDefault(fsPromises);
41
- var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
42
- var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
43
- var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
44
-
45
- // src/deploy/log.ts
46
- var createPinoStream = (logger) => {
47
- return new stream.Transform({
48
- transform(chunk, _encoding, callback) {
49
- const line = chunk.toString().trim();
50
- if (line) {
51
- console.log(line);
52
- logger.info(line);
53
- }
54
- callback(null, chunk);
55
- }
56
- });
57
- };
58
- function createChildProcessLogger({ logger, root }) {
59
- const pinoStream = createPinoStream(logger);
60
- return async ({ cmd, args, env }) => {
61
- try {
62
- const subprocess = child_process.spawn(cmd, args, {
63
- cwd: root,
64
- shell: true,
65
- env
66
- });
67
- subprocess.stdout?.pipe(pinoStream);
68
- subprocess.stderr?.pipe(pinoStream);
69
- return new Promise((resolve, reject) => {
70
- subprocess.on("close", (code) => {
71
- pinoStream.end();
72
- if (code === 0) {
73
- resolve({ success: true });
74
- } else {
75
- reject(new Error(`Process exited with code ${code}`));
76
- }
77
- });
78
- subprocess.on("error", (error) => {
79
- pinoStream.end();
80
- logger.error("Process failed", { error });
81
- reject(error);
82
- });
83
- });
84
- } catch (error) {
85
- console.log(error);
86
- logger.error("Process failed", { error });
87
- pinoStream.end();
88
- return { success: false, error };
89
- }
90
- };
91
- }
92
- var Deps = class extends base.MastraBase {
93
- packageManager;
94
- rootDir;
95
- constructor(rootDir = process.cwd()) {
96
- super({ component: "DEPLOYER", name: "DEPS" });
97
- this.rootDir = rootDir;
98
- this.packageManager = this.getPackageManager();
99
- }
100
- findLockFile(dir) {
101
- const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
102
- for (const file of lockFiles) {
103
- if (fs__default.default.existsSync(path__default.default.join(dir, file))) {
104
- return file;
105
- }
106
- }
107
- const parentDir = path__default.default.resolve(dir, "..");
108
- if (parentDir !== dir) {
109
- return this.findLockFile(parentDir);
110
- }
111
- return null;
112
- }
113
- getPackageManager() {
114
- const lockFile = this.findLockFile(this.rootDir);
115
- switch (lockFile) {
116
- case "pnpm-lock.yaml":
117
- return "pnpm";
118
- case "package-lock.json":
119
- return "npm";
120
- case "yarn.lock":
121
- return "yarn";
122
- case "bun.lock":
123
- return "bun";
124
- default:
125
- return "npm";
126
- }
127
- }
128
- async install({ dir = this.rootDir, packages = [] }) {
129
- let runCommand = this.packageManager;
130
- switch (this.packageManager) {
131
- case "npm":
132
- runCommand = `${this.packageManager} i`;
133
- break;
134
- case "pnpm":
135
- runCommand = `${this.packageManager} --ignore-workspace install`;
136
- break;
137
- default:
138
- runCommand = `${this.packageManager} ${packages?.length > 0 ? `add` : `install`}`;
139
- }
140
- const cpLogger = createChildProcessLogger({
141
- logger: this.logger,
142
- root: dir
143
- });
144
- return cpLogger({
145
- cmd: runCommand,
146
- args: packages,
147
- env: {
148
- PATH: process.env.PATH
149
- }
150
- });
151
- }
152
- async installPackages(packages) {
153
- let runCommand = this.packageManager;
154
- if (this.packageManager === "npm") {
155
- runCommand = `${this.packageManager} i`;
156
- } else {
157
- runCommand = `${this.packageManager} add`;
158
- }
159
- const cpLogger = createChildProcessLogger({
160
- logger: this.logger,
161
- root: ""
162
- });
163
- return cpLogger({
164
- cmd: `${runCommand}`,
165
- args: packages,
166
- env: {
167
- PATH: process.env.PATH
168
- }
169
- });
170
- }
171
- async checkDependencies(dependencies) {
172
- try {
173
- const packageJsonPath = path__default.default.join(this.rootDir, "package.json");
174
- try {
175
- await fsPromises__default.default.access(packageJsonPath);
176
- } catch {
177
- return "No package.json file found in the current directory";
178
- }
179
- const packageJson = JSON.parse(await fsPromises__default.default.readFile(packageJsonPath, "utf-8"));
180
- for (const dependency of dependencies) {
181
- if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
182
- return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
183
- }
184
- }
185
- return "ok";
186
- } catch (err) {
187
- console.error(err);
188
- return "Could not check dependencies";
189
- }
190
- }
191
- async getProjectName() {
192
- try {
193
- const packageJsonPath = path__default.default.join(this.rootDir, "package.json");
194
- const packageJson = await fsPromises__default.default.readFile(packageJsonPath, "utf-8");
195
- const pkg = JSON.parse(packageJson);
196
- return pkg.name;
197
- } catch (err) {
198
- throw err;
199
- }
200
- }
201
- async getPackageVersion() {
202
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KFOGAPGX.cjs', document.baseURI).href)));
203
- const __dirname = path.dirname(__filename);
204
- const pkgJsonPath = path__default.default.join(__dirname, "..", "..", "package.json");
205
- const content = await fsExtra__default.default.readJSON(pkgJsonPath);
206
- return content.version;
207
- }
208
- async addScriptsToPackageJson(scripts) {
209
- const packageJson = JSON.parse(await fsPromises__default.default.readFile("package.json", "utf-8"));
210
- packageJson.scripts = {
211
- ...packageJson.scripts,
212
- ...scripts
213
- };
214
- await fsPromises__default.default.writeFile("package.json", JSON.stringify(packageJson, null, 2));
215
- }
216
- };
217
- function removeAllExceptTelemetryConfig(result) {
218
- const t = babel__namespace.default.types;
219
- return {
220
- name: "remove-all-except-telemetry-config",
221
- visitor: {
222
- ExportNamedDeclaration: {
223
- // remove all exports
224
- exit(path2) {
225
- path2.remove();
226
- }
227
- },
228
- NewExpression(path2, state) {
229
- const varDeclaratorPath = path2.findParent((path3) => t.isVariableDeclarator(path3.node));
230
- if (!varDeclaratorPath) {
231
- return;
232
- }
233
- const parentNode = path2.parentPath.node;
234
- if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
235
- return;
236
- }
237
- let mastraArgs = t.objectExpression([]);
238
- if (t.isObjectExpression(path2.node.arguments[0])) {
239
- mastraArgs = path2.node.arguments[0];
240
- }
241
- let telemetry = mastraArgs.properties.find(
242
- // @ts-ignore
243
- (prop) => prop.key.name === "telemetry"
244
- );
245
- let telemetryValue = t.objectExpression([]);
246
- const programPath = path2.scope.getProgramParent().path;
247
- if (!programPath) {
248
- return;
249
- }
250
- if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {
251
- result.hasCustomConfig = true;
252
- telemetryValue = telemetry.value;
253
- if (t.isIdentifier(telemetry.value) && telemetry.value.name === "telemetry") {
254
- const telemetryBinding = state.file.scope.getBinding("telemetry");
255
- if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
256
- const id = path2.scope.generateUidIdentifier("telemetry");
257
- telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
258
- telemetryValue = id;
259
- }
260
- }
261
- }
262
- const exportDeclaration = t.exportNamedDeclaration(
263
- t.variableDeclaration("const", [t.variableDeclarator(t.identifier("telemetry"), telemetryValue)]),
264
- []
265
- );
266
- programPath.node.body.push(exportDeclaration);
267
- }
268
- }
269
- };
270
- }
271
- function removeNonReferencedNodes() {
272
- const t = babel__namespace.default.types;
273
- return {
274
- name: "remove-non-referenced-nodes",
275
- visitor: {
276
- Program(path2) {
277
- const scope = path2.scope;
278
- const currentBody = path2.get("body");
279
- const filteredBody = currentBody.filter((childPath) => {
280
- if (childPath.isExportDeclaration()) {
281
- return true;
282
- }
283
- if (childPath.isVariableDeclaration()) {
284
- return childPath.node.declarations.some((decl) => {
285
- if (!t.isIdentifier(decl.id)) {
286
- return false;
287
- }
288
- const name = decl.id.name;
289
- const binding = scope.getBinding(name);
290
- return binding && (binding.referenced || binding.referencePaths.length > 0);
291
- });
292
- }
293
- if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
294
- if (!t.isIdentifier(childPath.node.id)) {
295
- return false;
296
- }
297
- const name = childPath.node.id.name;
298
- const binding = scope.getBinding(name);
299
- return binding && (binding.referenced || binding.referencePaths.length > 0);
300
- }
301
- if (childPath.isImportDeclaration()) {
302
- return childPath.node.specifiers.some((specifier) => {
303
- const importedName = specifier.local.name;
304
- const binding = scope.getBinding(importedName);
305
- return binding && (binding.referenced || binding.referencePaths.length > 0);
306
- });
307
- }
308
- return false;
309
- });
310
- path2.set(
311
- "body",
312
- filteredBody.map((p) => p.node)
313
- );
314
- }
315
- }
316
- };
317
- }
318
- function recursiveRemoveNonReferencedNodes(code) {
319
- return new Promise(async (resolve, reject) => {
320
- babel__namespace.transform(
321
- code,
322
- {
323
- babelrc: false,
324
- configFile: false,
325
- plugins: [removeNonReferencedNodes()]
326
- },
327
- (err, result) => {
328
- if (err) {
329
- return reject(err);
330
- }
331
- if (result && result.code !== code) {
332
- return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
333
- }
334
- resolve({
335
- code: result.code,
336
- map: result.map
337
- });
338
- }
339
- );
340
- });
341
- }
342
-
343
- // src/build/telemetry.ts
344
- function getTelemetryBundler(entryFile, result) {
345
- return rollup.rollup({
346
- logLevel: "silent",
347
- input: {
348
- "telemetry-config": entryFile
349
- },
350
- treeshake: "smallest",
351
- plugins: [
352
- // transpile typescript to something we understand
353
- esbuild__default.default({
354
- target: "node20",
355
- platform: "node",
356
- minify: false
357
- }),
358
- commonjs__default.default({
359
- extensions: [".js", ".ts"],
360
- strictRequires: "strict",
361
- transformMixedEsModules: true,
362
- ignoreTryCatch: false
363
- }),
364
- {
365
- name: "get-telemetry-config",
366
- transform(code, id) {
367
- if (id !== entryFile) {
368
- return;
369
- }
370
- return new Promise((resolve, reject) => {
371
- babel__namespace.transform(
372
- code,
373
- {
374
- babelrc: false,
375
- configFile: false,
376
- filename: id,
377
- plugins: [removeAllExceptTelemetryConfig(result)]
378
- },
379
- (err, result2) => {
380
- if (err) {
381
- return reject(err);
382
- }
383
- resolve({
384
- code: result2.code,
385
- map: result2.map
386
- });
387
- }
388
- );
389
- });
390
- }
391
- },
392
- // let esbuild remove all unused imports
393
- esbuild__default.default({
394
- target: "node20",
395
- platform: "node",
396
- minify: false
397
- }),
398
- {
399
- name: "cleanup",
400
- transform(code, id) {
401
- if (id !== entryFile) {
402
- return;
403
- }
404
- return recursiveRemoveNonReferencedNodes(code);
405
- }
406
- },
407
- // let esbuild remove all unused imports
408
- esbuild__default.default({
409
- target: "node20",
410
- platform: "node",
411
- minify: false
412
- })
413
- ]
414
- });
415
- }
416
- async function writeTelemetryConfig(entryFile, outputDir) {
417
- const result = {
418
- hasCustomConfig: false
419
- };
420
- const bundle = await getTelemetryBundler(entryFile, result);
421
- await bundle.write({
422
- dir: outputDir,
423
- format: "es",
424
- entryFileNames: "[name].mjs"
425
- });
426
- return result;
427
- }
428
-
429
- exports.Deps = Deps;
430
- exports.createChildProcessLogger = createChildProcessLogger;
431
- exports.createPinoStream = createPinoStream;
432
- exports.recursiveRemoveNonReferencedNodes = recursiveRemoveNonReferencedNodes;
433
- exports.writeTelemetryConfig = writeTelemetryConfig;
@@ -1,252 +0,0 @@
1
- import { aliasHono } from './chunk-UTZ3434D.js';
2
- import { getInputOptions } from './chunk-XEFBJH3T.js';
3
- import { removeDeployer } from './chunk-WVBUOQT6.js';
4
- import alias from '@rollup/plugin-alias';
5
- import commonjs from '@rollup/plugin-commonjs';
6
- import json from '@rollup/plugin-json';
7
- import { nodeResolve } from '@rollup/plugin-node-resolve';
8
- import { builtinModules } from 'node:module';
9
- import path, { join } from 'path';
10
- import { rollup, watch } from 'rollup';
11
- import esbuild from 'rollup-plugin-esbuild';
12
- import { fileURLToPath } from 'url';
13
- import * as fs2 from 'fs';
14
- import fs2__default from 'fs';
15
- import fsExtra from 'fs-extra/esm';
16
-
17
- var EnvService = class {
18
- };
19
- var FileEnvService = class extends EnvService {
20
- filePath;
21
- constructor(filePath) {
22
- super();
23
- this.filePath = filePath;
24
- }
25
- readFile(filePath) {
26
- return new Promise((resolve, reject) => {
27
- fs2.readFile(filePath, "utf8", (err, data) => {
28
- if (err) reject(err);
29
- else resolve(data);
30
- });
31
- });
32
- }
33
- writeFile({ filePath, data }) {
34
- return new Promise((resolve, reject) => {
35
- fs2.writeFile(filePath, data, "utf8", (err) => {
36
- if (err) reject(err);
37
- else resolve();
38
- });
39
- });
40
- }
41
- async updateEnvData({
42
- key,
43
- value,
44
- filePath = this.filePath,
45
- data
46
- }) {
47
- const regex = new RegExp(`^${key}=.*$`, "m");
48
- if (data.match(regex)) {
49
- data = data.replace(regex, `${key}=${value}`);
50
- } else {
51
- data += `
52
- ${key}=${value}`;
53
- }
54
- await this.writeFile({ filePath, data });
55
- console.log(`${key} set to ${value} in ENV file.`);
56
- return data;
57
- }
58
- async getEnvValue(key) {
59
- try {
60
- const data = await this.readFile(this.filePath);
61
- const regex = new RegExp(`^${key}=(.*)$`, "m");
62
- const match = data.match(regex);
63
- return match?.[1] || null;
64
- } catch (err) {
65
- console.error(`Error reading ENV value: ${err}`);
66
- return null;
67
- }
68
- }
69
- async setEnvValue(key, value) {
70
- try {
71
- const data = await this.readFile(this.filePath);
72
- await this.updateEnvData({ key, value, data });
73
- } catch (err) {
74
- console.error(`Error writing ENV value: ${err}`);
75
- }
76
- }
77
- };
78
-
79
- // src/build/fs.ts
80
- var FileService = class {
81
- /**
82
- *
83
- * @param inputFile the file in the starter files directory to copy
84
- * @param outputFilePath the destination path
85
- * @param replaceIfExists flag to replace if it exists
86
- * @returns
87
- */
88
- async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
89
- const __filename = fileURLToPath(import.meta.url);
90
- const __dirname = path.dirname(__filename);
91
- const filePath = path.resolve(__dirname, "..", "starter-files", inputFile);
92
- const fileString = fs2__default.readFileSync(filePath, "utf8");
93
- if (fs2__default.existsSync(outputFilePath) && !replaceIfExists) {
94
- console.log(`${outputFilePath} already exists`);
95
- return false;
96
- }
97
- await fsExtra.outputFile(outputFilePath, fileString);
98
- return true;
99
- }
100
- async setupEnvFile({ dbUrl }) {
101
- const envPath = path.join(process.cwd(), ".env.development");
102
- await fsExtra.ensureFile(envPath);
103
- const fileEnvService = new FileEnvService(envPath);
104
- await fileEnvService.setEnvValue("DB_URL", dbUrl);
105
- }
106
- getFirstExistingFile(files) {
107
- for (const f of files) {
108
- if (fs2__default.existsSync(f)) {
109
- return f;
110
- }
111
- }
112
- throw new Error("Missing required file, checked the following paths: " + files.join(", "));
113
- }
114
- replaceValuesInFile({
115
- filePath,
116
- replacements
117
- }) {
118
- let fileContent = fs2__default.readFileSync(filePath, "utf8");
119
- replacements.forEach(({ search, replace }) => {
120
- fileContent = fileContent.replaceAll(search, replace);
121
- });
122
- fs2__default.writeFileSync(filePath, fileContent);
123
- }
124
- };
125
-
126
- // src/build/bundle.ts
127
- function getOptions(inputOptions, platform, root) {
128
- const fileService = new FileService();
129
- const entry = fileService.getFirstExistingFile([
130
- join(root, "src/mastra/index.ts"),
131
- join(root, "src/mastra/index.js")
132
- ]);
133
- const nodeBuiltins = platform === "node" ? builtinModules : [];
134
- let nodeResolvePlugin = platform === "node" ? nodeResolve({
135
- preferBuiltins: true,
136
- exportConditions: ["node", "import", "require"],
137
- mainFields: ["module", "main"]
138
- }) : nodeResolve({
139
- preferBuiltins: false,
140
- exportConditions: ["browser", "import", "require"],
141
- mainFields: ["module", "main"],
142
- browser: true
143
- });
144
- return {
145
- logLevel: "silent",
146
- ...inputOptions,
147
- treeshake: "smallest",
148
- preserveSymlinks: true,
149
- external: [
150
- ...nodeBuiltins,
151
- ...nodeBuiltins.map((builtin) => "node:" + builtin),
152
- ...inputOptions.external ?? []
153
- ],
154
- plugins: [
155
- ...inputOptions.plugins ?? [],
156
- alias({
157
- entries: [
158
- {
159
- find: /^\#server$/,
160
- replacement: fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/")
161
- },
162
- { find: /^\#mastra$/, replacement: entry.replaceAll("\\", "/") },
163
- {
164
- find: /^hono\//,
165
- replacement: "hono/",
166
- customResolver: (id, importer) => {
167
- if (!importer?.startsWith("\0virtual")) {
168
- return null;
169
- }
170
- const path2 = import.meta.resolve(id);
171
- return fileURLToPath(path2);
172
- }
173
- }
174
- ]
175
- }),
176
- commonjs({
177
- strictRequires: "strict",
178
- transformMixedEsModules: true
179
- // dynamicRequireTargets: ['node_modules/**/@libsql+win32-*/*'],
180
- }),
181
- // for debugging
182
- // {
183
- // name: 'logger',
184
- // // @ts-ignore
185
- // resolveId(id, ...args) {
186
- // console.log({ id, args });
187
- // },
188
- // },
189
- nodeResolvePlugin,
190
- json(),
191
- esbuild({
192
- include: /\.tsx?$/,
193
- target: "node20",
194
- platform,
195
- minify: false,
196
- define: {
197
- "process.env.NODE_ENV": JSON.stringify("production")
198
- }
199
- }),
200
- removeDeployer(entry),
201
- esbuild({
202
- include: entry,
203
- target: "node20",
204
- platform,
205
- minify: false
206
- })
207
- ].filter(Boolean)
208
- };
209
- }
210
- async function getBundler(inputOptions, args = {}) {
211
- const { platform = "node", dir = process.cwd() } = args;
212
- const bundle = await rollup(getOptions(inputOptions, platform, dir));
213
- return bundle;
214
- }
215
- async function getWatcher(inputOptions, args = {}) {
216
- const { platform = "node", dir = process.cwd() } = args;
217
- const watcher = watch(getOptions(inputOptions, platform, dir));
218
- return watcher;
219
- }
220
- async function getInputOptions2(entryFile, platform) {
221
- const inputOptions = await getInputOptions(
222
- entryFile,
223
- {
224
- dependencies: /* @__PURE__ */ new Map(),
225
- externalDependencies: /* @__PURE__ */ new Set(),
226
- invalidChunks: /* @__PURE__ */ new Set()
227
- },
228
- platform
229
- );
230
- if (Array.isArray(inputOptions.plugins)) {
231
- inputOptions.plugins = inputOptions.plugins.filter(
232
- // @ts-ignore
233
- (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
234
- );
235
- inputOptions.plugins.push(aliasHono());
236
- }
237
- return inputOptions;
238
- }
239
- async function createWatcher(inputOptions, outputOptions) {
240
- const watcher = await watch({
241
- ...inputOptions,
242
- output: {
243
- ...outputOptions,
244
- format: "esm",
245
- entryFileNames: "[name].mjs",
246
- chunkFileNames: "[name].mjs"
247
- }
248
- });
249
- return watcher;
250
- }
251
-
252
- export { FileService, createWatcher, getBundler, getInputOptions2 as getInputOptions, getWatcher };