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: load bytes instead of strings #357

Merged
merged 15 commits into from
Jan 31, 2024
Merged

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jan 12, 2024

This is in preparation for with { "type": "wasm" } and having the ability to get the original bytes.

Closes #152

@dsherret dsherret changed the title feat: store a module's original bytes feat: store original bytes of modules Jan 12, 2024
@dsherret dsherret changed the title feat: store original bytes of modules feat: load bytes instead of strings Jan 31, 2024
@dsherret dsherret marked this pull request as ready for review January 31, 2024 15:00
Esm(EsModule),
// todo(#239): remove this when updating the --json output for 2.0
#[serde(rename = "esm")]
Js(JsModule),
Copy link
Member Author

@dsherret dsherret Jan 31, 2024

Choose a reason for hiding this comment

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

I found it simplifies the downstream code to use Module::Js here and then we can introduce Module::Wasm later. The benefit is that it forces people to handle Wasm modules specifically and also if someone has a JsModule then they don't need to worry about if they can get a string out of it or not.

Couldn't think of a better name because ScriptModule has the connotations that it's not an ES module. Another alternative is JsTsModule

Copy link
Member

Choose a reason for hiding this comment

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

Current name is fine 👍

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.

Looks like the JS implementation got out of sync. Other than that it looks good to me 👍

@dsherret
Copy link
Member Author

Should be good now. I'm going to finish upgrading this PR into the downstream crates, then do a release and upgrade everything. Then I'll circle back and add Wasm imports.

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

src/graph.rs Outdated
Comment on lines 4235 to 4239
#[allow(clippy::result_large_err)]
fn new_source_with_text(
specifier: &ModuleSpecifier,
text: Arc<[u8]>,
) -> Result<Arc<str>, ModuleError> {
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR, but maybe we could box the error to get rid of the lint?

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'll box at least this code for now, but yeah we should box more of these errors.

@dsherret dsherret merged commit 19e2b28 into denoland:main Jan 31, 2024
4 checks passed
@dsherret dsherret deleted the feat_store_bytes branch January 31, 2024 21:58
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.

2 participants