-
Notifications
You must be signed in to change notification settings - Fork 409
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
modules modules modules #312
Conversation
d08522f
to
33eccd3
Compare
eea0c02
to
f06f3cc
Compare
src/manifest/mod.rs
Outdated
None => {} | ||
} | ||
|
||
NpmPackage::ES6Package(ES6Package { |
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.
nitpick: I'd probably name this EsModulePackage
since I think modules didn't come until after es6 and es6 is also actually es2015 or some such... or something like that, 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.
yeah that actually makes a bunch of sense, good catch
7f52a38
to
7f38eb9
Compare
442ee7f
to
195c4e1
Compare
src/manifest/mod.rs
Outdated
if let Some(s) = scope { | ||
self.package.name = format!("@{}/{}", s, self.package.name); | ||
} | ||
let mut files = vec![wasm_file, js_file.clone()]; |
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 clone
. i hate it but i also love not having a ton of lifetime parameters everywhere. i think it's fine but if we hate it let's talk about ways to make it as clean as possible.
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 don't think this single allocation that isn't in a loop (or even within any code that we know to be hot) is a problem. 👍
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.
Looks great! The granular commits made this a pleasure to review :)
src/manifest/mod.rs
Outdated
if let Some(s) = scope { | ||
self.package.name = format!("@{}/{}", s, self.package.name); | ||
} | ||
let mut files = vec![wasm_file, js_file.clone()]; |
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 don't think this single allocation that isn't in a loop (or even within any code that we know to be hot) is a problem. 👍
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 looks good to me besides the one package thing I mentioned below
src/manifest/mod.rs
Outdated
} | ||
|
||
/// Check the data for missing fields and warn | ||
pub fn check_optional_fields( |
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.
Would it be possible to have this be a function in the impl of the package type so that you can just call:
self.check_optional_fields();
rather than feeding it from three separate variables and avoiding possibly calling the function incorrectly?
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.
oh! that's a great idea. can do :)
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 seems like a good first step! After this though I imagine there will be a follow-up to publish an "isomorphic" package that has both a CommonJS entry point as well as es modules for bundlers?
src/manifest/mod.rs
Outdated
Some(format!("{}.d.ts", filename)) | ||
}; | ||
|
||
if let Some(s) = scope { |
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 scope handling logic looks duplicated between this and the above?
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 is all from master but yeah you are right i think, file an issue?
src/manifest/mod.rs
Outdated
let dts_file = if disable_dts == true { | ||
None | ||
} else { | ||
Some(format!("{}.d.ts", filename)) |
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 dts logic looks duplicated with the above?
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 is all from master but yeah you are right i think, file an issue?
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 guess i can try to fix it in this PR, might as well
@alexcrichton correct, this is just to lay the groundwork for #313 |
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.
These changes look good to me!
Great job @ashleygwilliams! |
fixes #309 plus rather large refactor which is in the first few commits
strategy here is to define several struct for types of packages folks will want to make (common js only, es6 only, es6 + commonjs to start), we'll serialize the Cargo.toml into the format based on what the target specified is