Refactored with tests for dependency resolution, using Esprima for require() parsing