Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broken path in build output #2534

Open
4 of 15 tasks
tigawanna opened this issue Mar 1, 2024 · 4 comments
Open
4 of 15 tasks

broken path in build output #2534

tigawanna opened this issue Mar 1, 2024 · 4 comments

Comments

@tigawanna
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Hey guys am getting this error when trying to import a module into another

// posts module
@Module({
  controllers: [PostsController],
  providers: [PostsService],
  imports: [ColorsModule],
})
export class PostsModule {}

// colors module
@Module({
  controllers: [ColorsController],
  providers: [ColorsService],
  exports: [ColorsService],
})
export class ColorsModule {}

// dist posts mudole.js output

"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "PostsModule", {
    enumerable: true,
    get: function() {
        return PostsModule;
    }
});
const _common = require("@nestjs/common");
const _postsservice = require("./posts.service");
const _postscontroller = require("./posts.controller");
const _colorsmodule = require("/?/C:/Users/denni/Desktop/code/node/nestjs/nestjs-typeorm/src/colors/colors.module");
function _ts_decorate(decorators, target, key, desc) {
....

manually changing

const _colorsmodule = require("/?/C:/Users/denni/Desktop/code/node/nestjs/nestjs-typeorm/src/colors/colors.module")
//to
const _colorsmodule = require("../colors/colors.module")

fixes ths issue , what am i doing wrong?

Minimum reproduction code

https://github.com/tigawanna/nestjs_typeorm/tree/minimal-reproduction

Steps to reproduce

  1. npm ci 2. npm run start:swc

Expected behavior

start up server with no errors

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

10

NestJS version

No response

Packages versions

  "dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "^3.2.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/jwt": "^10.2.0",
    "@nestjs/passport": "^10.0.3",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/swagger": "^7.3.0",
    "@nestjs/typeorm": "^10.0.2",
    "@types/bcrypt": "^5.0.2",
    "bcrypt": "^5.1.1",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "passport": "^0.7.0",
    "passport-local": "^1.0.0",
    "pg": "^8.11.3",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1",
    "sqlite3": "^5.1.7",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/mapped-types": "^2.0.5",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@swc/cli": "^0.3.9",
    "@swc/core": "^1.4.2",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/passport-local": "^1.0.38",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3",
    "unplugin-swc": "^1.4.4",
    "vitest": "^1.3.1"
  },

Node.js version

20

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

with npm run start:dev

image

with npm run start:swc

image

@micalevisk
Copy link
Member

I didn't manage to reproduce your issue on my Ubuntu. Try it out:

git clone git@github.com:tigawanna/nestjs_typeorm.git -b minimal-reproduction
cd nestjs_typeorm/
npm install
npm run start:swc

image

@tigawanna
Copy link
Author

tigawanna commented Mar 1, 2024

works in wsl , looks like a windows issue

Linux output in dtst/posts/post.module,js

const _common = require("@nestjs/common");
const _postsservice = require("./posts.service");
const _postscontroller = require("./posts.controller");
const _colorsmodule = require("../colors/colors.module");

vs
Windows output in dtst/posts/post.module,js

const _common = require("@nestjs/common");
const _postsservice = require("./posts.service");
const _postscontroller = require("./posts.controller");
const _colorsmodule = require("/?/C:/Users/denni/Desktop/code/node/nestjs/minimal/src/colors/colors.module");

manually correcting the path will fix the issue and it only appears when importing external modules (colors into posts)

@micalevisk
Copy link
Member

@tigawanna what if you don't use swc? perhaps that's something we cannot fix on our side

@tigawanna
Copy link
Author

ts-node without swc works fine it's just slow but i get there's not much you can do about an SWC issue

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants