swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
31.02k stars 1.22k forks source link

Error: Cannot find module '@bootstrap' #7578

Closed ibrahim-azez closed 1 year ago

ibrahim-azez commented 1 year ago

Describe the bug

I am using nestjs version 10 and I've added swc to my project. I've tried to run it then it gave this error below. I've added the paths and the proper configs to .swcrc but did not work as expected. I think SWC can not understand barrel files

Input code

yarn start
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.
>  SWC  Running...
Successfully compiled: 282 files with swc (487.28ms)
Error: Cannot find module '@bootstrap'
Require stack:
- C:\Users\cotlin\Desktop\backend\dist\main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Function.Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (C:\Users\remy\Desktop\service\dist\main.js:7:20)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

Config

{
  "$schema": "https://json.schemastore.org/swcrc",
  "sourceMaps": true,
  "jsc": {
    "target": "es2017",
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": true
    },
    "baseUrl": "./",
    "paths": {
      "src/*": ["src/*"],
      "@bootstrap": ["src/bootstrap/index"],
      "@common": ["src/common/index/index"],
      "@modules": ["src/modules/index"],
      "@generated": ["src/generated/index"]
    }
  },
  "minify": false
}

Playground link

No response

Expected behavior

Run the project without any issues.

Actual behavior

Throwing an error complaining about module does not exist.

Version

1.3.66

Additional context

"dependencies": { ... "@nestjs/common": "10.0.2", "@nestjs/core": "10.0.2", ... } "devDependencies": { ... "@nestjs/cli": "10.0.3", "@nestjs/schematics": "10.0.1", "@nestjs/testing": "10.0.2", "@swc/cli": "0.1.62", "@swc/core": "1.3.66", ... }

dawid-dahl-umain commented 1 year ago

I am facing the same issue. Before updating to Nest 10 and swc everything worked, I used the tsconfig-paths package to resolve absolute paths.

kdy1 commented 1 year ago

Closing as not actionable

ibrahim-azez commented 1 year ago

I am facing the same issue. Before updating to Nest 10 and swc everything worked, I used the tsconfig-paths package to resolve absolute paths.

could you give me an example?

ibrahim-azez commented 1 year ago

Closing as not actionable

I don't understand ?

kdy1 commented 1 year ago

If this is still an issue, please file a new issue with a minimal reproduction

swc-bot commented 1 year ago

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.