diff --git a/packages/graphql/lib/plugin/visitors/model-class.visitor.ts b/packages/graphql/lib/plugin/visitors/model-class.visitor.ts index c79a288a1..9dc008b8c 100644 --- a/packages/graphql/lib/plugin/visitors/model-class.visitor.ts +++ b/packages/graphql/lib/plugin/visitors/model-class.visitor.ts @@ -54,7 +54,8 @@ export class ModelClassVisitor { const metadataWithImports = []; Object.keys(this._collectedMetadata).forEach((filePath) => { const metadata = this._collectedMetadata[filePath]; - const path = filePath.replace(/\.[jt]s$/, ''); + // Emit explicit .js specifiers so generated metadata.ts stays NodeNext-compatible. + const path = filePath.replace(/\.[jt]s$/, '.js'); const importExpr = ts.factory.createCallExpression( ts.factory.createToken(ts.SyntaxKind.ImportKeyword) as ts.Expression, undefined, diff --git a/packages/graphql/tests/plugin/fixtures/serialized-meta.fixture.ts b/packages/graphql/tests/plugin/fixtures/serialized-meta.fixture.ts index 467ee5e03..f5cbec086 100644 --- a/packages/graphql/tests/plugin/fixtures/serialized-meta.fixture.ts +++ b/packages/graphql/tests/plugin/fixtures/serialized-meta.fixture.ts @@ -9,7 +9,7 @@ export default async () => { '@nestjs/graphql': { models: [ [ - import('./recipes/dto/new-recipe.input'), + import('./recipes/dto/new-recipe.input.js'), { NewRecipeInput: { title: { @@ -22,7 +22,7 @@ export default async () => { } ], [ - import('./recipes/dto/recipes.args'), + import('./recipes/dto/recipes.args.js'), { RecipesArgs: { skip: { type: () => Number }, @@ -31,7 +31,7 @@ export default async () => { } ], [ - import('./recipes/models/ingredient.model'), + import('./recipes/models/ingredient.model.js'), { Ingredient: { id: { type: () => String }, @@ -40,7 +40,7 @@ export default async () => { } ], [ - import('./recipes/models/recipe.model'), + import('./recipes/models/recipe.model.js'), { Recipe: { id: { type: () => String },