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/ast.rs | |
parent | fdcc78500cc1aff8c87d76abd1692e79977ac9cc (diff) |
fix(cli): inject helpers when transpiling via swc (#8221)
Fixes #8212
Diffstat (limited to 'cli/ast.rs')
-rw-r--r-- | cli/ast.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cli/ast.rs b/cli/ast.rs index bc7265c15..fcce0cc92 100644 --- a/cli/ast.rs +++ b/cli/ast.rs @@ -298,6 +298,7 @@ impl ParsedModule { legacy: true, emit_metadata: options.emit_metadata }), + helpers::inject_helpers(), typescript::strip(), fixer(Some(&self.comments)), ); @@ -413,6 +414,7 @@ pub fn transpile_module( src: &str, media_type: &MediaType, emit_options: &EmitOptions, + globals: &Globals, cm: Rc<SourceMap>, ) -> Result<(Rc<SourceFile>, Module), AnyError> { // TODO(@kitsonk) DRY-up with ::parse() @@ -464,10 +466,11 @@ pub fn transpile_module( legacy: true, emit_metadata: emit_options.emit_metadata }), + helpers::inject_helpers(), typescript::strip(), fixer(Some(&comments)), ); - let module = swc_common::GLOBALS.set(&Globals::new(), || { + let module = swc_common::GLOBALS.set(globals, || { helpers::HELPERS.set(&helpers::Helpers::new(false), || { module.fold_with(&mut passes) }) |