Open dominictarr opened 8 years ago
@dominictarr does -N
--no-bundle
work for what you want? (for single files or "node like")
It does not currently work with zips though.
I had this same problem with the original version of nucleus which is pretty much why I've added this.
See also https://github.com/nucleus-js/design/issues/22 -- @creationix seems to think people will get confused and have problems with programs that were accessing files during testing but can't when zipped up. Not sure I agree though.
and I understand that it is ment to be possible to create a new nucleus command by just appending a zip of the code? I tried this but was not able to find any documentation.
Right, if you append a zip that has a main.js
in it, it will execute starting with that file from within the zip.
This is documented in my PR for CLI options to the spec in https://github.com/nucleus-js/design/pull/30/files#diff-7becf02ad489c02e98feeccea97f1ad4R7, but should also be stated elsewhere.
(It should also be configurable ala https://github.com/nucleus-js/rustyduk/issues/8)
(the fact that both you and I have had to ask this question means it is definitely a problem lol)
oh, thanks!
-N, --no-bundle do not execute as a bundle
did not sound like what i was looking for
-f FILE execute a single file
would have been more obvious.
Makes sense, we can totally change it to that!
hmm, okay so I recalled that zip files have an index at the end, and for that reason I thought maybe you could just append the zip. If you have to frame the zip, could you also have a framing that just appends a single file? also, would it be possible to have multiple files or zips that each bootstrap a layer?
hmm, okay so I recalled that zip files have an index at the end, and for that reason I thought maybe you could just append the zip. If you have to frame the zip, could you also have a framing that just appends a single file?
If what you are asking is like this example from the design repo, then that would be correct:
# Manually build a standalone binary with nucleus embedded.
cat /usr/local/bin/nucleus app.zip > app
chmod +x app
./app args...
also, would it be possible to have multiple files or zips that each bootstrap a layer?
I have literally no idea, maybe @creationix knows
I remembered @creationix describing how luvit worked, and structure of zip files make this easy: https://en.wikipedia.org/wiki/Zip_(file_format)#Structure
It seems like a neat idea, but I can just imagine needing to have multiple layers of bootstrapping.
hmm, I guess you can jump to the directory, and that tells you the length of the file, and then you can just work backwards. you could apply this same idea to a file, by just appending a length as the last line..
cat $(which nucleus) app.js $(stat -c %s log.js) > nukeapp
okay that might need a empty line at the end of app.js
but then you could read back, and then execute forward, and nukeapp could even be extended this way, it would be composable.
There is no explicit framing in the design outside of the zip format itself.
Is it really that hard to make a zip file containing a single file? The nucleus CLI tool should make the zip for you even. I guess we just need a mode where you pass it a file instead of a directory and it creates a zip containing only that file as main.js. I would think that would work well as long as your single file doesn't expect ant other files to be present in the bundle.
@creationix sure that would work!
How do I run a single javascript file? with browserify it's really easy to take a lot of javascript and run it on any javascript platform, however nucleus seems to insist on running directories that is constraining as often I just want to run, say, a test script.
I did get this to work, https://github.com/dominictarr/nucleus-run
and I understand that it is ment to be possible to create a new nucleus command by just appending a zip of the code? I tried this but was not able to find any documentation.
but that didn't seem to work.
bundling the zip file is a pretty great idea, but a single js file is still the lowest common denomenator of javascript, so it seems reasonable that works out of the box.