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

Tell bundler that the generated package has side effects. Closes #972. #1208

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ impl CrateData {
module: data.main,
homepage: data.homepage,
types: data.dts_file,
side_effects: false,
side_effects: true,
keywords: data.keywords,
dependencies,
})
Expand Down Expand Up @@ -774,7 +774,7 @@ impl CrateData {
module: data.main,
homepage: data.homepage,
types: data.dts_file,
side_effects: false,
side_effects: true,
keywords: data.keywords,
dependencies,
})
Expand Down
4 changes: 2 additions & 2 deletions tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn it_creates_a_package_json_default_path() {
);
assert_eq!(pkg.module, "js_hello_world.js");
assert_eq!(pkg.types, "js_hello_world.d.ts");
assert_eq!(pkg.side_effects, false);
assert_eq!(pkg.side_effects, true);

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> = [
Expand Down Expand Up @@ -255,7 +255,7 @@ fn it_creates_a_package_json_with_correct_files_when_out_name_is_provided() {
);
assert_eq!(pkg.module, "index.js");
assert_eq!(pkg.types, "index.d.ts");
assert_eq!(pkg.side_effects, false);
assert_eq!(pkg.side_effects, true);

let actual_files: HashSet<String> = pkg.files.into_iter().collect();
let expected_files: HashSet<String> =
Expand Down
6 changes: 5 additions & 1 deletion tests/all/utils/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct NpmPackage {
pub browser: String,
#[serde(default = "default_none")]
pub types: String,
#[serde(default = "default_false", rename = "sideEffects")]
#[serde(default = "default_true", rename = "sideEffects")]
pub side_effects: bool,
pub homepage: Option<String>,
pub keywords: Option<Vec<String>>,
Expand All @@ -36,6 +36,10 @@ fn default_false() -> bool {
false
}

fn default_true() -> bool {
true
}

#[derive(Deserialize)]
pub struct Repository {
#[serde(rename = "type")]
Expand Down