Polymer / pwa-starter-kit

Starter templates for building full-featured Progressive Web Apps from web components.
https://pwa-starter-kit.polymer-project.org
2.36k stars 431 forks source link

How to get started with dependencies using npm #361

Closed brecke closed 5 years ago

brecke commented 5 years ago

Hi all,

I've been experimenting with Polymer for a project I'm starting soon. I was able to install it and run it, but I tried implementing login/logout with cookie based sessions via external packages and I'm stalled. I tried universal-cookie and js-cookie but keep having problems such as "require is not defined" which I think are due to trying to integrate non-es6 code directly - I'm new to modern frontend development, so bear with me.

I also tried the webpack branch and tried doing the same, and it works out of the box.

That being said, I have a couple of questions, the first being am I doing something wrong or missing something really obvious regarding the use of external packages (via npm) with the original starter kit? And if not, why does the webpack branch work, shouldn't the two approaches be similar in scope?

Thanks in advance,

keanulee commented 5 years ago

Your observations are entirely correct - those modules aren't distributed as ES modules and that's why only the webpack branch works. See the FAQ for more details.

brecke commented 5 years ago

Thanks! Somehow I missed the FAQ link 🤦🏻‍♂️