Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Can this be made to work in the browser please? :-) #83

Open
serapath opened this issue May 4, 2017 · 1 comment
Open

Can this be made to work in the browser please? :-) #83

serapath opened this issue May 4, 2017 · 1 comment

Comments

@serapath
Copy link

serapath commented May 4, 2017

Some days ago on twitter https://twitter.com/serapath/status/856908380731916288

Now I just stumbled upon the module.

It seems it currently does not work in the browser, but if it would, that would be awesome, because I would love to use it.

Other than that - one feature I'd love to use it to prompt a user for a token so that it's possible to actually publish data to npm from the browser (think: in-browser Javascript IDE)

I would also try to implement it myself, but dont know what kind of requests I would need to make or how I can learn about it and on top of that if it's even possible regarding maybe CORS settings.

@zkat
Copy link
Owner

zkat commented May 4, 2017

Hm.

It would take a bit of work to get this to work in the browser, and there's a lot you wouldn't be able to do, ever.

Off the top of my head, and I'm probably missing a lot:

  • no git dependencies, local dependencies, symlinks (this will break a lot of things, alone)
  • the tarball extractor will need to be switched out in browser mode to evaluate the scripts directly
  • make-fetch-happen needs to be ported to be isomorphic
  • cacache can never be used, so opts.cache needs to be ignored in browser mode.
  • figure out how to get a test suite working on the browser
  • go through deps-of-deps and make sure nothing is strictly tied to node: I haven't made any such analysis.

I'm concerned that these changes might possibly involve way too many browser-specific changes to be manageable/maintainable. I am totally fine with someone exploring this and using any of the code in pacote/m-f-h/cacache/etc to see if they can build something browser-specific.

But getting pacote working on browsers is not a priority for me in the foreseeable future.

So that leaves you, and I have two suggestions, and it's up to you which one you prefer (or maybe you come up with a better one?):

  1. fork pacote into your own pacote-browser package which tears out everything incompatible with browsers and uses native browser fetch instead of make-fetch-happen (m-f-h mostly matches the fetch API). Maintain the fork separately in your own time.

  2. figure out a (minimal?) patch that will allow a browser-specific (and browser-testable) build of pacote.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants