diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-11-02 22:33:43 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 22:33:43 +1100 |
commit | 272e9b82ebddaa33cbc01cc8b1efd8a36ec3c645 (patch) | |
tree | 33ec0f339eeaa302ca05543a7110019468ac4b07 /cli/module_graph2.rs | |
parent | fdcc78500cc1aff8c87d76abd1692e79977ac9cc (diff) |
fix(cli): inject helpers when transpiling via swc (#8221)
Fixes #8212
Diffstat (limited to 'cli/module_graph2.rs')
-rw-r--r-- | cli/module_graph2.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/module_graph2.rs b/cli/module_graph2.rs index 6ac27906d..f795a7acb 100644 --- a/cli/module_graph2.rs +++ b/cli/module_graph2.rs @@ -120,20 +120,23 @@ impl Error for GraphError {} /// avoid a circular dependency with `ast`. struct BundleLoader<'a> { cm: Rc<swc_common::SourceMap>, - graph: &'a Graph2, emit_options: &'a ast::EmitOptions, + globals: &'a swc_common::Globals, + graph: &'a Graph2, } impl<'a> BundleLoader<'a> { pub fn new( graph: &'a Graph2, emit_options: &'a ast::EmitOptions, + globals: &'a swc_common::Globals, cm: Rc<swc_common::SourceMap>, ) -> Self { BundleLoader { cm, - graph, emit_options, + globals, + graph, } } } @@ -158,6 +161,7 @@ impl swc_bundler::Load for BundleLoader<'_> { &src, &media_type, self.emit_options, + self.globals, self.cm.clone(), ) } else { @@ -965,9 +969,9 @@ impl Graph2 { let cm = Rc::new(swc_common::SourceMap::new( swc_common::FilePathMapping::empty(), )); - let loader = BundleLoader::new(self, emit_options, cm.clone()); - let hook = Box::new(BundleHook); let globals = swc_common::Globals::new(); + let loader = BundleLoader::new(self, emit_options, &globals, cm.clone()); + let hook = Box::new(BundleHook); let bundler = swc_bundler::Bundler::new( &globals, cm.clone(), |