-
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
core: introduce extensions #9800
Conversation
core/runtime_modules.rs
Outdated
// ``` | ||
// fn web_modules(args: WebModuleArgs) -> MultiModule { | ||
// MultiModule::new(vec![deno_url::init(), deno_fetch::init(...), ...]) | ||
// } |
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.
Interesting!
Nice! I fully support this effort. If you can get the existing op crates working and the tests pass, I'm rather confident that this will generalize to future needs. I think it will be challenging tho. |
Also rewrite their `::init()` to return JsRuntimeModules
Is less verbose, auto-stringifies op-names to avoid types, ...
Replaces PureJsModule/SimpleModule/SimpleOpModule with a single simpler struct
Don't check bytes sent/received since those are irrelevant and not functional since serde_v8 op-layer rewrite
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.
After more thought I really do think we shouldn't go with the name "extensions". A couple reasons:
- term "op crates" has been used for almost a year, it will be very confusing to transition to "extensions"
- "extension" is not very specific
- these are not "extensions" per se - they do not augment the capabilities of the runtime in any way, but rather allow to group ops inside a single crate
Since not idempotent as of today
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 implementation is both cleaner and more flexible than the original prototype in denoland#9800
This PR implements ideas discussed in #9738, specifically the concept of
JsRuntimeModule
s which makes modular runtime features plug-n-play.Goals
Reduce complexity in
runtime
, make modules self-contained and streamline snapshotting, etc...This should make many parts of
deno
simpler and reusable by third-parties and reduce the implicit complexity in bootstrapping JsRuntimes (when snapshotting or not ...).op_crates
should now be easily usable withoutruntime
Subtasks
JsRuntimeModule
foundations/traits (core/runtime_modules.rs
)JsRuntime
init via modulesop_crates
to be::init() -> JsRuntimeModule
(essentially move code from
runtime/ops/*.rs
toop_crates/*/lib.rs
)include_js_files!()
anddeclare_ops!()
macrosJsRuntime
s & ops to use these new modules)OpMiddleware
OpMetrics
(replacingop_metrics
)OpTracing
middleware (--optrace
flag)UnstableChecker
into an OpMiddlewaredeno_runtime
use JsRuntimeModules ?web_modules()
helper function that inits all Web-API modules (url, fetch, ... essentiallyop_crates
today)--no-snapshot
flag to allow running without snapshots (not sure if useful at all, even when debugging, besides optimize(core): move internal js src off heap #9713)Potential Follow-ups
declare_ops!()
macrosMultiModule
abstraction, thus reverting Extension to a Traitruntime
cli
Worker
andWebWorker
, making them more reusable and composableWorker
andMainWorker
without snapshots, good for debugging and in general snapshots should be optional and viewed as a graceful enhancement (perf boost)