serviejs/popsicle

Need to export 'popsicle' object

Closed this issue · 2 comments

In documentation you use commonjs style require() to import the popsicle module, and then use it as follows:

const popsicle = require('popsicle')
 
popsicle.request({
  method: 'POST',
...
})
.use(popsicle.plugins.parse('json'))

However, the default export is the request object. So using es6 import syntax, following the example gives a popsicle.request is not a function error. Instead, one must do:

import { request, plugins } from 'popsicle'
request(...).use(plugins.parse('json')

not so bad in this tiny example, but if you're using lots of popsicle functions you end uup with a lot of named imports that pollute the namespace. Why not export a popsicle object, either named or by default, so that es6 users one can use syntax consistent with the examples in documentation?

You could just do import * as popsicle from 'popsicle'.

Yeah I thought of that just now and came back to close this before anyone saw it haha. Doh