This commit refactors the way info is retrieved from entry-point `package.json` files to make it easier to extract more info (such as the package's name) in the future. It also avoids reading and parsing the `package.json` file multiple times (as was happening before). PR Close #37040