diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-01-13 11:58:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 11:58:00 -0500 |
commit | f12164646ba8327e9e6275b0ab97602f85e9854f (patch) | |
tree | 1668ac008ac455d38d9eacd70dec4ed7f1d542c2 /cli/ast/bundle_hook.rs | |
parent | 5e2d7737f5542c02572aa6585c8a6a78c84ae5ab (diff) |
refactor: move transpiling to deno_ast (#13332)
Diffstat (limited to 'cli/ast/bundle_hook.rs')
-rw-r--r-- | cli/ast/bundle_hook.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/cli/ast/bundle_hook.rs b/cli/ast/bundle_hook.rs deleted file mode 100644 index a2dd658e3..000000000 --- a/cli/ast/bundle_hook.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -use deno_ast::swc::bundler::Hook; -use deno_ast::swc::bundler::ModuleRecord; -use deno_ast::swc::common::Span; -use deno_core::error::AnyError; - -/// This contains the logic for Deno to rewrite the `import.meta` when bundling. -pub struct BundleHook; - -impl Hook for BundleHook { - fn get_import_meta_props( - &self, - span: Span, - module_record: &ModuleRecord, - ) -> Result<Vec<deno_ast::swc::ast::KeyValueProp>, AnyError> { - use deno_ast::swc::ast; - - Ok(vec![ - ast::KeyValueProp { - key: ast::PropName::Ident(ast::Ident::new("url".into(), span)), - value: Box::new(ast::Expr::Lit(ast::Lit::Str(ast::Str { - span, - value: module_record.file_name.to_string().into(), - kind: ast::StrKind::Synthesized, - has_escape: false, - }))), - }, - ast::KeyValueProp { - key: ast::PropName::Ident(ast::Ident::new("main".into(), span)), - value: Box::new(if module_record.is_entry { - ast::Expr::Member(ast::MemberExpr { - span, - obj: ast::ExprOrSuper::Expr(Box::new(ast::Expr::MetaProp( - ast::MetaPropExpr { - meta: ast::Ident::new("import".into(), span), - prop: ast::Ident::new("meta".into(), span), - }, - ))), - prop: Box::new(ast::Expr::Ident(ast::Ident::new( - "main".into(), - span, - ))), - computed: false, - }) - } else { - ast::Expr::Lit(ast::Lit::Bool(ast::Bool { span, value: false })) - }), - }, - ]) - } -} |