Skip to content

rollup additionalEntry path resolution on windows #29690

@theotonge

Description

@theotonge

Current Behavior

When building a project using @nx/rollup specifying additionalEntrypoints a warning is shown The pattern libs\test-lib\src\entrypoints\*.ts did not match any files even though the files exist

Expected Behavior

The additional entrypoints are found correctly.

GitHub Repo

https://github.com/theotonge/nx-additionalEntrypoints-error-example

Steps to Reproduce

With repo

  1. use windows
  2. clone https://github.com/theotonge/nx-additionalEntrypoints-error-example
  3. run nx build test-lib

Manually

  1. use windows
  2. create a react lib with bundler as rollup
  3. modify project.json to:
  "name": "test-lib",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "libs/test-lib/src",
  "projectType": "library",
  "tags": [],
  "targets": {
    "build": {
      "options": {
        "main": "libs/test-lib/src/index.ts",
        "format": ["esm", "cjs"],
        "additionalEntryPoints": ["libs/test-lib/src/entrypoints/*.ts"],
        "generateExportsField": true
      }
    }
  }
}
  1. create a file in libs/test-lib/src/entrypoints/thing.ts with an export
  2. create a file in libs/test-lib/src/entrypoints/other.ts with an export
  3. run nx build test-lib

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.18.1
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.2

nx                     : 20.3.2
@nx/js                 : 20.3.2
@nx/jest               : 20.3.2
@nx/eslint             : 20.3.2
@nx/eslint-plugin      : 20.3.2
@nx/module-federation  : 20.3.2
@nx/react              : 20.3.2
@nx/rollup             : 20.3.2
@nx/vite               : 20.3.2
@nx/web                : 20.3.2
typescript             : 5.6.3
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/rollup/plugin

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

The cause of the issue is because the createEntrypoints method is calling globSync from tinyglobby, passing a full windows path - tinyglobby only seems to support posix paths

As the paths are passed in as relative posix paths, working through the call stack I see that the paths are modified in withNx by calling path.join(workspaceRoot, entry) causing the conversion to windows path.

Replacing all separators at this point seems to solve the issue:

path.join(workspaceRoot, entry).replaceAll(path.sep, path.posix.sep)

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions