bestiejs / platform.js

A platform detection library.
https://mths.be/platform
MIT License
3.22k stars 408 forks source link

Loading through Webpack #110

Closed mii9000 closed 8 years ago

mii9000 commented 8 years ago

When loading through Webpack its seems this is how its setting the platform object but throughout the app I get platform is not defined when trying to access like platform.name. How should I be accessing platform when loading through Webpack?

jdalton commented 8 years ago

That's not a Webpack thing. That's an AMD thing. Because you're using platform in the presence of an AMD loader it assumes you're wanting to use it with the AMD loader.

We should fix this though to align with other projects which export to the global when there's an AMD loader just in case you don't want to load through it.

mii9000 commented 8 years ago

@jdalton Thanks for the explanation. So, what can I do currently to workaround this?

jdalton commented 8 years ago

We'll need to add a bit of code to expose platform to the global object.

mii9000 commented 8 years ago

Assuming I can workaround not accessing platform globally, what other options do I have in consuming it? Like I tried importing import 'platform' in a .ts file and while Webpack bundle shows that its doing a require but at runtime its still the same.