mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(bundler): Don't load dynamic imports (#1297)
swc_bundler: - Do not load dynamically imported files.
This commit is contained in:
parent
ba13db54db
commit
bc7ac45d87
@ -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]
|
||||
|
@ -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());
|
||||
// }
|
||||
// _ => {}
|
||||
// },
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ impl Load for Loader {
|
||||
Syntax::Typescript(TsConfig {
|
||||
decorators: true,
|
||||
tsx,
|
||||
dynamic_import: true,
|
||||
..Default::default()
|
||||
}),
|
||||
JscTarget::Es2020,
|
||||
|
3
bundler/tests/fixture/dynamic/input/dep.ts
Normal file
3
bundler/tests/fixture/dynamic/input/dep.ts
Normal file
@ -0,0 +1,3 @@
|
||||
console.log('Foo')
|
||||
|
||||
export const a = 5;
|
3
bundler/tests/fixture/dynamic/input/entry.ts
Normal file
3
bundler/tests/fixture/dynamic/input/entry.ts
Normal file
@ -0,0 +1,3 @@
|
||||
const a = import('./dep')
|
||||
|
||||
console.log(a)
|
2
bundler/tests/fixture/dynamic/output/entry.ts
Normal file
2
bundler/tests/fixture/dynamic/output/entry.ts
Normal file
@ -0,0 +1,2 @@
|
||||
const a = import('./dep');
|
||||
console.log(a);
|
Loading…
Reference in New Issue
Block a user