Detect Node target for library builds
billyjanitsch opened this issue · comments
Billy Janitsch commented
We currently hardcode a target version of Node for library builds:
Line 35 in 4b37790
We're adding engines
field to all of our projects. This corresponds to the consuming environment so the lowest satisfying version is exactly the one that we'd want as the default Node target when transpiling libraries.
We could try to detect this automatically:
- Starting from the file path being transpiled, traverse upwards to find a
package.json
. - If one exists, check if it has an
engines.node
field. - If it does, parse it and use the lowest satisfying version as the default target.
- Otherwise, fall back to the current explicit value as a default? Or throw, but provide an option to pass an explicit value if the auto-detection doesn't fit the use case?