-
Notifications
You must be signed in to change notification settings - Fork 459
[BUG] Invalid use of CommonJS __dirname in ESM test file #2778
Copy link
Copy link
Closed
Labels
GSSoC-26Official GSSoC 2026 issueOfficial GSSoC 2026 issueacceptedContribution approved for integration into EaseMotion CSSContribution approved for integration into EaseMotion CSSgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved for GSSoC contributionsApproved for GSSoC contributionshelp wantedExtra attention neededExtra attention neededlevel:intermediateRequires moderate project understandingRequires moderate project understanding
Metadata
Metadata
Assignees
Labels
GSSoC-26Official GSSoC 2026 issueOfficial GSSoC 2026 issueacceptedContribution approved for integration into EaseMotion CSSContribution approved for integration into EaseMotion CSSgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved for GSSoC contributionsApproved for GSSoC contributionshelp wantedExtra attention neededExtra attention neededlevel:intermediateRequires moderate project understandingRequires moderate project understanding
🐛 What's broken?
The
tests/smoke.test.jsfile uses standard ES Module imports (import { ... } from ...), but relies on the CommonJS__dirnamevariable to resolve file paths on lines 12, 13, and 101. In a native Node.js ES Module environment,__dirnameisundefinedand will throw aReferenceError. While Vitest injects a polyfill for this under the hood, relying on it in an ESM file violates Node.js best practices and can break standard Node execution or stricter linting rules.📋 Steps to Reproduce
tests/smoke.test.js.importsyntax at the top of the file.__dirnameis used in theresolve()function.✅ Expected Behavior
Path resolution in modern ES Modules should utilize
import.meta.dirname(Node >= 20.11) or utilizefileURLToPath(import.meta.url)to construct the directory path safely.❌ Actual Behavior
The file uses legacy CommonJS globals (
__dirname) inside an ES Module.🔗 Reproduction
Current Structure: