Skip to content

Commit 3ef2ce5

Browse files
authored
feat: eszip 2.3 - support Wasm modules (#204)
1 parent 89bfaac commit 3ef2ce5

14 files changed

+245
-35
lines changed

Cargo.lock

Lines changed: 34 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = ["lib"]
1313
[workspace.dependencies]
1414
deno_graph = { version = "0.86.3", default-features = false }
1515
deno_ast = { version = "0.44.0", features = ["transpiling"] }
16-
import_map = "0.20.0"
16+
import_map = "0.21.0"
1717
serde = "1"
1818

1919
[profile.release]
@@ -57,7 +57,7 @@ indexmap = "2"
5757
serde = { workspace = true }
5858
serde_json = "1"
5959
sha2 = {version = "0.10.1", optional = true}
60-
thiserror = "1.0.30"
60+
thiserror = "2"
6161
url = "2.2.2"
6262
xxhash-rust = { version = "0.8", optional = true }
6363

benches/source_hash_function.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ async fn build_eszip(mb: usize) -> EszipV2 {
179179
graph.valid().unwrap();
180180
EszipV2::from_graph(eszip::FromGraphOptions {
181181
graph,
182+
module_kind_resolver: Default::default(),
182183
parser: analyzer.as_capturing_parser(),
183184
transpile_options: TranspileOptions::default(),
184185
emit_options: EmitOptions::default(),

lib/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ pub async fn build_eszip(
342342
.map_err(|e| js_sys::Error::new(&e.to_string()))?;
343343
let mut eszip = eszip::EszipV2::from_graph(eszip::FromGraphOptions {
344344
graph,
345+
module_kind_resolver: Default::default(),
345346
parser: analyzer.as_capturing_parser(),
346347
transpile_options: Default::default(),
347348
emit_options: Default::default(),

src/examples/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ async fn main() {
7474
let mut eszip = eszip::EszipV2::from_graph(eszip::FromGraphOptions {
7575
graph,
7676
parser: analyzer.as_capturing_parser(),
77+
module_kind_resolver: Default::default(),
7778
transpile_options: TranspileOptions::default(),
7879
emit_options: EmitOptions::default(),
7980
relative_file_base: None,

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22

3+
#![deny(clippy::print_stderr)]
4+
#![deny(clippy::print_stdout)]
5+
#![deny(clippy::unused_async)]
6+
37
mod error;
48
pub mod v1;
59
pub mod v2;
@@ -14,6 +18,7 @@ use futures::io::AsyncReadExt;
1418
use serde::Deserialize;
1519
use serde::Serialize;
1620
use v2::EszipV2Modules;
21+
use v2::EszipVersion;
1722

1823
pub use crate::error::ParseError;
1924
pub use crate::v1::EszipV1;
@@ -47,8 +52,8 @@ impl Eszip {
4752
let mut reader = futures::io::BufReader::new(reader);
4853
let mut magic = [0; 8];
4954
reader.read_exact(&mut magic).await?;
50-
if EszipV2::has_magic(&magic) {
51-
let (eszip, fut) = EszipV2::parse_with_magic(&magic, reader).await?;
55+
if let Some(version) = EszipVersion::from_magic(&magic) {
56+
let (eszip, fut) = EszipV2::parse_with_version(version, reader).await?;
5257
Ok((Eszip::V2(eszip), Box::pin(fut)))
5358
} else {
5459
let mut buffer = Vec::new();
@@ -212,6 +217,7 @@ pub enum ModuleKind {
212217
Json = 1,
213218
Jsonc = 2,
214219
OpaqueData = 3,
220+
Wasm = 4,
215221
}
216222

217223
#[cfg(test)]

src/snapshots/eszip__v2__tests__file_format_roundtrippable.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ expression: bytes
1010
80,
1111
50,
1212
46,
13-
50,
13+
51,
1414
0,
1515
0,
1616
0,

src/snapshots/eszip__v2__tests__npm_empty_snapshot.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ expression: bytes
1010
80,
1111
50,
1212
46,
13-
50,
13+
51,
1414
0,
1515
0,
1616
0,

src/snapshots/eszip__v2__tests__npm_packages.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ expression: bytes
1010
80,
1111
50,
1212
46,
13-
50,
13+
51,
1414
0,
1515
0,
1616
0,

src/snapshots/eszip__v2__tests__opaque_data.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ expression: bytes
1010
80,
1111
50,
1212
46,
13-
50,
13+
51,
1414
0,
1515
0,
1616
0,

0 commit comments

Comments
 (0)