Skip to content
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

Merged
merged 38 commits into from
Feb 8, 2023

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Feb 6, 2023

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".

@aapoalas
Copy link
Collaborator

aapoalas commented Feb 6, 2023

Ooooh, welcome back!

@crowlKats crowlKats force-pushed the es_builtins_traspilation branch from d622f7b to ebe6bd8 Compare February 7, 2023 21:08
@bartlomieju bartlomieju marked this pull request as ready for review February 8, 2023 11:42
cli/build.rs Outdated
Comment on lines 350 to 352
esm_files.push(ExtensionFileSource {
specifier: "runtime/js/99_main.js".to_string(),
code: deno_runtime::js::SOURCE_CORE_FOR_99_MAIN_JS,
Copy link
Member

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.

Copy link
Member Author

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");
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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).

core/runtime.rs Show resolved Hide resolved
Copy link
Member

@ry ry left a 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!

@bartlomieju bartlomieju merged commit 286e5d0 into denoland:main Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants