browserslist icon indicating copy to clipboard operation
browserslist copied to clipboard

[Feature suggestion] Support `package.json` `engines.node` field

Open ehmicky opened this issue 6 years ago • 7 comments

Suggestion for Node.js: default to package.json engines.node field (if present) instead of last 2 versions.

Use case: I am writing Node.js libraries using Node 11 syntax, but compiling with Babel in order to support Node >=6. I am declaring Node.js support with engines.node. Babel preset-env uses browserslist. Currently I need to duplicate the information from engines.node to a browserslist configuration file or preset-env configuration option.

ehmicky avatar Nov 20 '18 12:11 ehmicky

Right now many client-side projects use Browserslist. If we will switch defaults from last 2 versions to package.engine all client-sude projects without browsers config will not work in browser.

I understanding your case, but this default will hurt too many users and is not expected behavior for any client-side projects authors.

We need different solution for your problem.

ai avatar Nov 20 '18 13:11 ai

This could be opt-in by using a configuration option.

Do you think this would then be a good feature idea? If you think this is not worth the effort, I'll close the issue.

Thanks for the help!

ehmicky avatar Nov 20 '18 13:11 ehmicky

We can introduce one extra query like package.json node, but I don't have good idea about query name (it should be short and clear)

ai avatar Nov 20 '18 13:11 ai

Some ideas (not super clear, sorry):

  • used node
  • node in use
  • package node
  • node in package
  • engines node

ehmicky avatar Nov 20 '18 13:11 ehmicky

Another idea:

  • project node version

mutech avatar Dec 05 '18 17:12 mutech

And project electron version

ai avatar Dec 05 '18 17:12 ai

node version in package.json file would be the most explicit, but not sure if it's too much long... Probably node in package.json would be just enought, and also open the door to define the version in other files or locations. Could there be any other file where to define the version used? Maybe in lerna repos?

piranna avatar Oct 29 '20 23:10 piranna