Closed siamahnaf closed 1 year ago
Looks like your repository is private
I can solve existing problem. But I am facing another issue. I already plaace a question on discussion into swc. Can you please see the question if you can please.
Yes, I can solve it now. But I am seeing import issue. Could you please help on that?
I already ask a question on swc GitHub discussion. Here is link-https://github.com/swc-project/swc/discussions/7577
@siamahnaf for that one, see #11863
I already see this issues. But I can't figure out?
my folder structure is-
in src folder I have structure like-
src > student > model > student.entity
src > user > model > user.entity
I import user.entity into student.entity like -
import { User } from "@/user/model/user.entity";
I am getting an error like-
I create a .swcrc
file like-
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"baseUrl": "./"
}
}
and my tsconfig.json
-
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"paths": {
"@/*": [
"./src/*"
]
},
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
}
}
Where I am wrong?
In @nestjs/cli@10.0.3
SWC paths & baseUrl had to be specified manually in the .swcrc file.
In @nestjs/cli@10.0.4
paths & baseUrl will be auto-populated from the tsconfig.json
Hello, @kamilmysliwiec
I update @nestjs/cli
to version 10.0.4
. But I am still getting an error.
here is my tsconfig-
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
},
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
}
here is my nest-cli.json-
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"builder": "swc",
"typeCheck": true
}
}
I do not create any .swcrc
as you say it will be automatically!
Here is my project link-https://github.com/siamahnaf/swc-error
Here is the error-
I am on the windows
Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).
I already provide my git repository in my last comment!
I can't reproduce your issue on my machine
But in my environment I am still seeing the error.
I am trying from a windows pc
Your environment?
This is most likely an swc issue and not related to NestJS directly.
@kamilmysliwiec correect meif I'm wrong here, but Nest doesn't do anything special to the config or resolution when using SWC, we just pass it directly to swc for transpilation, unlike with tsc how we hook into tsconfig-paths, correct?
i try it but not work https://stackblitz.com/edit/nestjs-typescript-starter-xdrtdr
SWC won't work on web containers (stackblitz/codesandbox), just FYI.
@kamilmysliwiec correect meif I'm wrong here, but Nest doesn't do anything special to the config or resolution when using SWC, we just pass it directly to swc for transpilation, unlike with tsc how we hook into tsconfig-paths, correct?
In the latest version of @nestjs/cli
, we copy the paths
and baseUrl
configuration values from tsconfig.json
to .swcrc
, but other than that yeah, no changes/hooks
This is most likely an swc issue and not related to NestJS directly.
Your highlighted issues all are closed as solve. But there is no proper solution. SWC said that they buy a windows pc and try to reproduce the issue. They don't find any issue, that's why they close the issue. But with nestjs we facing the same issue.
It's a problem with swc on Windows. In unix environments or works as expected. If I had a Windows name I would try to figure out what swc configuration to change to get it to work
Okay, thank you. Should I create a issue on SWC?
I just double-checked and it seems to be working as expected (windows)
@siamahnaf can you try to reproduce this issue with swc cli directly?
@kamilmysliwiec when i override path in .swcrc, build not work ERR
Just to chime in on the discussion, I'm facing a similar issue with my project. When I turn off SWC, the module aliases seem to work perfectly, but the moment I switch it back on, everything falls apart. Here's my setup:
nest-cli.json:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"builder": "swc",
"deleteOutDir": true,
"typeCheck": true
}
}
tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"module": "commonjs",
"moduleResolution": "Node",
"noFallthroughCasesInSwitch": false,
"noImplicitAny": false,
"outDir": "./dist",
"paths": {
"@/*": ["src/*"]
},
"removeComments": true,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictBindCallApply": false,
"strictNullChecks": false,
"target": "ES2017"
}
}
Running start:dev
, I get the following error:
⠋ TSC Initializing type checker...Debugger attached. Error: Cannot find module '@/profile/profile.module'
Which originates from this line in the compiled JS:
const _profilemodule = require("@/profile/profile.module");
Disabling SWC and switching to tsc produces the correct path:
const profile_module_1 = require("../profile/profile.module");
@onselakin can you please provide a minimum reproduction repository?
Exactly same issue I am facing in my project. But it is working as expected in @kamilmysliwiec environment! I am now totally puzzled what's going on! Someone says this is the issue from swc(From Discord).
@kamilmysliwiec, Should I create a new issue in swc
.
@kamilmysliwiec , I have a question!
I open a file from dist folder, that was already build.
In the picture I can I see that-
const _studententity = require("G:/Codestation21/e-campus/server/src/student/model/student.entity");
SWC compile path like above. Why swc compile in this way where default typescript compiler compile like-
const _studententity = require("../student/model/student.entity");
Why swc give the full path of the file when compilation?
@siamahnaf I just ran into the same issue trying to build my project on Windows. It works on my Mac.
same here
I'm running it on Mac and got the same error, it's a problem on an .entity file too, I'm using MikroORM.
I got the same issue
Please, report this issue in the SWC repository https://github.com/swc-project/swc
Is there an existing issue for this?
Current behavior
I am trying to update my existing project to nestjs 10 for using 20x fast compiler. I set my swc in
nest-cli.json
-And am I am getting a error like
Minimum reproduction code
https://github.com/siamahnaf/test-project
Steps to reproduce
No response
Expected behavior
I don't know what is the problem!
Package
Other package
No response
NestJS version
No response
Packages versions
Node.js version
18.16.0
In which operating systems have you tested?
Other
No response