这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@0xSero
Copy link

@0xSero 0xSero commented Feb 17, 2025

Problem

tsup was not properly handling Windows-style paths (with backslashes) in entry points, causing issues for Windows users when specifying input files using backslashes or mixed path separators.

Solution

Added path normalization using the slash utility to convert Windows backslashes to forward slashes in two key areas:

  1. Array entries: When entry points are provided as an array, each path is normalized
  2. Object entries: When entry points are provided as an object (with custom output names), each path value is normalized

The normalization ensures consistent path handling across platforms by converting Windows backslashes (\) to forward slashes (/) before processing.

Testing

The changes were tested using both Windows-style and mixed path formats, running on macOS to ensure cross-platform compatibility. The test suite includes:

  1. windows: backslash in entry - Tests basic backslash handling
  2. windows: complex path handling - Tests nested paths with backslashes
    entry: [
      String.raw`src\nested\input.ts`,
      String.raw`src\other\path\test.ts`
    ]
  3. windows: object entry with backslashes - Tests object entries with custom names
    entry: {
      'custom-name': String.raw`src\nested\input.ts`
    }
  4. windows: mixed path separators - Tests mixed forward/backward slashes
    entry: [
      'src/nested\\input.ts',
      String.raw`src\other/test.ts`
    ]

All Windows path-related tests pass successfully on macOS, confirming that the changes work correctly while maintaining compatibility with Unix-style paths.

Testing Instructions

You can verify these changes by:

  1. Running npm test -- -t "windows:" to run the Windows-specific tests
  2. Testing with Windows-style paths in your entry points:
    entry: ['src\\input.ts']
    // or
    entry: { 'output': 'src\\input.ts' }

Issue:

closes: #1150

@codesandbox
Copy link

codesandbox bot commented Feb 17, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 10:41am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot Build files on Windows with absolute, or relative paths

1 participant