mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 13:38:33 +03:00
Extract resolver pass (#344)
This commit is contained in:
parent
8674a1dae9
commit
5114dc9e95
@ -1,7 +1,8 @@
|
||||
use super::*;
|
||||
use crate::{
|
||||
compat::es2015::{arrow, block_scoping, resolver, spread},
|
||||
compat::es2015::{arrow, block_scoping, spread},
|
||||
react::jsx,
|
||||
resolver,
|
||||
};
|
||||
use swc_ecma_parser::{EsConfig, Syntax};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::compat::es2015::{block_scoping, resolver};
|
||||
use crate::{compat::es2015::block_scoping, resolver};
|
||||
|
||||
fn tr() -> impl Fold<Module> {
|
||||
chain!(resolver(), function_name(), block_scoping())
|
||||
|
@ -2,9 +2,8 @@ pub use self::{
|
||||
arrow::arrow, block_scoped_fn::BlockScopedFns, block_scoping::block_scoping, classes::Classes,
|
||||
computed_props::computed_properties, destructuring::destructuring,
|
||||
duplicate_keys::duplicate_keys, for_of::for_of, function_name::function_name,
|
||||
instanceof::InstanceOf, parameters::parameters, resolver::resolver,
|
||||
shorthand_property::Shorthand, spread::spread, sticky_regex::StickyRegex,
|
||||
template_literal::TemplateLiteral, typeof_symbol::TypeOfSymbol,
|
||||
instanceof::InstanceOf, parameters::parameters, shorthand_property::Shorthand, spread::spread,
|
||||
sticky_regex::StickyRegex, template_literal::TemplateLiteral, typeof_symbol::TypeOfSymbol,
|
||||
};
|
||||
use crate::pass::Pass;
|
||||
use ast::{Expr, Module, Stmt};
|
||||
@ -20,7 +19,6 @@ mod for_of;
|
||||
mod function_name;
|
||||
mod instanceof;
|
||||
mod parameters;
|
||||
mod resolver;
|
||||
mod shorthand_property;
|
||||
mod spread;
|
||||
mod sticky_regex;
|
||||
@ -49,7 +47,6 @@ pub fn es2015() -> impl Pass {
|
||||
chain_at!(
|
||||
Module,
|
||||
BlockScopedFns,
|
||||
resolver(),
|
||||
Classes,
|
||||
spread(),
|
||||
stmts(),
|
||||
@ -64,6 +61,7 @@ pub fn es2015() -> impl Pass {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::resolver;
|
||||
|
||||
test!(
|
||||
::swc_ecma_parser::Syntax::default(),
|
||||
|
@ -1,9 +1,9 @@
|
||||
use super::*;
|
||||
use crate::compat::es2015::Classes;
|
||||
use crate::{compat::es2015::Classes, resolver};
|
||||
|
||||
fn tr() -> impl Fold<Module> {
|
||||
chain!(
|
||||
crate::compat::es2015::resolver(),
|
||||
resolver(),
|
||||
Params,
|
||||
crate::compat::es2015::destructuring(),
|
||||
crate::compat::es2015::block_scoping(),
|
||||
|
@ -42,7 +42,7 @@ extern crate unicode_xid;
|
||||
|
||||
pub use self::{
|
||||
const_modules::const_modules, fixer::fixer, hygiene::hygiene, inline_globals::InlineGlobals,
|
||||
simplify::simplifier,
|
||||
resolver::resolver, simplify::simplifier,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@ -64,6 +64,7 @@ pub mod modules;
|
||||
pub mod pass;
|
||||
pub mod proposals;
|
||||
pub mod react;
|
||||
mod resolver;
|
||||
pub mod scope;
|
||||
mod simplify;
|
||||
pub mod typescript;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{super::util, amd, Config};
|
||||
use crate::compat::es2015::resolver;
|
||||
use crate::resolver;
|
||||
use ast::Module;
|
||||
use swc_common::Fold;
|
||||
use swc_ecma_parser::Syntax;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::{super::util::Lazy, common_js, Config};
|
||||
use crate::compat::es2015::resolver;
|
||||
use crate::resolver;
|
||||
use ast::*;
|
||||
use swc_common::Fold;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::compat::es2015::resolver;
|
||||
use crate::resolver;
|
||||
|
||||
fn syntax() -> ::swc_ecma_parser::Syntax {
|
||||
Default::default()
|
||||
|
@ -1,7 +1,10 @@
|
||||
use super::*;
|
||||
use crate::compat::{
|
||||
es2015::{block_scoping, function_name, resolver, Classes},
|
||||
es3::ReservedWord,
|
||||
use crate::{
|
||||
compat::{
|
||||
es2015::{block_scoping, es2015, function_name, Classes},
|
||||
es3::ReservedWord,
|
||||
},
|
||||
resolver,
|
||||
};
|
||||
use swc_ecma_parser::{EsConfig, Syntax};
|
||||
|
||||
@ -2777,3 +2780,26 @@ class Foo{
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
syntax(),
|
||||
|_| chain!(resolver(), class_properties(), Classes),
|
||||
issue_342,
|
||||
"class Foo {
|
||||
constructor(bar) {
|
||||
this._bar = bar;
|
||||
}
|
||||
|
||||
qux = {
|
||||
frob: (bar) => {},
|
||||
};
|
||||
}",
|
||||
"let Foo = function Foo(bar) {
|
||||
_classCallCheck(this, Foo);
|
||||
_defineProperty(this, 'qux', {
|
||||
frob: (bar)=>{
|
||||
}
|
||||
});
|
||||
this._bar = bar;
|
||||
};"
|
||||
);
|
||||
|
@ -1,4 +1,7 @@
|
||||
use crate::scope::{IdentType, ScopeKind};
|
||||
use crate::{
|
||||
pass::Pass,
|
||||
scope::{IdentType, ScopeKind},
|
||||
};
|
||||
use ast::*;
|
||||
use fxhash::FxHashSet;
|
||||
use swc_atoms::JsWord;
|
||||
@ -9,7 +12,7 @@ mod tests;
|
||||
|
||||
const LOG: bool = false;
|
||||
|
||||
pub fn resolver() -> Resolver<'static> {
|
||||
pub fn resolver() -> impl Pass + 'static {
|
||||
Resolver::new(
|
||||
Mark::fresh(Mark::root()),
|
||||
Scope::new(ScopeKind::Fn, None),
|
Loading…
Reference in New Issue
Block a user