krakenjs / post-robot

Cross domain post-messaging on the client side using a simple listener/client pattern.
Apache License 2.0
746 stars 91 forks source link

Importing post-robot #29

Closed vovimayhem closed 7 years ago

vovimayhem commented 7 years ago

Hi! I'm having a bit of trouble with importing post-robot inside an Ember component. I strongly suspect this is something easy:

import Ember  from 'ember';
import postRobot from 'post-robot';

This will fail with the following message:

Error: Could not find module `post-robot` imported from (...)

How I'm supposed to refer to postRobot from here?? I added it to my project with npm install --save post-robot...

vovimayhem commented 7 years ago

Got it working!

To make the library accessible via import, I generated an "ES6 shim". See the "Managing Dependencies - Standard Non-AMD Asset" section in the Ember CLI guides.

bluepnume commented 7 years ago

Weird. post-robot should be AMD-ified already by webpack. Going to re-open this so I can look into it.

bluepnume commented 7 years ago

Yeah, tried this for myself and it seems like there's not much that can be done in post-robot to avoid needing that ES6 shim to be generated. Shame, since tools like webpack manage just fine. Any ember-cli experts ever read this and know a better way of solving this for everyone, please let me know.