mobile-detect.js icon indicating copy to clipboard operation
mobile-detect.js copied to clipboard

ES6 module support

Open kkimdev opened this issue 7 years ago • 8 comments

It would be great if mobile-detect supports ES6 module style :)

kkimdev avatar Mar 01 '18 01:03 kkimdev

Yes, indeed. Currently, I have not enough time for this. PR welcome.

hgoebl avatar Mar 01 '18 16:03 hgoebl

@hgoebl I'm going to give this a try, I have an idea how to simplify the code and the import process overall. I'll try on a different branch and maybe discuss it separately based on the PR.

serbanghita avatar Mar 01 '18 17:03 serbanghita

@serbanghita I guess a natural way to do is that feature-detect if browser supports es6 module, then export if so?

kkimdev avatar Mar 08 '18 23:03 kkimdev

I'm not quite sure what exactly is this issue about. I came here to report thats it's hard to import it in my ES6 JS/TS project. I'm transpiling it to ES5 anyway, so I don't mind browser-side module support.

My issue is that it's:

  • impossible to import and access via import MobileDetect from 'mobile-detect', my error tells me that 'mobile-detect' doesn't have default exports
  • mobile-detect gets itself to the global scope automatically and we can't contain it in our project with simple way. We want to avoid global scope pollution.

Should I create new issue?

Zielak avatar Jun 20 '18 08:06 Zielak

@Zielak this issue is for that :)

kkimdev avatar Jun 20 '18 08:06 kkimdev

+1, ES6 import would be nice

DrNiels avatar Oct 22 '18 14:10 DrNiels

Hello, please know to tell me if it already works with ES6, otherwise what a way to do!

Thank you!

d3ividi avatar Jun 27 '19 14:06 d3ividi

Everybody is welcome to create a PR. Please keep in mind that the code is generated and the template is the thing which should carry the solution.

hgoebl avatar Jun 27 '19 18:06 hgoebl