From de8f2d85dc2cf87c09844d7c3e894bc919c57316 Mon Sep 17 00:00:00 2001 From: prisis Date: Tue, 24 Jun 2025 18:02:34 +0200 Subject: [PATCH 1/3] feat: enhance file resolution logic for Convex configuration and schema files - Updated bundler to check for multiple file extensions (.ts, .js, .mjs, .cjs) for schema and auth configuration files. - Improved component root path resolution to prioritize new file types. - Adjusted comments and error messages for clarity regarding supported file types. This change ensures better compatibility and flexibility in handling various configuration file formats. --- npm-packages/convex/src/bundler/index.ts | 51 ++++++++++++++----- npm-packages/convex/src/cli/lib/components.ts | 26 ++++++---- .../src/cli/lib/components/constants.ts | 2 + .../cli/lib/components/definition/bundle.ts | 25 +++++---- .../definition/directoryStructure.ts | 33 ++++++++---- .../scripts/build-convexServerTypes.py | 31 +++++++++-- 6 files changed, 124 insertions(+), 44 deletions(-) diff --git a/npm-packages/convex/src/bundler/index.ts b/npm-packages/convex/src/bundler/index.ts index 352a3e765..cc070c90f 100644 --- a/npm-packages/convex/src/bundler/index.ts +++ b/npm-packages/convex/src/bundler/index.ts @@ -297,10 +297,26 @@ export async function bundleSchema( dir: string, extraConditions: string[], ) { - let target = path.resolve(dir, "schema.ts"); - if (!ctx.fs.exists(target)) { - target = path.resolve(dir, "schema.js"); + const candidates = [ + "schema.ts", + "schema.mjs", + "schema.cjs", + "schema.js", + ]; + + let target = ""; + for (const filename of candidates) { + const candidatePath = path.resolve(dir, filename); + if (ctx.fs.exists(candidatePath)) { + target = candidatePath; + break; + } + } + + if (!target) { + return []; } + const result = await bundle( ctx, dir, @@ -314,21 +330,30 @@ export async function bundleSchema( } export async function bundleAuthConfig(ctx: Context, dir: string) { - const authConfigPath = path.resolve(dir, "auth.config.js"); - const authConfigTsPath = path.resolve(dir, "auth.config.ts"); - if (ctx.fs.exists(authConfigPath) && ctx.fs.exists(authConfigTsPath)) { + const candidates = [ + "auth.config.ts", + "auth.config.mjs", + "auth.config.cjs", + "auth.config.js" + ]; + + const existingPaths = candidates + .map(filename => path.resolve(dir, filename)) + .filter(filepath => ctx.fs.exists(filepath)); + + if (existingPaths.length > 1) { return await ctx.crash({ exitCode: 1, errorType: "invalid filesystem data", - printedMessage: `Found both ${authConfigPath} and ${authConfigTsPath}, choose one.`, + printedMessage: `Found multiple auth config files: ${existingPaths.join(", ")}, choose one.`, }); } - const chosenPath = ctx.fs.exists(authConfigTsPath) - ? authConfigTsPath - : authConfigPath; - if (!ctx.fs.exists(chosenPath)) { + + if (existingPaths.length === 0) { return []; } + + const chosenPath = existingPaths[0]; const result = await bundle(ctx, dir, [chosenPath], true, "browser"); return result.modules; } @@ -419,10 +444,10 @@ export async function entryPoints( logVerbose(ctx, chalk.yellow(`Skipping dotfile ${fpath}`)); } else if (base.startsWith("#")) { logVerbose(ctx, chalk.yellow(`Skipping likely emacs tempfile ${fpath}`)); - } else if (base === "schema.ts" || base === "schema.js") { + } else if (base === "schema.mjs" || base === "schema.cjs" || base === "schema.js" || base === "schema.ts") { logVerbose(ctx, chalk.yellow(`Skipping ${fpath}`)); } else if ((base.match(/\./g) || []).length > 1) { - // `auth.config.ts` and `convex.config.ts` are important not to bundle. + // `auth.config.*` and `convex.config.*` files are important not to bundle. // `*.test.ts` `*.spec.ts` are common in developer code. logVerbose( ctx, diff --git a/npm-packages/convex/src/cli/lib/components.ts b/npm-packages/convex/src/cli/lib/components.ts index aaefd376d..a55e5dda9 100644 --- a/npm-packages/convex/src/cli/lib/components.ts +++ b/npm-packages/convex/src/cli/lib/components.ts @@ -54,19 +54,27 @@ import { Reporter, Span } from "./tracing.js"; import { DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, + DEFINITION_FILENAME_MJS, + DEFINITION_FILENAME_CJS, } from "./components/constants.js"; import { DeploymentSelection } from "./deploymentSelection.js"; async function findComponentRootPath(ctx: Context, functionsDir: string) { - // Default to `.ts` but fallback to `.js` if not present. - let componentRootPath = path.resolve( - path.join(functionsDir, DEFINITION_FILENAME_TS), - ); - if (!ctx.fs.exists(componentRootPath)) { - componentRootPath = path.resolve( - path.join(functionsDir, DEFINITION_FILENAME_JS), - ); + const candidates = [ + DEFINITION_FILENAME_MJS, + DEFINITION_FILENAME_CJS, + DEFINITION_FILENAME_JS, + DEFINITION_FILENAME_TS, + ]; + + for (const filename of candidates) { + const componentRootPath = path.resolve(path.join(functionsDir, filename)); + if (ctx.fs.exists(componentRootPath)) { + return componentRootPath; + } } - return componentRootPath; + + // Default fallback to .ts for backward compatibility + return path.resolve(path.join(functionsDir, DEFINITION_FILENAME_TS)); } export async function runCodegen( diff --git a/npm-packages/convex/src/cli/lib/components/constants.ts b/npm-packages/convex/src/cli/lib/components/constants.ts index 48e0d0d53..943905511 100644 --- a/npm-packages/convex/src/cli/lib/components/constants.ts +++ b/npm-packages/convex/src/cli/lib/components/constants.ts @@ -1,2 +1,4 @@ export const DEFINITION_FILENAME_TS = "convex.config.ts"; export const DEFINITION_FILENAME_JS = "convex.config.js"; +export const DEFINITION_FILENAME_MJS = "convex.config.mjs"; +export const DEFINITION_FILENAME_CJS = "convex.config.cjs"; diff --git a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts index 96f5dfa36..e32722dae 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts @@ -53,7 +53,7 @@ function componentPlugin({ name: `convex-${mode === "discover" ? "discover-components" : "bundle-components"}`, async setup(build) { // This regex can't be really precise since developers could import - // "convex.config", "convex.config.js", "convex.config.ts", etc. + // "convex.config", "convex.config.mjs", "convex.config.cjs", "convex.config.js", "convex.config.ts", etc. build.onResolve({ filter: /.*convex.config.*/ }, async (args) => { verbose && logMessage(ctx, "esbuild resolving import:", args); if (args.namespace !== "file") { @@ -83,12 +83,14 @@ function componentPlugin({ const candidates = [args.path]; const ext = path.extname(args.path); - if (ext === ".js") { - candidates.push(args.path.slice(0, -".js".length) + ".ts"); + + if (ext === ".mjs" || ext === ".cjs" || ext === ".js") { + candidates.push(args.path.slice(0, -ext.length) + ".ts"); } - if (ext !== ".js" && ext !== ".ts") { - candidates.push(args.path + ".js"); - candidates.push(args.path + ".ts"); + + // If no extension or unrecognized extension, try all in priority order + if (!ext || ![".mjs", ".cjs", ".js", ".ts"].includes(ext)) { + candidates.push(args.path + ".mjs", args.path + ".cjs", args.path + ".js", args.path + ".ts"); } let resolvedPath = undefined; for (const candidate of candidates) { @@ -497,11 +499,14 @@ export async function bundleImplementations( rootComponentDirectory.path, directory.path, ); + // Check for schema files in priority order: .mjs, .cjs, .js, .ts + const schemaCandidates = ["schema.mjs", "schema.cjs", "schema.js", "schema.ts"]; + const schemaExists = schemaCandidates.some(filename => + ctx.fs.exists(path.resolve(resolvedPath, filename)) + ); + let schema; - if (ctx.fs.exists(path.resolve(resolvedPath, "schema.ts"))) { - schema = - (await bundleSchema(ctx, resolvedPath, extraConditions))[0] || null; - } else if (ctx.fs.exists(path.resolve(resolvedPath, "schema.js"))) { + if (schemaExists) { schema = (await bundleSchema(ctx, resolvedPath, extraConditions))[0] || null; } else { diff --git a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts index 89bbc9dae..36fff87be 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts @@ -3,6 +3,8 @@ import { Context } from "../../../../bundler/context.js"; import { DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, + DEFINITION_FILENAME_MJS, + DEFINITION_FILENAME_CJS, } from "../constants.js"; import { getFunctionsDirectoryPath } from "../../config.js"; @@ -29,7 +31,7 @@ export type ComponentDirectory = { path: string; /** - * Absolute local filesystem path to the `convex.config.{ts,js}` file within the component definition. + * Absolute local filesystem path to the `convex.config.{mjs,cjs,js,ts}` file within the component definition. */ definitionPath: string; }; @@ -67,17 +69,30 @@ export function isComponentDirectory( return { kind: "err", why: `Not a directory` }; } - // Check that we have a definition file, defaulting to `.ts` but falling back to `.js`. - let filename = DEFINITION_FILENAME_TS; - let definitionPath = path.resolve(path.join(directory, filename)); - if (!ctx.fs.exists(definitionPath)) { - filename = DEFINITION_FILENAME_JS; - definitionPath = path.resolve(path.join(directory, filename)); + // Check that we have a definition file, using priority order: .mjs, .cjs, .js, .ts + const candidates = [ + DEFINITION_FILENAME_MJS, + DEFINITION_FILENAME_CJS, + DEFINITION_FILENAME_JS, + DEFINITION_FILENAME_TS, + ]; + + let filename = ""; + let definitionPath = ""; + + for (const candidate of candidates) { + const candidatePath = path.resolve(path.join(directory, candidate)); + if (ctx.fs.exists(candidatePath)) { + filename = candidate; + definitionPath = candidatePath; + break; + } } - if (!ctx.fs.exists(definitionPath)) { + + if (!filename) { return { kind: "err", - why: `Directory doesn't contain a ${filename} file`, + why: `Directory doesn't contain any of the supported definition files: ${candidates.join(", ")}`, }; } const definitionStat = ctx.fs.stat(definitionPath); diff --git a/npm-packages/dashboard-common/scripts/build-convexServerTypes.py b/npm-packages/dashboard-common/scripts/build-convexServerTypes.py index 3f75e93c6..f1a4d9568 100644 --- a/npm-packages/dashboard-common/scripts/build-convexServerTypes.py +++ b/npm-packages/dashboard-common/scripts/build-convexServerTypes.py @@ -6,7 +6,7 @@ RELATIVE_PATH_TO_OUTPUT_FILE = "../src/lib/generated/convexServerTypes.json" # The entrypoints and helpers from `convex` NPM package used in Convex server functions -SERVER_ENTRYPOINTS = ["server", "values", "type_utils.d.ts"] +SERVER_ENTRYPOINTS = ["server", "values", "type_utils"] # For VS Code PATH_PREFIX = "file:///convex/" @@ -36,10 +36,35 @@ def build_entrypoint(convex_build_directory, entry_point): def find_dts_files(path, base_path): dts_files = {} if os.path.isdir(path): + # Collect all .d.ts, .d.cts, .d.mts files in this directory + dir_files = {} for item in os.listdir(path): item_path = os.path.join(path, item) - dts_files.update(find_dts_files(item_path, base_path)) - elif path.endswith(".d.ts"): + if os.path.isdir(item_path): + dts_files.update(find_dts_files(item_path, base_path)) + elif item.endswith((".d.mts", ".d.cts", ".d.ts")): + # Extract base name (e.g., "a" from "a.d.mts") + if item.endswith(".d.mts"): + base_name = item[:-6] # Remove ".d.mts" + priority = 0 # Highest priority + elif item.endswith(".d.cts"): + base_name = item[:-6] # Remove ".d.cts" + priority = 1 + else: # .d.ts + base_name = item[:-5] # Remove ".d.ts" + priority = 2 # Lowest priority + + if base_name not in dir_files or priority < dir_files[base_name][1]: + dir_files[base_name] = (item_path, priority) + + # Process the selected files from this directory + for item_path, _ in dir_files.values(): + relative_path = os.path.relpath(item_path, base_path) + with open(item_path, "r", encoding="utf-8") as file: + dts_files[PATH_PREFIX + relative_path] = strip_source_map_suffix( + file.read() + ) + elif path.endswith((".d.mts", ".d.cts", ".d.ts")): relative_path = os.path.relpath(path, base_path) with open(path, "r", encoding="utf-8") as file: dts_files[PATH_PREFIX + relative_path] = strip_source_map_suffix( From 2bb6d21482bd27ab1da91be7965cac14821f62d0 Mon Sep 17 00:00:00 2001 From: prisis Date: Wed, 25 Jun 2025 21:48:23 +0200 Subject: [PATCH 2/3] refactor: streamline configuration file handling by removing .cjs support - Removed support for .cjs file extension in various components, including bundler and component definitions. - Updated logic to prioritize .js and .ts extensions for configuration files. - Adjusted comments and error messages for clarity regarding supported file types. --- npm-packages/convex/src/bundler/index.ts | 38 +++++++------------ npm-packages/convex/src/cli/lib/components.ts | 6 +-- .../src/cli/lib/components/constants.ts | 1 - .../cli/lib/components/definition/bundle.ts | 12 +++--- .../definition/directoryStructure.ts | 6 +-- 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/npm-packages/convex/src/bundler/index.ts b/npm-packages/convex/src/bundler/index.ts index cc070c90f..60ec80387 100644 --- a/npm-packages/convex/src/bundler/index.ts +++ b/npm-packages/convex/src/bundler/index.ts @@ -297,12 +297,11 @@ export async function bundleSchema( dir: string, extraConditions: string[], ) { - const candidates = [ - "schema.ts", - "schema.mjs", - "schema.cjs", - "schema.js", - ]; + const candidates = [ + "schema.ts", + "schema.mjs", + "schema.js", + ]; let target = ""; for (const filename of candidates) { @@ -330,30 +329,21 @@ export async function bundleSchema( } export async function bundleAuthConfig(ctx: Context, dir: string) { - const candidates = [ - "auth.config.ts", - "auth.config.mjs", - "auth.config.cjs", - "auth.config.js" - ]; - - const existingPaths = candidates - .map(filename => path.resolve(dir, filename)) - .filter(filepath => ctx.fs.exists(filepath)); - - if (existingPaths.length > 1) { + const authConfigPath = path.resolve(dir, "auth.config.js"); + const authConfigTsPath = path.resolve(dir, "auth.config.ts"); + if (ctx.fs.exists(authConfigPath) && ctx.fs.exists(authConfigTsPath)) { return await ctx.crash({ exitCode: 1, errorType: "invalid filesystem data", - printedMessage: `Found multiple auth config files: ${existingPaths.join(", ")}, choose one.`, + printedMessage: `Found both ${authConfigPath} and ${authConfigTsPath}, choose one.`, }); } - - if (existingPaths.length === 0) { + const chosenPath = ctx.fs.exists(authConfigTsPath) + ? authConfigTsPath + : authConfigPath; + if (!ctx.fs.exists(chosenPath)) { return []; } - - const chosenPath = existingPaths[0]; const result = await bundle(ctx, dir, [chosenPath], true, "browser"); return result.modules; } @@ -444,7 +434,7 @@ export async function entryPoints( logVerbose(ctx, chalk.yellow(`Skipping dotfile ${fpath}`)); } else if (base.startsWith("#")) { logVerbose(ctx, chalk.yellow(`Skipping likely emacs tempfile ${fpath}`)); - } else if (base === "schema.mjs" || base === "schema.cjs" || base === "schema.js" || base === "schema.ts") { + } else if (base === "schema.mjs" || base === "schema.js" || base === "schema.ts") { logVerbose(ctx, chalk.yellow(`Skipping ${fpath}`)); } else if ((base.match(/\./g) || []).length > 1) { // `auth.config.*` and `convex.config.*` files are important not to bundle. diff --git a/npm-packages/convex/src/cli/lib/components.ts b/npm-packages/convex/src/cli/lib/components.ts index a55e5dda9..a92048efc 100644 --- a/npm-packages/convex/src/cli/lib/components.ts +++ b/npm-packages/convex/src/cli/lib/components.ts @@ -55,13 +55,11 @@ import { DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, DEFINITION_FILENAME_MJS, - DEFINITION_FILENAME_CJS, } from "./components/constants.js"; import { DeploymentSelection } from "./deploymentSelection.js"; async function findComponentRootPath(ctx: Context, functionsDir: string) { const candidates = [ DEFINITION_FILENAME_MJS, - DEFINITION_FILENAME_CJS, DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, ]; @@ -73,8 +71,8 @@ async function findComponentRootPath(ctx: Context, functionsDir: string) { } } - // Default fallback to .ts for backward compatibility - return path.resolve(path.join(functionsDir, DEFINITION_FILENAME_TS)); + // Default fallback to .js for backward compatibility + return path.resolve(path.join(functionsDir, DEFINITION_FILENAME_JS)); } export async function runCodegen( diff --git a/npm-packages/convex/src/cli/lib/components/constants.ts b/npm-packages/convex/src/cli/lib/components/constants.ts index 943905511..1d01bb49f 100644 --- a/npm-packages/convex/src/cli/lib/components/constants.ts +++ b/npm-packages/convex/src/cli/lib/components/constants.ts @@ -1,4 +1,3 @@ export const DEFINITION_FILENAME_TS = "convex.config.ts"; export const DEFINITION_FILENAME_JS = "convex.config.js"; export const DEFINITION_FILENAME_MJS = "convex.config.mjs"; -export const DEFINITION_FILENAME_CJS = "convex.config.cjs"; diff --git a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts index e32722dae..bf1df9537 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts @@ -53,7 +53,7 @@ function componentPlugin({ name: `convex-${mode === "discover" ? "discover-components" : "bundle-components"}`, async setup(build) { // This regex can't be really precise since developers could import - // "convex.config", "convex.config.mjs", "convex.config.cjs", "convex.config.js", "convex.config.ts", etc. + // "convex.config", "convex.config.mjs", "convex.config.js", "convex.config.ts", etc. build.onResolve({ filter: /.*convex.config.*/ }, async (args) => { verbose && logMessage(ctx, "esbuild resolving import:", args); if (args.namespace !== "file") { @@ -84,13 +84,13 @@ function componentPlugin({ const candidates = [args.path]; const ext = path.extname(args.path); - if (ext === ".mjs" || ext === ".cjs" || ext === ".js") { + if (ext === ".mjs" || ext === ".js") { candidates.push(args.path.slice(0, -ext.length) + ".ts"); } // If no extension or unrecognized extension, try all in priority order - if (!ext || ![".mjs", ".cjs", ".js", ".ts"].includes(ext)) { - candidates.push(args.path + ".mjs", args.path + ".cjs", args.path + ".js", args.path + ".ts"); + if (!ext || ![".mjs", ".js", ".ts"].includes(ext)) { + candidates.push(args.path + ".mjs", args.path + ".js", args.path + ".ts"); } let resolvedPath = undefined; for (const candidate of candidates) { @@ -499,8 +499,8 @@ export async function bundleImplementations( rootComponentDirectory.path, directory.path, ); - // Check for schema files in priority order: .mjs, .cjs, .js, .ts - const schemaCandidates = ["schema.mjs", "schema.cjs", "schema.js", "schema.ts"]; + // Check for schema files in priority order: .mjs, .js, .ts + const schemaCandidates = ["schema.mjs", "schema.js", "schema.ts"]; const schemaExists = schemaCandidates.some(filename => ctx.fs.exists(path.resolve(resolvedPath, filename)) ); diff --git a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts index 36fff87be..2ade18eb3 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts @@ -4,7 +4,6 @@ import { DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, DEFINITION_FILENAME_MJS, - DEFINITION_FILENAME_CJS, } from "../constants.js"; import { getFunctionsDirectoryPath } from "../../config.js"; @@ -31,7 +30,7 @@ export type ComponentDirectory = { path: string; /** - * Absolute local filesystem path to the `convex.config.{mjs,cjs,js,ts}` file within the component definition. + * Absolute local filesystem path to the `convex.config.{mjs,js,ts}` file within the component definition. */ definitionPath: string; }; @@ -69,10 +68,9 @@ export function isComponentDirectory( return { kind: "err", why: `Not a directory` }; } - // Check that we have a definition file, using priority order: .mjs, .cjs, .js, .ts + // Check that we have a definition file, using priority order: .mjs, .js, .ts const candidates = [ DEFINITION_FILENAME_MJS, - DEFINITION_FILENAME_CJS, DEFINITION_FILENAME_JS, DEFINITION_FILENAME_TS, ]; From 20c665fa50627671123bf79003869921b473aa65 Mon Sep 17 00:00:00 2001 From: prisis Date: Wed, 25 Jun 2025 21:57:06 +0200 Subject: [PATCH 3/3] refactor: update file extension priority in schema and definition checks - Adjusted the priority order for schema and definition file checks to prioritize .ts over .mjs and .js. - Removed references to .d.cts files in the DTS file collection logic to streamline the process. - Updated comments for clarity regarding the new priority order. --- .../src/cli/lib/components/definition/bundle.ts | 4 ++-- .../lib/components/definition/directoryStructure.ts | 4 ++-- .../scripts/build-convexServerTypes.py | 11 ++++------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts index bf1df9537..4d2f55070 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/bundle.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/bundle.ts @@ -499,8 +499,8 @@ export async function bundleImplementations( rootComponentDirectory.path, directory.path, ); - // Check for schema files in priority order: .mjs, .js, .ts - const schemaCandidates = ["schema.mjs", "schema.js", "schema.ts"]; + // Check for schema files in priority order: .ts, .mjs, .js + const schemaCandidates = ["schema.ts", "schema.mjs", "schema.js"]; const schemaExists = schemaCandidates.some(filename => ctx.fs.exists(path.resolve(resolvedPath, filename)) ); diff --git a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts index 2ade18eb3..374dcdddf 100644 --- a/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts +++ b/npm-packages/convex/src/cli/lib/components/definition/directoryStructure.ts @@ -68,11 +68,11 @@ export function isComponentDirectory( return { kind: "err", why: `Not a directory` }; } - // Check that we have a definition file, using priority order: .mjs, .js, .ts + // Check that we have a definition file, using priority order: .ts, .mjs, .js const candidates = [ + DEFINITION_FILENAME_TS, DEFINITION_FILENAME_MJS, DEFINITION_FILENAME_JS, - DEFINITION_FILENAME_TS, ]; let filename = ""; diff --git a/npm-packages/dashboard-common/scripts/build-convexServerTypes.py b/npm-packages/dashboard-common/scripts/build-convexServerTypes.py index f1a4d9568..9927c949d 100644 --- a/npm-packages/dashboard-common/scripts/build-convexServerTypes.py +++ b/npm-packages/dashboard-common/scripts/build-convexServerTypes.py @@ -36,23 +36,20 @@ def build_entrypoint(convex_build_directory, entry_point): def find_dts_files(path, base_path): dts_files = {} if os.path.isdir(path): - # Collect all .d.ts, .d.cts, .d.mts files in this directory + # Collect all .d.ts, .d.mts files in this directory dir_files = {} for item in os.listdir(path): item_path = os.path.join(path, item) if os.path.isdir(item_path): dts_files.update(find_dts_files(item_path, base_path)) - elif item.endswith((".d.mts", ".d.cts", ".d.ts")): + elif item.endswith((".d.mts", ".d.ts")): # Extract base name (e.g., "a" from "a.d.mts") if item.endswith(".d.mts"): base_name = item[:-6] # Remove ".d.mts" priority = 0 # Highest priority - elif item.endswith(".d.cts"): - base_name = item[:-6] # Remove ".d.cts" - priority = 1 else: # .d.ts base_name = item[:-5] # Remove ".d.ts" - priority = 2 # Lowest priority + priority = 1 # Lower priority if base_name not in dir_files or priority < dir_files[base_name][1]: dir_files[base_name] = (item_path, priority) @@ -64,7 +61,7 @@ def find_dts_files(path, base_path): dts_files[PATH_PREFIX + relative_path] = strip_source_map_suffix( file.read() ) - elif path.endswith((".d.mts", ".d.cts", ".d.ts")): + elif path.endswith((".d.mts", ".d.ts")): relative_path = os.path.relpath(path, base_path) with open(path, "r", encoding="utf-8") as file: dts_files[PATH_PREFIX + relative_path] = strip_source_map_suffix(