-
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
refactor: internal runtime code TS support #17672
refactor: internal runtime code TS support #17672
Conversation
Ooooh, welcome back! |
d622f7b
to
ebe6bd8
Compare
cli/build.rs
Outdated
esm_files.push(ExtensionFileSource { | ||
specifier: "runtime/js/99_main.js".to_string(), | ||
code: deno_runtime::js::SOURCE_CORE_FOR_99_MAIN_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.
This seems a little crufty - I believe the resulting specifier will be internal:deno_cli/runtime/js/99_main.js
. OTOH it's not a big deal.
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.
i think its fine; no one would import from it, and i doubt errors will come from it
runtime/js.rs
Outdated
path.join("js").join("99_main.js") | ||
} | ||
#[cfg(feature = "snapshot_from_snapshot")] | ||
pub static SOURCE_CORE_FOR_99_MAIN_JS: &str = include_str!("js/99_main.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.
this data seems to only be used in build.rs... why not put it there? it seems the contents of 99_main.js will be in the runtime's memory
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.
It's used in cli/build.rs
and this code lives in runtime/
- there's no way I'm aware of of include_str!()
file from other crate (because you need to pass a string literal to include_str!()
. #[cfg(feature="snapshot_from_snapshot")]
ensures that this source is only embedded when you are snapshotting.
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.
Maybe add a comment about that... seems a bit odd to me.
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.
I will try to clean this up further in #17653 so we don't end up with two copies of this source code in the binary (one in data section, the other in the snapshot).
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 - great to have this!
This is a proof of concept for being able to snapshot TypeScript files.
Currently only a single runtime file is authored in TypeScript - "runtime/js/01_version.ts".
Not needed infrastructure was removed from "core/snapshot_util.rs".