diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 3bfe9b8ca..3009a5032 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -56,9 +56,17 @@ impl<'a> Context<'a> { let contents = deindent(contents); let contents = contents.trim(); let global = if self.config.nodejs { - format!("module.exports.{} = {};\n", name, contents) + if contents.starts_with("class") { + format!("{1}\nmodule.exports.{0} = {0};\n", name, contents) + } else { + format!("module.exports.{} = {};\n", name, contents) + } } else if self.config.no_modules { - format!("__exports.{} = {}\n", name, contents) + if contents.starts_with("class") { + format!("{1}\n__exports.{0} = {0};\n", name, contents) + } else { + format!("__exports.{} = {};\n", name, contents) + } } else { if contents.starts_with("function") { format!("export function {}{}\n", name, &contents[8..])