postaljs / postal.request-response

postal.js add-on that provides a request/response pattern API.
MIT License
35 stars 13 forks source link

Correct way to ES6 import this #11

Open mjp0 opened 8 years ago

mjp0 commented 8 years ago

I'm currently using require('postal.request-response')(require('postal')) to include the module but this seems to fail with webpack for some reason.

So excuse me if this is obvious but what's the way to use ES6 import with this? I can't seem to find the right combination so that postal itself is included.

derekdon commented 8 years ago

Try this:

/**
 * Setup Postal
 *
 * For some reason the request-response plugin needs to be
 * passed postal, while the other plugins just require it internally.
 *
 */
import postal from 'postal';
import postalRR from 'postal.request-response';
postalRR(postal);

I also needed to disable the plugin's preference to use AMD via a webpack loader config:

{ test: /postal/, loader: 'imports?define=>false' }