Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rollup additionalEntry path resolution on windows #29690

Open
1 of 4 tasks
theotonge opened this issue Jan 20, 2025 · 0 comments
Open
1 of 4 tasks

rollup additionalEntry path resolution on windows #29690

theotonge opened this issue Jan 20, 2025 · 0 comments
Assignees
Labels
scope: bundlers Issues related to webpack, rollup type: bug

Comments

@theotonge
Copy link

theotonge commented Jan 20, 2025

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)
@AgentEnder AgentEnder added the scope: bundlers Issues related to webpack, rollup label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

No branches or pull requests

3 participants