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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent more false positives on cjs #19

Merged
merged 1 commit into from Oct 28, 2021
Merged

Conversation

danielroe
Copy link
Member

No description provided.

@danielroe danielroe requested a review from pi0 October 28, 2021 09:27
@danielroe danielroe self-assigned this Oct 28, 2021
@@ -11,7 +11,7 @@ export function hasESMSyntax (code: string): boolean {
return ESM_RE.test(code)
}

const CJS_RE = /([\s;]|^)(module.exports\b|exports\.|require\s*\(|global\b)/m
const CJS_RE = /([\s;]|^)(module.exports\b|exports\.\w|require\s*\(|global\.\w)/m
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if this is affecting static analyze regexes or not? 馃檲 Wouldn't be easier for longer-term to use same regex or keep it as string and compile it with additional checks here?

@pi0 pi0 merged commit 8ac4b74 into main Oct 28, 2021
@pi0 pi0 deleted the fix/cjs-detection-improvements branch October 28, 2021 09:43
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.

None yet

2 participants