axe-me / vite-plugin-node

Vite plugin to run your node dev server with HMR!
1k stars 48 forks source link

swc tsCompiler does not seem to do anything #46

Closed EdwardKerckhof closed 2 years ago

EdwardKerckhof commented 2 years ago

Steps taken:

  1. Create fresh nestjs application
  2. Add @swc/core to dev dependencies
  3. Create vite.config.ts
  4. Update src/main.ts

Error: image

vite.config.ts image

src/main.ts image

When removing the tsCompiler option I get the same error, but I was under the impression swc would fix reflect-metadata doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.

package.json:

{
  "name": "api",
  "version": "1.0.0",
  "private": true,
  "license": "MIT",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "vite build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "dev": "vite",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "vitest",
    "test:watch": "vitest --watch",
    "test:cov": "vitest --coverage"
  },
  "dependencies": {
    "@nestjs/common": "^8.0.0",
    "@nestjs/core": "^8.0.0",
    "@nestjs/platform-express": "^8.0.0",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0"
  },
  "devDependencies": {
    "@nestjs/cli": "^8.0.0",
    "@nestjs/schematics": "^8.0.0",
    "@nestjs/testing": "^8.0.0",
    "@swc/core": "^1.2.187",
    "@types/express": "^4.17.13",
    "@types/node": "^16.0.0",
    "@types/supertest": "^2.0.11",
    "config": "workspace:*",
    "source-map-support": "^0.5.20",
    "supertest": "^6.1.3",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig": "workspace:*",
    "tsconfig-paths": "^3.10.1",
    "typescript": "^4.3.5",
    "vite": "^2.9.9",
    "vite-plugin-node": "^0.0.19"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "vitest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}
EdwardKerckhof commented 2 years ago

Does not give breaking issues.

sebastiangug commented 2 years ago

@EdwardKerckhof what was the solution for this? currently facing the same problem.

Simolation commented 1 year ago

I have the same issue. How did you resolve it?

SymphonyIceAttack commented 1 year ago

I have sent a PR for this issue which can loging the message about which file update