10-06-2017 09:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-06-2017 09:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
TL,DR: Is there a preferred way of importing external JS/TS into the project?
If I recall correctly the max size we can have for a rollup bundle is 64kb, but I find working with raw javascript, especially with the sensor data, to be a bit limiting and would love to bring in an external library like lodash or even my own custom built ionic-centric library. There seems to be no external code addition option in the sdk so the only way that seems to make sense is to do a separate outside rollup exporting the desired library as an Es6 module and then copying the bundle into the interface, but this seems bad due to 1) lots of copying and pasting 2) the sdk rollup can't tree-shake to eliminate unnecessary code.
10-06-2017 13:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-06-2017 13:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I was also looking into how to include existing modules and used Browserify so far. Wrote down my findings here https://community.fitbit.com/t5/SDK-Development/Using-non-ES6-modules/td-p/2224095
Have not looked into what Rollup can do yet. Can Rollup export non es6 modules to es6?

10-06-2017 14:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-06-2017 14:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yeah, I saw your post. Pretty much any bundler (webpack, rollup, browserify,...) can export es6 modules. You just have to import the non-es6 library as a variable and then export that variable in your bundle. This just seems rather inefficient to have to use a separate bundler when we have a system already using one in the sdk and it won't allow us to use tree-shaking to eliminate unused modules.

