Commit 62f996e5 authored by Tim Neutkens's avatar Tim Neutkens

Revert "Fix"

This reverts commit 082e766e.
parent 08066f67
...@@ -13,7 +13,7 @@ use swc_core::{ ...@@ -13,7 +13,7 @@ use swc_core::{
common::{ common::{
collections::AHashMap, collections::AHashMap,
errors::{ColorConfig, Handler}, errors::{ColorConfig, Handler},
BytePos, FileName, Globals, SourceMap, Span, GLOBALS, BytePos, FileName, SourceMap, Span,
}, },
ecma::ast::*, ecma::ast::*,
ecma::atoms::JsWord, ecma::atoms::JsWord,
...@@ -69,11 +69,10 @@ impl Task for BundleTask { ...@@ -69,11 +69,10 @@ impl Task for BundleTask {
.map(JsWord::from) .map(JsWord::from)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let globals = Globals::default();
let comments = self.c.comments().clone(); let comments = self.c.comments().clone();
// //
let mut bundler = Bundler::new( let mut bundler = Bundler::new(
&globals, self.c.globals(),
self.c.cm.clone(), self.c.cm.clone(),
CustomLoader { CustomLoader {
cm: self.c.cm.clone(), cm: self.c.cm.clone(),
...@@ -89,46 +88,46 @@ impl Task for BundleTask { ...@@ -89,46 +88,46 @@ impl Task for BundleTask {
}, },
Box::new(CustomHook), Box::new(CustomHook),
); );
GLOBALS.set(&globals, || {
let mut entries = HashMap::default(); let mut entries = HashMap::default();
let path: PathBuf = option.entry; let path: PathBuf = option.entry;
let path = path let path = path
.canonicalize() .canonicalize()
.context("failed to canonicalize entry file")?; .context("failed to canonicalize entry file")?;
entries.insert("main".to_string(), FileName::Real(path)); entries.insert("main".to_string(), FileName::Real(path));
let outputs = bundler.bundle(entries)?; let outputs = bundler.bundle(entries)?;
let output = outputs.into_iter().next().ok_or_else(|| { let output = outputs
anyhow!("swc_bundler::Bundle::bundle returned empty result") .into_iter()
})?; .next()
.ok_or_else(|| anyhow!("swc_bundler::Bundle::bundle returned empty result"))?;
let source_map_names = {
let mut v = SourceMapIdentCollector { let source_map_names = {
names: Default::default(), let mut v = SourceMapIdentCollector {
}; names: Default::default(),
output.module.visit_with(&mut v);
v.names
}; };
let code = self.c.print( output.module.visit_with(&mut v);
&output.module,
None, v.names
None, };
true,
EsVersion::Es5, let code = self.c.print(
SourceMapsConfig::Bool(true), &output.module,
&source_map_names, None,
None, None,
false, true,
Some(&comments), EsVersion::Es5,
true, SourceMapsConfig::Bool(true),
false, &source_map_names,
)?; None,
false,
Ok(code) Some(&comments),
}) true,
false,
)?;
Ok(code)
}, },
) )
.convert_err() .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