-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixed deno support. #3990
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
Fixed deno support. #3990
Changes from all commits
b119706
3b17bc9
f9acbb2
3cd7fb1
c707619
5a886bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ wrap("info"); | |
wrap("warn"); | ||
wrap("error"); | ||
|
||
cx = new wasm.WasmBindgenTestContext(); | ||
const cx = new wasm.WasmBindgenTestContext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is an unrelated change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that is required for deno, because deno implementation uses a part of the node implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be good if you explain what you did exactly and why you did it in the OP or comments. (maybe its more obvious for the actual reviewer) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest I don't remember all the details. But by looking at the diffs, I don't think I made any decisions, I tried to follow the original intentions, I just added missing pieces and changed the order of some code to get it working. I agree its hard to understand because the errors surfaced mainly in the generated run.js file, in this case, I was getting a variable missing error. On another the variable was used before it was declared for instance... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the old version didn't work in Deno because it has strict mode enabled by default, which doesn't allow implicitly declaring global variables like that. |
||
handlers.on_console_debug = wasm.__wbgtest_console_debug; | ||
handlers.on_console_log = wasm.__wbgtest_console_log; | ||
handlers.on_console_info = wasm.__wbgtest_console_info; | ||
|
@@ -117,7 +117,10 @@ pub fn execute( | |
#[cfg(unix)] | ||
pub fn exec(cmd: &mut Command) -> Result<(), Error> { | ||
use std::os::unix::prelude::*; | ||
Err(Error::from(cmd.exec()).context("failed to execute `node`")) | ||
Err(Error::from(cmd.exec()).context(format!( | ||
"failed to execute `{}`", | ||
cmd.get_program().to_string_lossy() | ||
))) | ||
} | ||
|
||
#[cfg(windows)] | ||
|
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.
Note for reviewer: this is probably undesirable and at the very least should be limited to Deno.
EDIT: This part of the code already limits it to Deno.
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 didn't broke node or any of the implementations I tested so far, so I wasn't sure if deno was just being more strict than the others.
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'm more worried about exporting anything, even if prefixed by
__
, unless its absolutely necessary. We don't want anyone starting to rely on it unless we intend to and we also don't want to occupy a name unless necessary.Again, there is no real issue here, we should just double-check if this is really necessary.
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 understand your concerns, the generated code requires this variable both on node and on deno
For some reason, without the export it says its not declared on deno, perhaps because deno uses an import:
while node still uses a require:
In practice it was being "exported" for node already, intentionally or not.
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 seems like this was added for Node only in #2012:
wasm-bindgen/crates/cli-support/src/js/mod.rs
Line 278 in ad82651
I don't like it very much, but this isn't making things any worse and removing it from Node is probably out of scope for this PR.
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'm not sure about the best approach either here or in other places, but it seems clear to me that some refactors are in order.
I don't think its just me, but when I'm just trying to fix issues, I try to avoid refactoring as much as possible to make the PR easier to review, but that strategy adds up, and its pretty clear that some refactors are in order.
Although, in this case and some others, I'm not sure the best approach is, as my point of view was quite narrow, focused on specific issues.
But I think opening issues with those changes, so that someone can pick up and provide a PR might be a very good idea.