-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can this work in the browser? #4
Comments
Cool idea, Alexander! It kind of makes me think of @jbenet's [JRFC 19](jbenet/random-ideas#19): skipping the 'install' step and just *using* packages.
In terms of code, right now `peer-npm` is an npm registry and wrapper over the `npm` command more than anything: I don't know how much of the code here would be applicable to a browser environment.
*However*, the modules that are published with peer-npm are regular node modules (`package.json` metadata and a tarball), so you should be able to pull them in via the browser using ssb/hyperdrive/ipfs or anything else that works in the browser. I'm experimenting heavily with the command line app, but the format of the data that'll be found in a published package probably won't change much.
I think it's a fun and useful experiment. How can I help?
|
You should also check out Everything Stays. You should be able to use |
interesting. I will check out "Everything Stays". thx :-) I am not sure about the details, but the initial page load should be as small and optimized as possible. Maybe the I would love to get some feedback and inspiration of what would actually make the most sense...
I'm actually trying to build something minimal, so that every page eventually becomes something like: <meta charset=“utf-8”>
<body>
<!-- <script name=".npmrc" type="application/json"> ... </script> -->
<script name="package.json" type="application/json">
{
version: '1.0.0',
name: 'hellobrowser',
main: 'hello.js',
// (dev-)dependencies can specify version if any 'cached' or 'latest' is not good enough...
scripts: {
start: ''
}
}
</script>
<script name="src/hello.js" type="text/plain">
var bel = require('bel')
var world = require('./world')
var browser = require('_browser')
module.exports = bel`
<h1> hello ${browser} ${world} </h1>
`
</script>
<script name="src/world.js" type="text/plain">
module.exports = 'world'
</script>
<script name="src/node_modules/_browser.js" type="text/plain">
module.exports = 'browser'
</script>
<script src="https://wzrd.in/standalone/npmrequire">
/* set's `window['npm']` and `window['require']` and then maybe:
1. searches for a script tag with the name `package.json`
and of type "application/json" and turns it into:
=> window['package.json'] = { /* ... content of above script tag ... */ }
2. maybe searches also for a `.npmrc` named script tag?
and turns it into:
=> window['.npmrc'] = `...`
3. it also executes the content of this script tag
*/
// that would probably be run automatically when a normal user visits the page
var main = window['package.json'].main
var hellobrowser = require(main)
document.body.appendChild(hellobrowser)
// that would probably be run from the "devtools" and not here when in "dev mode"
npm.start()
</script>
</body> I went through all the npm cli commands and was wondering if it's actually smart to do it like npm or if also less features would do. What I'm using for quite some time already is a script on codepen https://codepen.io/serapath/pen/yMpGXr/ and I have one version that includes the basic iframe logic but it's not published yet. |
Not sure if it makes sense at all, but it would be awesome if it could work in the browser too :-)
I am currently using a sync
require
function in the browser that downloads modules and caches them inlocalStorage
. I plan to extend it somehow utilizing an iframe to share the modules cross domain, but figured I would actually also like to have some kind ofwindow['package.json']
orlocalStorage['package.json']
and maybe even a way to prompt the user for a token to be able to do anpm publish
directly from the browser or the devtools :-)I'm actually right now working on refining this and even though it utilizes
http://wzrd.in
by default, it's possible to provide an alternative like for example a forked versionwizardamigos-browserify-cdn.herokuapp.com
and ideally it would be kind of neat to provide something ssb and/or hyperdrive based?What do you think about this?
The text was updated successfully, but these errors were encountered: