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

Conversation

@MarkShawn2020
Copy link

Description

When using tsup's watch mode with an outDir that points to a location outside the current directory (e.g., ../../dist), file changes are not detected and the rebuild is not triggered. This PR fixes the issue by improving the path comparison logic in the watch mode.

Problem

The current implementation uses glob patterns to check if a file should be ignored, which doesn't handle external paths correctly. This leads to watch mode failing to detect changes when outDir is outside the current directory.

Solution

  • Convert all paths to absolute paths before comparison
  • Replace glob-based ignore check with direct path comparison using startsWith
  • Ensure consistent path handling for both local and external directories

Test Cases

  1. Watch mode with local outDir (./dist):

    export default defineConfig({
      outDir: 'dist',
      watch: true
    })

    ✅ Works as expected

  2. Watch mode with external outDir (../../dist):

    export default defineConfig({
      outDir: '../../dist',
      watch: true
    })

    ✅ Now works correctly

Breaking Changes

None. This is a bug fix that maintains backward compatibility.

When using tsup's watch mode with an outDir that points to a location
outside the current directory (e.g., ../../dist), file changes are not
detected and the rebuild is not triggered.

This commit fixes the issue by:
- Converting paths to absolute paths before comparison
- Replacing glob-based ignore check with direct path comparison
- Ensuring consistent path handling for both local and external directories
@codesandbox
Copy link

codesandbox bot commented Dec 22, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented Dec 22, 2024

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 Dec 22, 2024 9:43pm

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.

1 participant