deno icon indicating copy to clipboard operation
deno copied to clipboard

[WIP] feat: embed std/node polyfill into the binary

Open bartlomieju opened this issue 3 years ago • 2 comments

Experiment.

This commits creates a single bundle file from "std/node/module_all.ts" and embeds it in "ext/node/03_std_node.js". This allows us to remove a lot of complexity in CLI related to setting up Node compat layer. Thanks to being snapshotted we can think about enabling this layer on each startup, which could help solve issues like https://github.com/denoland/deno/issues/16088.

Currently the produced bundle weighs at 1.8Mb. Compressed CLI snapshot weighs at 1093982 bytes, while on main it's 585684 bytes.

This should also make is significantly easier to support "node:<module_name>" imports in all code.

bartlomieju avatar Nov 21 '22 20:11 bartlomieju

Is it possible to use a git submodule? Or are you wanting to move the source of truth here?

ry avatar Nov 22 '22 15:11 ry

Is it possible to use a git submodule? Or are you wanting to move the source of truth here?

Neither approach makes sense IMO - we will create a script that bundles std/node into 03_std_node.js, because just pure bundling is not enough, we need to modify bundled file to "export" some things using "window.__bootstrap" namespace.

bartlomieju avatar Nov 22 '22 15:11 bartlomieju

Closing in favor of https://github.com/denoland/deno/pull/17724

bartlomieju avatar Feb 15 '23 00:02 bartlomieju