summaryrefslogtreecommitdiff
path: root/core/extensions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/extensions.rs')
-rw-r--r--core/extensions.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/extensions.rs b/core/extensions.rs
index 16cca924d..e497b8003 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -43,6 +43,7 @@ impl OpDecl {
pub struct Extension {
js_files: Option<Vec<ExtensionFileSource>>,
esm_files: Option<Vec<ExtensionFileSource>>,
+ esm_entry_point: Option<&'static str>,
ops: Option<Vec<OpDecl>>,
opstate_fn: Option<Box<OpStateFn>>,
middleware_fn: Option<Box<OpMiddlewareFn>>,
@@ -100,6 +101,10 @@ impl Extension {
}
}
+ pub fn get_esm_entry_point(&self) -> Option<&'static str> {
+ self.esm_entry_point
+ }
+
/// Called at JsRuntime startup to initialize ops in the isolate.
pub fn init_ops(&mut self) -> Option<Vec<OpDecl>> {
// TODO(@AaronO): maybe make op registration idempotent
@@ -158,6 +163,7 @@ impl Extension {
pub struct ExtensionBuilder {
js: Vec<ExtensionFileSource>,
esm: Vec<ExtensionFileSource>,
+ esm_entry_point: Option<&'static str>,
ops: Vec<OpDecl>,
state: Option<Box<OpStateFn>>,
middleware: Option<Box<OpMiddlewareFn>>,
@@ -197,6 +203,11 @@ impl ExtensionBuilder {
self
}
+ pub fn esm_entry_point(&mut self, entry_point: &'static str) -> &mut Self {
+ self.esm_entry_point = Some(entry_point);
+ self
+ }
+
pub fn ops(&mut self, ops: Vec<OpDecl>) -> &mut Self {
self.ops.extend(ops);
self
@@ -234,6 +245,7 @@ impl ExtensionBuilder {
Extension {
js_files,
esm_files,
+ esm_entry_point: self.esm_entry_point.take(),
ops,
opstate_fn: self.state.take(),
middleware_fn: self.middleware.take(),