Skip to content

Conversation

AlemTuzlak
Copy link
Contributor

Due to this bug fix: #988 the entries on Windows are completely broken due to a transform happening midway between the plugin and the final resolver which turns the escaped \ \ into /.

I couldn't pinpoint the exact cause, and this fix mostly covers the issues on Windows, the only thing that won't work is the ( ) escape.

Copy link
Member

@webpro webpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could we then also re-enable the Windows test?

@@ -47,7 +48,7 @@ const resolveConfig: ResolveConfig<PluginConfig> = async (localConfig, options)
// See:
// - https://reactrouter.com/how-to/file-route-conventions#optional-segments
// - https://www.npmjs.com/package/fast-glob#advanced-syntax
.map(route => route.replace(/[$^*+?()\[\]]/g, '\\$&'));
.map(route => os.platform() === "win32" ? route : route.replace(/[$^*+?()\[\]]/g, '\\$&'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(route => os.platform() === "win32" ? route : route.replace(/[$^*+?()\[\]]/g, '\\$&'));
.map(route => isWindows ? route : route.replace(/[$^*+?()\[\]]/g, '\\$&'));

@@ -5,6 +5,7 @@ import { join } from '../../util/path.js';
import { hasDependency, load } from '../../util/plugin.js';
import vite from '../vite/index.js';
import type { PluginConfig, RouteConfigEntry } from './types.js';
import os from 'node:os';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import os from 'node:os';
import os from 'node:os';
const isWindows = os.platform() === 'win32';

@AlemTuzlak AlemTuzlak requested a review from webpro June 11, 2025 10:31
Copy link

pkg-pr-new bot commented Jun 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/knip@1130

commit: e353b9b

@webpro webpro merged commit bbf67dd into webpro-nl:main Jun 11, 2025
29 checks passed
@webpro
Copy link
Member

webpro commented Jun 11, 2025

Thanks, Alem! 🙏

@webpro
Copy link
Member

webpro commented Jun 12, 2025

🚀 This pull request is included in v5.61.0. See Release 5.61.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

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.

2 participants