Skip to content

Commit 24cd384

Browse files
authoredDec 23, 2022
fix(cli): Use the --source-maps option (#6708)
1 parent 7fcc978 commit 24cd384

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed
 

‎bindings/swc_cli/src/commands/compile.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rayon::prelude::*;
1313
use relative_path::RelativePath;
1414
use swc_core::{
1515
base::{
16-
config::{Config, ConfigFile, Options},
16+
config::{ConfigFile, Options, SourceMapsConfig},
1717
try_with_handler, Compiler, HandlerOpts, TransformOutput,
1818
},
1919
common::{
@@ -266,28 +266,32 @@ struct InputContext {
266266
#[swc_trace]
267267
impl CompileOptions {
268268
fn build_transform_options(&self, file_path: &Option<&Path>) -> anyhow::Result<Options> {
269-
let base_options = Options::default();
270-
let base_config = Config::default();
271-
272269
let config_file = self.config_file.as_ref().map(|config_file_path| {
273270
ConfigFile::Str(config_file_path.to_string_lossy().to_string())
274271
});
275272

276-
let mut ret = Options {
277-
config: Config { ..base_config },
273+
let mut options = Options {
278274
config_file,
279-
..base_options
275+
..Options::default()
280276
};
281277

282278
if let Some(file_path) = *file_path {
283-
ret.filename = file_path.to_str().unwrap_or_default().to_owned();
279+
options.filename = file_path.to_str().unwrap_or_default().to_owned();
284280
}
285281

286282
if let Some(env_name) = &self.env_name {
287-
ret.env_name = env_name.to_string();
283+
options.env_name = env_name.to_string();
284+
}
285+
286+
if let Some(source_maps) = &self.source_maps {
287+
options.source_maps = Some(match source_maps.as_str() {
288+
"false" => SourceMapsConfig::Bool(false),
289+
"true" => SourceMapsConfig::Bool(true),
290+
value => SourceMapsConfig::Str(value.to_string()),
291+
});
288292
}
289293

290-
Ok(ret)
294+
Ok(options)
291295
}
292296

293297
/// Create canonical list of inputs to be processed across stdin / single

0 commit comments

Comments
 (0)
Please sign in to comment.