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

feat: eszip v2 #40

Merged
merged 23 commits into from
Jan 27, 2022
Merged

feat: eszip v2 #40

merged 23 commits into from
Jan 27, 2022

Conversation

lucacasonato
Copy link
Member

@lucacasonato lucacasonato commented Jan 5, 2022

This PR is a first pass a new iteration of the ESZip format. This PR also changes the
purpose of this crate: it is now exclusively responsible for three things:

  • having a generic Eszip struct that can contain either a V1, or V2 eszip, but exposes a unified module loading API.
  • the parsers and serializers for V1 and V2 eszip formats
  • a function for turning a deno_graph::ModuleGraph into a V2 eszip

The crate is not anymore responsible for module loading itself, and does not anymore contain a module loader.

src/v2.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/v2.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@lucacasonato lucacasonato changed the title first pass at eszip v2 feat: eszip v2 Jan 26, 2022
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! A few nitpicks, but it looks great overall

src/lib.rs Show resolved Hide resolved
src/v2.rs Show resolved Hide resolved
src/v2.rs Show resolved Hide resolved
src/v2.rs Show resolved Hide resolved
src/v2.rs Outdated Show resolved Hide resolved
}
let start = read;
read += $n;
&header_bytes[start..read]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a macro, it could created a fixed array and copy &header_bytes[start..read] into it. This will eliminate the .try_into().unwrap() calls below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do, because read! is invoked with a non const length, for example read!(specifier_len, "specifier"). The length of an array needs to be const.

source_map: EszipV2SourceSlot,
},
Redirect {
target: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using Cow<'a, str> instead?

Copy link
Member Author

@lucacasonato lucacasonato Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would require that the EszipV2Module structs have a lifetime. I don't think that can be achieved easily.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lucacasonato lucacasonato merged commit 4de1eae into main Jan 27, 2022
@lucacasonato lucacasonato deleted the v2_first_pass branch January 27, 2022 12:37
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