javascriptpolymerpolymer-cli

Polymer CLI and require


I am trying to build a Polymer 3 component that has a dependency on a library that uses Node's require to function. Can I use the Polymer CLI serve and build components that have node style required file?


Solution

  • Polymer uses the ES6 Module syntax and NodeJS uses CommonJS Module syntax module.exports not ES6 module syntax export keyword.

    So it is not possible by default to use the nodejs require within polymer project. Rob Dodson from the polymer team created an experimental project to achieve what you are looking for, but it seems the project did not see the light