Skip to content

Commit

Permalink
feat(rust): add OutputFormat::Cjs (#358)
Browse files Browse the repository at this point in the history
<!-- Thank you for contributing! -->

### Description

Part of #45.

<!-- Please insert your description here and provide especially info about the "what" this PR is solving -->

### Test Plan

<!-- e.g. is there anything you'd like reviewers to focus on? -->

---
  • Loading branch information
hyf0 authored Nov 22, 2023
1 parent 7387e35 commit 44c6331
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/rolldown/src/bundler/chunk/render_chunk_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ impl Chunk {
});
return Some(MagicString::new(format!("export default {wrap_ref_name}();\n")));
}
OutputFormat::Cjs => {
unreachable!("entry CJS should not be wrapped in `OutputFormat::Cjs`")
}
}
}
}
Expand Down Expand Up @@ -94,6 +97,9 @@ impl Chunk {
OutputFormat::Esm => {
return vec!["default".to_string()];
}
OutputFormat::Cjs => {
unreachable!("entry CJS should not be wrapped in `OutputFormat::Cjs`")
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/rolldown/src/bundler/options/output_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::file_name_template::FileNameTemplate;
#[derive(Debug)]
pub enum OutputFormat {
Esm,
Cjs,
}

#[derive(Derivative)]
Expand Down

0 comments on commit 44c6331

Please sign in to comment.