hindley-milner-parser-js icon indicating copy to clipboard operation
hindley-milner-parser-js copied to clipboard

browser support

Open davidchambers opened this issue 7 years ago • 5 comments

Based on sanctuary-js/sanctuary-site#23 it seems one can't simply import HMP via a <script> tag. I would very much like to be able to do so. I suggest either:

  • including a browser build in the tarball; or
  • having a single source file which uses the export mechanism appropriate to the environment.

I prefer the latter. It adds a bit of boilerplate, but obviates the need for a build step. :)

davidchambers avatar Apr 14 '17 07:04 davidchambers

I think we need a build step as we are depending on nearley. There is already a build step though, which I added after reading https://github.com/fluture-js/Fluture/pull/58, so no big deal there.

I guess we'd basically be doing what ramda is to create the version in dist? Inlining require and adding a little wrapper around it? I couldn't find an npm package that does this, do you know of one?

kedashoe avatar Apr 14 '17 16:04 kedashoe

I couldn't find an npm package that does this, do you know of one?

No. I haven't yet needed such a tool.

davidchambers avatar Apr 15 '17 23:04 davidchambers

k I'll keep looking/figure something out.

kedashoe avatar Apr 16 '17 06:04 kedashoe

May I suggest using Rollup to create an IIFE or UMD build? Using that it should be possible to bundle the nearley dependency in your build. This should make it possible to directly use the build in a <script> tag.

mickdekkers avatar Sep 27 '17 16:09 mickdekkers

Thanks @mickdekkers . Ended up not needing it for this issue as we bundled a parent lib for the browser, but I'll leave the issue open and look into using rollup for a browser build for this lib.

kedashoe avatar Sep 27 '17 19:09 kedashoe