segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.

Home Page:https://segment.com/libraries/node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for es6

icco opened this issue · comments

This is a bit of a replay of #132, but right now because of the design of this package, to get typescript or other es6 based languages to use this package, you need to write import Analytics = require('analytics-node').

https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1 does a great job of walking through commonjs vs. es6 imports.

At the bottom there are suggested actions to add a wrapper to allow es6 imports, which would make using this package in typescript and other es6 languages a lot easier.

Thoughts on adding this wrapper?

Have you tested it? What happens then?

I mean, have you tested using import Analytics from 'analytics-node'?

@icco Thank you for your inquiry, if you need to re-open this for any reason, please feel free to do so.

FYI- this is still an open problem as described by the original comment.

Looks like in this thread the Segment team is trying to kick the maintenance of type definitions to the crowd at DefinitelyTyped (weird move) but in this thread the type maintainers rightfully point out that the Segment library isn't even es6 compatible yet so they're not going to update until Segment team does. They referenced this ticket, but it's now been marked as closed.

Maybe time for Segment to implement typing on these libraries or at least upgrade to es6 compatible exports so the open source community can offload some of the work?