Skip to content

@nx/esbuild outputFileName does not respect desired file extensions #33978

@JonathanWilbur

Description

@JonathanWilbur

Current Behavior

If you set outputFileName to main.mjs, it will still produce main.js.
If you set outputFileName to yeet.mjs, it will produce yeet.js.

It seems clear that it does not respect the file extension choice.

Expected Behavior

It should completely respect your file extension choice, including no file extension. If I put main.mjs in outputFileName, there should be a file produced called "main.mjs".

GitHub Repo

https://github.com/Wildboar-Software/directory

Steps to Reproduce

  1. In project.json for a project that builds with @nx/esbuild, set outputFileName to xyz.mjs.
  2. Build it
  3. Observe that the created file is xyz.js.

Nx Report

Node           : 23.8.0
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.9.2

nx             : 22.3.3
@nx/js         : 22.3.3
@nx/eslint     : 22.3.3
@nx/workspace  : 22.3.3
@nx/jest       : 22.3.3
@nx/devkit     : 22.3.3
@nx/esbuild    : 22.3.3
@nx/node       : 22.3.3
@nx/vite       : 22.3.3
@nx/vitest     : 22.3.3
@nx/docker     : 22.3.3
typescript     : 5.9.3
---------------------------------------
Cache Usage: 11.49 MB / 91.47 GB

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Contents of the build job:

{
            "executor": "@nx/esbuild:esbuild",
            "outputs": ["{options.outputPath}"],
            "options": {
                "main": "apps/meerkat/src/main.ts",
                "outputPath": "dist/apps/meerkat",
                "outputFileName": "main.mjs",
                "tsConfig": "apps/meerkat/tsconfig.app.json",
                "platform": "node",
                "format": ["esm"],
                "generatePackageJson": true,
                "esbuildOptions": {
                    "minify": false,
                    "banner": {
                        "js": "#!/bin/env node"
                    },
                    "footer": {
                        "js": "// Minified Meerkat DSA Javascript Source - Copyright (c) Wildboar Software 2025 - MIT License"
                    }
                },
                "assets": [
                    {
                        "glob": "apps/meerkat/README.md",
                        "input": "apps/meerkat/src",
                        "output": "."
                    },
                    {
                        "glob": "assets/**",
                        "input": "apps/meerkat/src",
                        "output": "."
                    },
                    {
                        "glob": "prisma/**",
                        "input": "apps/meerkat/src",
                        "output": "."
                    }
                ]
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions