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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Node target for library builds #112

Open
billyjanitsch opened this issue May 21, 2021 · 0 comments
Open

Detect Node target for library builds #112

billyjanitsch opened this issue May 21, 2021 · 0 comments

Comments

@billyjanitsch
Copy link
Collaborator

We currently hardcode a target version of Node for library builds:

if (env === 'esm' || env === 'cjs') return {node: '14.14', browsers: []}

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:

  1. Starting from the file path being transpiled, traverse upwards to find a package.json.
  2. If one exists, check if it has an engines.node field.
  3. If it does, parse it and use the lowest satisfying version as the default target.
  4. 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?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant