Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(dev): import buildFileParseWorker by its .mts path (#23220)

YuTengjing57e09e5f6851
diff --git a/scripts/buildFileParseWorker.test.ts b/scripts/buildFileParseWorker.test.ts
index 6f65305e149..bfae91204c3 100644
--- a/scripts/buildFileParseWorker.test.ts
+++ b/scripts/buildFileParseWorker.test.ts
@@ -8,7 +8,7 @@ import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { createFileParseRunner } from '../apps/server/src/services/fileParse/runner';
-import { buildFileParseWorker } from './buildFileParseWorker.mjs';
+import { buildFileParseWorker } from './buildFileParseWorker.mts';
const loaders = (relative: string) =>
path.resolve(__dirname, '../packages/file-loaders/src/loaders', relative);
diff --git a/scripts/devStartupSequence.mts b/scripts/devStartupSequence.mts
index 9ee51690079..82f03da197e 100644
--- a/scripts/devStartupSequence.mts
+++ b/scripts/devStartupSequence.mts
@@ -7,7 +7,7 @@ import { pathToFileURL } from 'node:url';
import dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand';
-import { buildFileParseWorker } from './buildFileParseWorker.mjs';
+import { buildFileParseWorker } from './buildFileParseWorker.mts';
interface DevProcessHandle {
directPid?: number;
diff --git a/scripts/devStartupSequence.test.ts b/scripts/devStartupSequence.test.ts
new file mode 100644
index 00000000000..dd9b549db0e
--- /dev/null
+++ b/scripts/devStartupSequence.test.ts
@@ -0,0 +1,28 @@
+/**
+ * @vitest-environment node
+ */
+import { spawnSync } from 'node:child_process';
+import path from 'node:path';
+import { pathToFileURL } from 'node:url';
+
+import { describe, expect, it } from 'vitest';
+
+describe('devStartupSequence', () => {
+ /**
+ * Cloud starts this script with bare `node` (native type stripping), which does not map a
+ * `.mjs` specifier to its `.mts` source the way `tsx` and Vitest do. Load it in a real Node
+ * process so a relative import that only those tools can resolve fails here instead of breaking
+ * Cloud `bun run dev` with ERR_MODULE_NOT_FOUND.
+ */
+ it('resolves every import under bare node', () => {
+ const entry = pathToFileURL(path.resolve(__dirname, 'devStartupSequence.mts')).href;
+ const result = spawnSync(
+ 'node',
+ ['--input-type=module', '-e', `await import(${JSON.stringify(entry)});`],
+ { encoding: 'utf8', timeout: 30_000 },
+ );
+
+ expect(result.stderr).not.toContain('ERR_MODULE_NOT_FOUND');
+ expect(result.status).toBe(0);
+ });
+});