-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add 'bundle' subcommand. #2467
Add 'bundle' subcommand. #2467
Conversation
Very nice - I'm able to run it - works great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a section to the manual describing the bundling operation briefly? (Maybe an example?)
.about("Bundle module and dependnecies into single file") | ||
.long_about( | ||
"Fetch, compile, and output to a single file a module and its dependencies. | ||
" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example command here that can be copied and pasted, so people can try it out quickly?
Maybe use a remote URL, like
deno bundle https://deno.land/std/examples/colors.ts colors_bundle.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks!
The real problematic block_on usage is here:
Lines 530 to 533 in 5960e39
// WARNING: Here we use tokio_util::block_on() which starts a new Tokio | |
// runtime for executing the future. This is so we don't inadvernently run | |
// out of threads in the main runtime. | |
Box::new(futures::future::result(tokio_util::block_on(fut))) |
sorry wrong tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
red
This would be a cool feature for later: default output filename
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - this is huge
Yeah, sorry, I went to bed. Thanks for the cleanup and stuff! |
Resolves #2357
This PR adds the subcommand "bundle" to allow the output of a single file JavaScript file which can then be run by Deno without further dependencies.
This works by using the
--outFile
feature of TypeScript along with the AMD module format. AMD modules allow single file concatenation, which is not possible via ES Modules (or CommonJS). This means the bundle is fully valid JavaScript and just needs to be loaded via an AMD loader. There is a minimalistic loader indeno_std
(see: denoland/std#480).So to utilise this in action, you would do something like this:
Which will output the source module to
./oak_server.js
, which can then be run like:I still need to: