Repository: swc-project/swc (rust)

Issue:
paths resolution is not working properly
### Describe the bug

`paths` resolution is not working for me.

I've provided paths config as

```json
{
 "paths": {
      "@moduleA/*": ["modules/01-moduleA/*"],
      "@moduleB/*": ["modules/02-moduleB/*"]
    }
}
```

When I'm trying to import using aliases, the compilation fails:

```
import { sum } from "@moduleA/utils";
import { multiply } from "@moduleB/utils";

console.log(sum(1, 2));
console.log(multiply(1, 2));
```

The reference to `@moduleA/utils` is being read as `@moduleA/utilsoduleA/utils`

Error:
```
ERROR in ./src/index.ts 1:0-49
Module not found: Error: Can't resolve '@moduleA/utilsoduleA/utils' in '/Users/vivek.bansal/Projects/vkbansal/swc-test/src'
resolve '@moduleA/utilsoduleA/utils' in '/Users/vivek.bansal/Projects/vkbansal/swc-test/src'
  Parsed request is a module
  using description file: /Users/vivek.bansal/Projects/vkbansal/swc-test/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /Users/vivek.bansal/Projects/vkbansal/swc-test/src/node_modules doesn't exist or is not a directory
      looking for modules in /Users/vivek.bansal/Projects/vkbansal/swc-test/node_modules
        /Users/vivek.bansal/Projects/vkbansal/swc-test/node_modules/@moduleA/utilsoduleA doesn't exist
      /Users/vivek.bansal/Projects/vkbansal/node_modules doesn't exist or is not a directory
      /Users/vivek.bansal/Projects/node_modules doesn't exist or is not a directory
      /Users/vivek.bansal/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory

ERROR in ./src/index.ts 2:0-54
Module not found: Error: Can't resolve '@moduleB/utilsoduleB/utils' in '/Users/vivek.bansal/Projects/vkbansal/swc-test/src'
resolve '@moduleB/utilsoduleB/utils' in '/Users/vivek.bansal/Projects/vkbansal/swc-test/src'
  Parsed request is a module
  using description file: /Users/vivek.bansal/Projects/vkbansal/swc-test/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /Users/vivek.bansal/Projects/vkbansal/swc-test/src/node_modules doesn't exist or is not a directory
      looking for modules in /Users/vivek.bansal/Projects/vkbansal/swc-test/node_modules
        /Users/vivek.bansal/Projects/vkbansal/swc-test/node_modules/@moduleB/utilsoduleB doesn't exist
      /Users/vivek.bansal/Projects/vkbansal/node_modules doesn't exist or is not a directory
      /Users/vivek.bansal/Projects/node_modules doesn't exist or is not a directory
      /Users/vivek.bansal/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory

webpack 5.68.0 compiled with 2 errors and 1 warning in 1372 ms
```

Repro Code: https://github.com/vkbansal/swc-test
Sandbox: https://codesandbox.io/s/github/vkbansal/swc-test/tree/main

### Input code

_No response_

### Config

```json
{
  "jsc": {
    "baseUrl": "./src",
    "target": "es2018",
    "externalHelpers": true,
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": false,
      "dynamicImport": true
    },
    "transform": {
      "react": {
        "runtime": "classic",
        "throwIfNamespace": true
      }
    },
    "paths": {
      "@moduleA/*": ["modules/01-moduleA/*"],
      "@moduleB/*": ["modules/03-moduleB/*"]
    }
  },
  "module": {
    "type": "es6",
    "strict": false,
    "strictMode": true,
    "lazy": false,
    "noInterop": false,
    "ignoreDynamic": true
  }
}
```


### Playground link

https://codesandbox.io/s/github/vkbansal/swc-test/tree/main

### Expected behavior

Project should compile without any errors

### Actual behavior

_No response_

### Version

1.2.136

### Additional context

_No response_

Pull request description:
fix(ecma_module): set strkind after rewrite path
**Description:**
fix paths alias

**Related issue (if exists):**
fix #3447

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9236ef324d..199e2b741a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,9 @@
 - **(css/ast)** Add types for all dimensions (#3477) ([dc939c6](https://github.com/swc-project/swc/commit/dc939c65afa3b3b09101128f5801f532170bdea2))
 
 
+- **(es/parser)** Disallow assignment to optional chaining expressions (#3483) ([26565b1](https://github.com/swc-project/swc/commit/26565b1ae9c0ab93b425c97fc40aaf49576e4b90))
+
+
 - **(plugin)** Support global `HANDLER` in the plugin context (#3478) ([d473a65](https://github.com/swc-project/swc/commit/d473a6597653e59fc485ffb9cb116d23b4b55e70))
 
 ### Miscellaneous Tasks
diff --git a/Cargo.lock b/Cargo.lock
index 284993b44a..2dad600cad 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2612,7 +2612,7 @@ dependencies = [
 
 [[package]]
 name = "swc"
-version = "0.122.3"
+version = "0.122.4"
 dependencies = [
  "ahash",
  "anyhow",
@@ -2990,7 +2990,7 @@ dependencies = [
 
 [[package]]
 name = "swc_ecma_parser"
-version = "0.88.2"
+version = "0.88.3"
 dependencies = [
  "either",
  "enum_kind",
@@ -3284,7 +3284,7 @@ dependencies = [
 
 [[package]]
 name = "swc_ecma_utils"
-version = "0.65.0"
+version = "0.65.1"
 dependencies = [
  "indexmap",
  "once_cell",
@@ -3986,7 +3986,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
 
 [[package]]
 name = "wasm"
-version = "1.2.137"
+version = "1.2.138"
 dependencies = [
  "anyhow",
  "console_error_panic_hook",
diff --git a/crates/swc/Cargo.toml b/crates/swc/Cargo.toml
index 6c7b01a839..0c05d460e1 100644
--- a/crates/swc/Cargo.toml
+++ b/crates/swc/Cargo.toml
@@ -9,7 +9,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
 license = "Apache-2.0"
 name = "swc"
 repository = "https://github.com/swc-project/swc.git"
-version = "0.122.3"
+version = "0.122.4"
 
 [lib]
 name = "swc"
@@ -53,7 +53,7 @@ swc_ecma_ext_transforms = {version = "0.51.0", path = "../swc_ecma_ext_transform
 swc_ecma_lints = {version = "0.14.1", path = "../swc_ecma_lints"}
 swc_ecma_loader = {version = "0.28.0", path = "../swc_ecma_loader", features = ["lru", "node", "tsc"]}
 swc_ecma_minifier = {version = "0.72.3", path = "../swc_ecma_minifier"}
-swc_ecma_parser = {version = "0.88.2", path = "../swc_ecma_parser"}
+swc_ecma_parser = {version = "0.88.3", path = "../swc_ecma_parser"}
 swc_ecma_preset_env = {version = "0.88.0", path = "../swc_ecma_preset_env"}
 swc_ecma_transforms = {version = "0.115.3", path = "../swc_ecma_transforms", features = [
   "compat",
@@ -66,7 +66,7 @@ swc_ecma_transforms = {version = "0.115.3", path = "../swc_ecma_transforms", fea
 swc_ecma_transforms_base = {version = "0.58.2", path = "../swc_ecma_transforms_base"}
 swc_ecma_transforms_compat = {version = "0.69.0", path = "../swc_ecma_transforms_compat"}
 swc_ecma_transforms_optimization = {version = "0.85.0", path = "../swc_ecma_transforms_optimization"}
-swc_ecma_utils = {version = "0.65.0", path = "../swc_ecma_utils"}
+swc_ecma_utils = {version = "0.65.1", path = "../swc_ecma_utils"}
 swc_ecma_visit = {version = "0.51.1", path = "../swc_ecma_visit"}
 swc_ecmascript = {version = "0.112.8", path = "../swc_ecmascript"}
 swc_node_comments = {version = "0.4.0", path = "../swc_node_comments"}
diff --git a/crates/swc_ecma_parser/Cargo.toml b/crates/swc_ecma_parser/Cargo.toml
index 864ef85d64..f46b86b0af 100644
--- a/crates/swc_ecma_parser/Cargo.toml
+++ b/crates/swc_ecma_parser/Cargo.toml
@@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
 license = "Apache-2.0"
 name = "swc_ecma_parser"
 repository = "https://github.com/swc-project/swc.git"
-version = "0.88.2"
+version = "0.88.3"
 
 [package.metadata.docs.rs]
 all-features = true
diff --git a/crates/swc_ecma_transforms_module/src/rewriter.rs b/crates/swc_ecma_transforms_module/src/rewriter.rs
index 466e28741a..37f07299c5 100644
--- a/crates/swc_ecma_transforms_module/src/rewriter.rs
+++ b/crates/swc_ecma_transforms_module/src/rewriter.rs
@@ -53,6 +53,7 @@ where
             .with_context(|| format!("failed to resolve import `{}`", i.src.value))
             .unwrap();
 
+        i.src.kind = Default::default();
         i.src.value = src;
     }
 
@@ -64,6 +65,7 @@ where
                 .with_context(|| format!("failed to resolve import `{}`", src.value))
                 .unwrap();
 
+            src.kind = Default::default();
             src.value = new;
         }
     }
diff --git a/crates/swc_ecma_utils/Cargo.toml b/crates/swc_ecma_utils/Cargo.toml
index 41f84cc17f..383d920a28 100644
--- a/crates/swc_ecma_utils/Cargo.toml
+++ b/crates/swc_ecma_utils/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2021"
 license = "Apache-2.0"
 name = "swc_ecma_utils"
 repository = "https://github.com/swc-project/swc.git"
-version = "0.65.0"
+version = "0.65.1"
 
 [package.metadata.docs.rs]
 all-features = true
@@ -30,4 +30,4 @@ swc_ecma_visit = {version = "0.51.0", path = "../swc_ecma_visit"}
 tracing = "0.1"
 
 [dev-dependencies]
-swc_ecma_parser = {version = "0.88.0", path = "../swc_ecma_parser"}
+swc_ecma_parser = {version = "0.88.3", path = "../swc_ecma_parser"}
diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml
index 642350e4e7..2521e5c8aa 100644
--- a/crates/wasm/Cargo.toml
+++ b/crates/wasm/Cargo.toml
@@ -6,7 +6,7 @@ license = "Apache-2.0"
 name = "wasm"
 publish = false
 repository = "https://github.com/swc-project/swc.git"
-version = "1.2.137"
+version = "1.2.138"
 
 [lib]
 crate-type = ["cdylib"]
diff --git a/package.json b/package.json
index c848f91af5..9a2049cd68 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "@swc/core",
-    "version": "1.2.137",
+    "version": "1.2.138",
     "description": "Super-fast alternative for babel",
     "homepage": "https://swc.rs",
     "main": "./index.js",
@@ -47,9 +47,7 @@
         "registry": "https://registry.npmjs.org/",
         "access": "public"
     },
-    "dependencies": {
-        "ts-node": "^10.4.0"
-    },
+    "dependencies": {},
     "optionalDependencies": {},
     "types": "./index.d.ts",
     "scripts": {
@@ -100,6 +98,7 @@
         "source-map-support": "^0.5.19",
         "sourcemap-validator": "^2.1.0",
         "terser": "^5.7.1",
+        "ts-node": "^10.5.0",
         "typescript": "^4.5.2"
     },
     "funding": {
diff --git a/yarn.lock b/yarn.lock
index 68a6d8d75d..e0f1d9034d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4343,10 +4343,10 @@ tr46@^2.1.0:
   dependencies:
     punycode "^2.1.1"
 
-ts-node@^10.4.0:
-  version "10.4.0"
-  resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
-  integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==
+ts-node@^10.5.0:
+  version "10.5.0"
+  resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.5.0.tgz#618bef5854c1fbbedf5e31465cbb224a1d524ef9"
+  integrity sha512-6kEJKwVxAJ35W4akuiysfKwKmjkbYxwQMTBaAxo9KKAx/Yd26mPUyhGz3ji+EsJoAgrLqVsYHNuuYwQe22lbtw==
   dependencies:
     "@cspotcode/source-map-support" "0.7.0"
     "@tsconfig/node10" "^1.0.7"
@@ -4359,6 +4359,7 @@ ts-node@^10.4.0:
     create-require "^1.1.0"
     diff "^4.0.1"
     make-error "^1.1.1"
+    v8-compile-cache-lib "^3.0.0"
     yn "3.1.1"
 
 type-check@~0.3.2:
@@ -4430,6 +4431,11 @@ universalify@^2.0.0:
   resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
   integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
 
+v8-compile-cache-lib@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
+  integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==
+
 v8-to-istanbul@^8.0.0:
   version "8.0.0"
   resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz#4229f2a99e367f3f018fa1d5c2b8ec684667c69c"


Test patch:
diff --git a/crates/swc/tests/fixture/paths/ext/001/output/index.js b/crates/swc/tests/fixture/paths/ext/001/output/index.js
index bd99756023..9bf47ca7f4 100644
--- a/crates/swc/tests/fixture/paths/ext/001/output/index.js
+++ b/crates/swc/tests/fixture/paths/ext/001/output/index.js
@@ -1,2 +1,2 @@
-import styles from './styles/global.css';
+import styles from "./styles/global.css";
 console.log(styles);
diff --git a/crates/swc/tests/fixture/paths/ext/002/output/index.js b/crates/swc/tests/fixture/paths/ext/002/output/index.js
index 28f2a9db0c..507538549e 100644
--- a/crates/swc/tests/fixture/paths/ext/002/output/index.js
+++ b/crates/swc/tests/fixture/paths/ext/002/output/index.js
@@ -1,2 +1,2 @@
-import styles from './foo.ts/index';
+import styles from "./foo.ts/index";
 console.log(styles);
diff --git a/crates/swc/tests/fixture/paths/issue-3447/input/.swcrc b/crates/swc/tests/fixture/paths/issue-3447/input/.swcrc
new file mode 100644
index 0000000000..dc884172fc
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/input/.swcrc
@@ -0,0 +1,31 @@
+{
+  "jsc": {
+    "baseUrl": "./src",
+    "target": "es2018",
+    "externalHelpers": true,
+    "parser": {
+      "syntax": "typescript",
+      "tsx": false,
+      "decorators": false,
+      "dynamicImport": true
+    },
+    "transform": {
+      "react": {
+        "runtime": "classic",
+        "throwIfNamespace": true
+      }
+    },
+    "paths": {
+      "@moduleA/*": ["modules/01-moduleA/*"],
+      "@moduleB/*": ["modules/03-moduleB/*"]
+    }
+  },
+  "module": {
+    "type": "es6",
+    "strict": false,
+    "strictMode": true,
+    "lazy": false,
+    "noInterop": false,
+    "ignoreDynamic": true
+  }
+}
diff --git a/crates/swc/tests/fixture/paths/issue-3447/input/src/index.ts b/crates/swc/tests/fixture/paths/issue-3447/input/src/index.ts
new file mode 100644
index 0000000000..a5b75f317b
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/input/src/index.ts
@@ -0,0 +1,4 @@
+import { sum } from "@moduleA/utils";
+export { multiply } from "@moduleB/utils";
+
+console.log(sum(1, 2));
diff --git a/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/01-moduleA/utils.ts b/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/01-moduleA/utils.ts
new file mode 100644
index 0000000000..7372ed029d
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/01-moduleA/utils.ts
@@ -0,0 +1,3 @@
+export function sum(a: number, b: number): number {
+  return a + b;
+}
diff --git a/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/02-moduleB/utils.ts b/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/02-moduleB/utils.ts
new file mode 100644
index 0000000000..14289fe2e8
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/input/src/modules/02-moduleB/utils.ts
@@ -0,0 +1,3 @@
+export function multiply(a: number, b: number): number {
+  return a * b;
+}
diff --git a/crates/swc/tests/fixture/paths/issue-3447/output/src/index.ts b/crates/swc/tests/fixture/paths/issue-3447/output/src/index.ts
new file mode 100644
index 0000000000..15e2d82f64
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/output/src/index.ts
@@ -0,0 +1,3 @@
+import { sum } from "./modules/01-moduleA/utils";
+export { multiply } from "./modules/03-moduleB/utils";
+console.log(sum(1, 2));
diff --git a/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/01-moduleA/utils.ts b/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/01-moduleA/utils.ts
new file mode 100644
index 0000000000..41e8b3d659
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/01-moduleA/utils.ts
@@ -0,0 +1,3 @@
+export function sum(a, b) {
+    return a + b;
+}
diff --git a/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/02-moduleB/utils.ts b/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/02-moduleB/utils.ts
new file mode 100644
index 0000000000..9f4b8a3876
--- /dev/null
+++ b/crates/swc/tests/fixture/paths/issue-3447/output/src/modules/02-moduleB/utils.ts
@@ -0,0 +1,3 @@
+export function multiply(a, b) {
+    return a * b;
+}