From cead404a537658ee688922aa087abd61bd1681fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 25 Oct 2021 01:25:59 +0900 Subject: [PATCH] fix(bundler): Fix bundler (#2510) swc_bundler: - Consider usage in named export specifier while analyzing imports. --- Cargo.lock | 2 +- bundler/Cargo.toml | 2 +- bundler/src/bundler/import/mod.rs | 2 ++ bundler/tests/deno-exec/deno-11575/case1/input/entry.ts | 2 ++ bundler/tests/deno-exec/deno-11575/case1/input/temp2.ts | 3 +++ bundler/tests/deno-exec/deno-11575/case1/input/temp3.ts | 3 +++ 6 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 bundler/tests/deno-exec/deno-11575/case1/input/entry.ts create mode 100644 bundler/tests/deno-exec/deno-11575/case1/input/temp2.ts create mode 100644 bundler/tests/deno-exec/deno-11575/case1/input/temp3.ts diff --git a/Cargo.lock b/Cargo.lock index 91f0b80949d..5318f53176b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2431,7 +2431,7 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.77.0" +version = "0.77.1" dependencies = [ "ahash", "anyhow", diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index bb52736551a..2717b271083 100644 --- a/bundler/Cargo.toml +++ b/bundler/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"] license = "Apache-2.0/MIT" name = "swc_bundler" repository = "https://github.com/swc-project/swc.git" -version = "0.77.0" +version = "0.77.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] diff --git a/bundler/src/bundler/import/mod.rs b/bundler/src/bundler/import/mod.rs index 603cb053c1e..87d97cd82bb 100644 --- a/bundler/src/bundler/import/mod.rs +++ b/bundler/src/bundler/import/mod.rs @@ -557,6 +557,8 @@ where } fn visit_mut_export_named_specifier(&mut self, s: &mut ExportNamedSpecifier) { + self.add_forced_ns_for(s.orig.to_id()); + match &s.exported { Some(exported) => { debug_assert_eq!( diff --git a/bundler/tests/deno-exec/deno-11575/case1/input/entry.ts b/bundler/tests/deno-exec/deno-11575/case1/input/entry.ts new file mode 100644 index 00000000000..41c67c6e027 --- /dev/null +++ b/bundler/tests/deno-exec/deno-11575/case1/input/entry.ts @@ -0,0 +1,2 @@ +import { foo } from "./temp2.ts"; +foo.hello(1); \ No newline at end of file diff --git a/bundler/tests/deno-exec/deno-11575/case1/input/temp2.ts b/bundler/tests/deno-exec/deno-11575/case1/input/temp2.ts new file mode 100644 index 00000000000..a5b0ad6edfd --- /dev/null +++ b/bundler/tests/deno-exec/deno-11575/case1/input/temp2.ts @@ -0,0 +1,3 @@ +import * as foo from "./temp3.ts"; +export { foo }; +foo.hello(2); diff --git a/bundler/tests/deno-exec/deno-11575/case1/input/temp3.ts b/bundler/tests/deno-exec/deno-11575/case1/input/temp3.ts new file mode 100644 index 00000000000..7ad21a6216e --- /dev/null +++ b/bundler/tests/deno-exec/deno-11575/case1/input/temp3.ts @@ -0,0 +1,3 @@ +export function hello(n) { + console.log("Hello", n); +} \ No newline at end of file