swc-project / swc

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

[Wrong] Don't declare an enum with name `Object` #7994

Closed rohanrajpal closed 12 months ago

rohanrajpal commented 12 months ago

Describe the bug

For the repository: https://github.com/rohanrajpal/nest-swc-monorepo-repro

If we try to install deps and run pnpm dev inside the api folder, I get

nest-swc-monorepo/apps/api on  main [!?] via  v18.12.1 via 💎 v3.0.0 on ☁️  howdyrohan@gmail.com took 4s 
❯ pnpm dev                                                                                                                                                                                                                          (base) 

> nest-swc-test@0.0.1 dev /Users/rohanrajpal/Documents/experiments/nest-swc-monorepo/apps/api
> nest start --watch

>  SWC  Running...
Successfully compiled: 6 files with swc (48.18ms)
Watching for file changes.

/Users/rohanrajpal/Documents/experiments/nest-swc-monorepo/apps/api/dist/models/chargebee-webhook.dto.js:2
Object.defineProperty(exports, "__esModule", {
       ^
TypeError: Cannot read properties of undefined (reading 'defineProperty')
    at Object.<anonymous> (/Users/rohanrajpal/Documents/experiments/nest-swc-monorepo/apps/api/dist/models/chargebee-webhook.dto.js:2:8)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/rohanrajpal/Documents/experiments/nest-swc-monorepo/apps/api/dist/models/index.js:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1213:10)

Input code

No response

Config

{
  "$schema": "https://json.schemastore.org/swcrc",
  "sourceMaps": true,
  "module": {
    "type": "commonjs"
  },
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": true
    },
    "paths": {
      "@/*": ["./*"]
    },
    "baseUrl": "/"
  },
  "minify": false,
  "exclude": [
    "node_modules",
    "test",
    "dist",
    ".spec.ts",
    "extensions",
    "codegen.ts"
  ]
}

Playground link

No response

SWC Info output

No response

Expected behavior

For nestjs to start and serve the application

Actual behavior

Compilation is done but app fails to serve

Version

^1.3.87

Additional context

No response

kdy1 commented 12 months ago

An enum named Object is the problem, which is not a fixable bug of SWC.

https://github.com/rohanrajpal/nest-swc-monorepo-repro/blob/6a3e1ee7120306d1bd1436cab99bcd1fc3f1adac/apps/api/src/models/chargebee-webhook.dto.ts#L104-L107

rohanrajpal commented 12 months ago

An enum named Object is the problem, which is not a fixable bug of SWC.

https://github.com/rohanrajpal/nest-swc-monorepo-repro/blob/6a3e1ee7120306d1bd1436cab99bcd1fc3f1adac/apps/api/src/models/chargebee-webhook.dto.ts#L104-L107

Any way to get a better error message so that i could figure this out myself?

swc-bot commented 11 months 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.