Commit 082e766e authored by Donny/강동윤's avatar Donny/강동윤

Fix

parent c3db1023
......@@ -13,7 +13,7 @@ use swc_core::{
common::{
collections::AHashMap,
errors::{ColorConfig, Handler},
BytePos, FileName, SourceMap, Span,
BytePos, FileName, Globals, SourceMap, Span, GLOBALS,
},
ecma::ast::*,
ecma::atoms::JsWord,
......@@ -69,10 +69,11 @@ impl Task for BundleTask {
.map(JsWord::from)
.collect::<Vec<_>>();
let globals = Globals::default();
let comments = self.c.comments().clone();
//
let mut bundler = Bundler::new(
self.c.globals(),
&globals,
self.c.cm.clone(),
CustomLoader {
cm: self.c.cm.clone(),
......@@ -88,7 +89,7 @@ impl Task for BundleTask {
},
Box::new(CustomHook),
);
GLOBALS.set(&globals, || {
let mut entries = HashMap::default();
let path: PathBuf = option.entry;
let path = path
......@@ -97,10 +98,9 @@ impl Task for BundleTask {
entries.insert("main".to_string(), FileName::Real(path));
let outputs = bundler.bundle(entries)?;
let output = outputs
.into_iter()
.next()
.ok_or_else(|| anyhow!("swc_bundler::Bundle::bundle returned empty result"))?;
let output = outputs.into_iter().next().ok_or_else(|| {
anyhow!("swc_bundler::Bundle::bundle returned empty result")
})?;
let source_map_names = {
let mut v = SourceMapIdentCollector {
......@@ -128,6 +128,7 @@ impl Task for BundleTask {
)?;
Ok(code)
})
},
)
.convert_err()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment