-
Notifications
You must be signed in to change notification settings - Fork 10
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
RFC: Enable depending on NPM packages #8
Conversation
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.
Thanks for this RFC, Alex. It provides answers for all of the open questions I had about the last iteration.
I have a few comments below, but these are nitpicks that I think we can largely address in implementation, and which don't need to block this RFC moving forward.
The primary goal of this RFC is to enable *tranparent* and *transitive* | ||
dependencies on NPM. The `#[wasm_bindgen]` macro is the only aspect of a crate's | ||
build which has access to all transitive dependencies, so this is what we'll be | ||
using to slurp up `package.json`. When `#[wasm_bindgen]` with a `module` key is |
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.
Nice insight.
(note that the cwd is set by Cargo to be the directory with the crate's | ||
`Cargo.toml` that is being compiled, or the crate in which `#[wasm_bindgen]` is | ||
written). This `package.json`, if found, will have an absolute path to it | ||
encoded into the custom section that `wasm-bindgen` already emits. |
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.
This dependency on package.json will be opaque to cargo
-- does it make sense to always include the package.json
path (even when it doesn't exist) in the custom section and have the CLI tool handle the missing case? This way incremental builds where a package.json
is included post facto should always work.
I think modifications to package.json would work incrementally either way though, right?
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.
Actually now that I think about it I think we can get rustc/cargo to learn about this dependency via include_str!
. We could probably emit a dummy constant that doesn't end up getting used to force it to get included. That way the proc macro could actually work with the contents rather than just the path (and could put the entire contents in the custom section)
[alternatives]: #rationale-and-alternatives | ||
|
||
When developing this RFC, some guiding values for its design have been | ||
articulated: |
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.
Thank you for summarizing all of this in one place.
I'd like to propose that we enter the Final Comment Period for this RFC. The original RFC has been around for quite some time and has baked for quite awhile, and I'd like to help spur on final discussion for this one before implementing! Disposition: merge @rustwasm/core members to sign off: |
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 think this seems very reasonable for an MVP.
} | ||
``` | ||
|
||
The `package.json` file will initially be a subset of NPM's `package.json`, |
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.
Are there any benefits to this restriction? Especially since we will support other fields in the future.
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 mostly thinking that we want to start out conservative. In the end wasm-bindgen will be producing a "merged" package.json, but that means that we in theory need a merging function for all fields of package.json. For now it's easy enough for us to define how to merge dependencies
, but beyond that I figure we'd want to make explicit decisions about how to merge other fields rather than having something accidentally ad-hoc-ly define how to do it for us
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.
Could we somehow error for transitive crates but not the current crate?
Since the current crate might be published to npm, so it might want things like name
, version
, etc.
But transitive crates aren't intended for publishing to npm, so it's okay to restrict them to dependencies
only.
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's possible I think! My hope though is that only allowing dependencies
is a useful-enough MVP to build on a feature like this in the future. Do you think, though, that we need to allow other fields (in some possible form) in the initial pass to be useful enough though?
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 suspect that at least version
will be needed, since the npm version can be different from the Rust version (e.g. breaking changes in .rs
but not in compiled .wasm
).
Maybe not needed for the MVP though, so I don't think it should block anything. I think this RFC is fine as-is.
ping @ashleygwilliams, have you had a chance to take a look at this and review the proposal for FCP in the past two weeks? |
This commit implements [RFC 8], which enables transitive and transparent dependencies on NPM. The `module` attribute, when seen and not part of a local JS snippet, triggers detection of a `package.json` next to `Cargo.toml`. If found it will cause the `wasm-bindgen` CLI tool to load and parse the `package.json` within each crate and then create a merged `package.json` at the end. [RFC 8]: rustwasm/rfcs#8
I've got a sample implementation of the currently proposed version of the RFC at rustwasm/wasm-bindgen#1305 |
@ashleygwilliams another ping since last week to check the FCP proposal |
@ashleygwilliams just another ping to check out the FCP proposal, would be great if we could get this in the near future! |
@alexcrichton not to speak for Ashley but I noticed from twitter that she's recently moved cross country and changed jobs so I would imagine that she's super busy. Not my intention to speak for her - just letting you know in case you don't already! (@ashleygwilliams I'm really not trying to speak for you and just trying to call out that you might be a bit busy right now so feel free to let me know if I'm totally wrong!!!) |
@chinedufn true! I'm trying to only ping at most once a week though because I want to make sure this doesn't fall off the radar but it also isn't too overwhelming. We currently require a full-team signoff (although that may change in #9), so we're unfortunately stuck leaving out this feature (which I personally feel is very important!) until @ashleygwilliams checks her box. |
Sounds good - hadn't seen #9 - thanks! |
🔔 🔔 🔔 This RFC has entered its final comment period. In seven calendar days, assuming no substantial new arguments or ideas are raised, we will merge it. |
This commit implements [RFC 8], which enables transitive and transparent dependencies on NPM. The `module` attribute, when seen and not part of a local JS snippet, triggers detection of a `package.json` next to `Cargo.toml`. If found it will cause the `wasm-bindgen` CLI tool to load and parse the `package.json` within each crate and then create a merged `package.json` at the end. [RFC 8]: rustwasm/rfcs#8
This commit implements [RFC 8], which enables transitive and transparent dependencies on NPM. The `module` attribute, when seen and not part of a local JS snippet, triggers detection of a `package.json` next to `Cargo.toml`. If found it will cause the `wasm-bindgen` CLI tool to load and parse the `package.json` within each crate and then create a merged `package.json` at the end. [RFC 8]: rustwasm/rfcs#8
@alexcrichton The restriction just broke the builds! As part of the workflow
In addition. Please note, that the dependencies these tools require are "devDependencies" only. I wouldn't want them to be included in the "dependencies" key in the first place. Also important to note here the use of Not entirely sure how I could work around such limitation of "only dependencies". Would appreciate some input. |
On a separate note, this RFC is extremely nuanced because the only reason this issue surfaced in my specific use case was due to the use of |
Sorry for the difficulties you're having @trivigy! I think that unfortunately there's not a great answer today, but brainstorming on how to solve this would be greatly appreciated! |
@alexcrichton I ended up spending the time rewriting everything in terms of |
This broke me too. I use There are lots of tools which use While some of them have alternative ways to configure them, breaking a common practice of using Please remove this restriction and simply ignore unknown keys. |
@DarthGandalf at this point it's probably best to open an issue and/or PR on |
I've given some thought to this, and I agree that we should allow for all keys in |
This proposal is an evolution of #4 which accounts for much of the discussion and makes a concrete proposal.
Rendered