medooze/sframe

npm module can't be imported

maikthomas opened this issue · 2 comments

I see the lib is published on npm, but it's not importable as a module https://www.npmjs.com/package/sframe
The main field of package.json points to index.js which doesn't exist.
Also the worker will not be accessible this way.
I would propose to:

  • Add an index.js which exports the public api members
  • Bundle the lib with webpack
  • use webpack to inline the worker as a blob url so it doesn't have to be hosted separately
  • Either build locally and add build to repo, or add a build job in something like travis.

I'm happy to open a PR with these changes.

I am not familiar with webpack so a PR would be very welcome

@murillo128 could you potentially take a look at this PR here:
ggoldens#1
In that PR I add the webpack config need to bundle the library including the worker so that it can be installed via npm.
and this repo I have a project that imports the library (using github instead of npm, since it's not published): https://github.com/maikthomas/sframe-import-webpack

The reason to use webpack is to bundle the worker inline, without the worker we wouldn't need to bundle the code as the end-users project could do that.

I can open a similar PR here but it would cause a couple issues:

  • Breaking change to the worker URL in Client.js, the code will no longer work unless bundled with webpack.
  • Example in this repo would need to be adapted, most likely to include the build library as a script tag, removing the ES6 modules stuff, and would be dependant on the lib being built before it would work
  • In the PR above I put the build into a dist_github folder which is tracked and commited. Here it might make more sense to build into a dist folder which is git ignored, and instead publish dist to  npm. This could just be you building the lib locally then publishing, or establishing some kind of travis pipeline.

The upside to all this being that you will have an easily installable library with no need to self-host workers or anything else.