fix(bundler): Don't load dynamic imports (#1297)

swc_bundler:
 - Do not load dynamically imported files.
This commit is contained in:
강동윤 2020-12-29 00:09:46 +09:00 committed by GitHub
parent ba13db54db
commit bc7ac45d87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 11 deletions

View File

@ -8,7 +8,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.18.1"
version = "0.18.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]

View File

@ -516,16 +516,19 @@ where
return Expr::Call(e);
}
ExprOrSuper::Expr(ref e) => match &**e {
Expr::Ident(Ident {
sym: js_word!("import"),
..
}) => {
self.info.dynamic_imports.push(src.clone());
}
_ => {}
},
// TODO: Uncomment this after implementing an option to make swc_bundler
// includes dynamic imports
//
//
// ExprOrSuper::Expr(ref e) => match &**e {
// Expr::Ident(Ident {
// sym: js_word!("import"),
// ..
// }) => {
// self.info.dynamic_imports.push(src.clone());
// }
// _ => {}
// },
_ => {}
}

View File

@ -76,6 +76,7 @@ impl Load for Loader {
Syntax::Typescript(TsConfig {
decorators: true,
tsx,
dynamic_import: true,
..Default::default()
}),
JscTarget::Es2020,

View File

@ -0,0 +1,3 @@
console.log('Foo')
export const a = 5;

View File

@ -0,0 +1,3 @@
const a = import('./dep')
console.log(a)

View File

@ -0,0 +1,2 @@
const a = import('./dep');
console.log(a);