Skip to content

TypeScript plugin doesn't find buildable project without exports["."]  #32290

@fregante

Description

@fregante

Current Behavior

#29670 was not fixed

This bug exists since Nx 20.3 and has blocked us from upgrading. Our exports generally looks like this:

  "exports": {
    "./package.json": "./package.json",
    "./*.js": "./dist/*.js",
    "./*": "./src/*"
  },

and build is not inferred unless I add an . entry point. In our repo only a handful of packages have that entry point. nx show projects --with-target build essentially produces a list of packages that either lack exports or specify .

nx.json has this config, which matches the one on https://nx.dev/technologies/typescript/introduction

  "plugins": [
    {
      "plugin": "@nx/js/typescript",
      "options": {
        "build": {
          "configName": "tsconfig.lib.json"
        }
      }
    }
  ],

My solution was to add a fictitious entry point that satisfies Nx and points to this bug:

  "exports": {
    "./package.json": "./package.json",
    "./*.js": "./dist/*.js",
    "./*": "./src/*",
+   ".": "./dist/https://github.com/nrwl/nx/issues/29670"
  },

Expected Behavior

build should be inferred even with packages that lack an . exports

GitHub Repo

No response

Steps to Reproduce

  1. Create Nx monorepo with one TS library
  2. Specify "exports": {"./*.js", "./dist/*.js"}
  3. Run nx build the-lib and see it fail because build doesn't exist

Nx Report

Node           : 22.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.3

nx             : 21.3.11
@nx/js         : 21.3.11
@nx/eslint     : 21.3.11
@nx/workspace  : 21.3.11
@nx/devkit     : 21.3.11
typescript     : 5.9.2
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
./scripts/nx/jest-plugin.ts
./scripts/nx/vitest-plugin.ts
---------------------------------------
Cache Usage: 455.18 KB / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions