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

fix: incorrectly resolving knownJsSrcRE files from root (fixes #4161) #8808

Merged
merged 3 commits into from
Jun 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: extract regex
sapphi-red committed Jun 28, 2022
commit 56a77de97285f8e5a7fc4b0658923ea6e3d0faf8
4 changes: 3 additions & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
@@ -1064,11 +1064,13 @@ export function stripBomTag(content: string): string {

export const isTS = (filename: string): boolean => /\.[cm]?ts$/.test(filename)

const windowsDrivePathPrefixRE = /^[A-Za-z]:[/\\]/

/**
* path.isAbsolute also returns true for drive relative paths on windows (e.g. /something)
* this function returns false for them but true for absolute paths (e.g. C:/something)
*/
export const isNonDriveRelativeAbsolutePath = (p: string): boolean => {
if (!isWindows) return p.startsWith('/')
return /^[A-Za-z]:[/\\]/.test(p)
return windowsDrivePathPrefixRE.test(p)
}