Search code examples
node.jsnpmpolyfills

Polyfills and package.json optionalDependencies


I'm working on a library that require some polyfills in some environments. Is correct to add the polyfills as optionalDependencies in the package.jso file?


Solution

  • The usual way is adding them in the dependencies and then in the code at runtime detect if needed and require them.