swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.72k stars 71 forks source link

@swc-node/register v1.5.6 breaking module aliases transpilation where in v1.5.4 works great #687

Closed g-wozniak closed 1 year ago

g-wozniak commented 1 year ago

Having updated @swc-node/register to v1.5.6 SWC stopped transpiling module aliases where the exact same setup works without issues for v1.5.4.

Structure:

My app.ts:

import {LogCategories} from '@root/properties'
console.log(LogCategories.dummy)

My properties.ts:

export enum LogCategories = {
   dummy = 'dummy'
}

My tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./.build",
    "target": "ES2021",
    "esModuleInterop": true,
    "paths": {
      "@root/*": ["src/*"]
    },
    "moduleResolution":"node"
  },
  "exclude": [
    "node_modules"
  ]
}

My .swcrc:

{
  "test": ".ts$",
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": false,
      "dynamicImport": true
    },
    "target": "es2021"
  },
  "module": {
    "type": "commonjs"
  }
}

My execution command: node --inspect=7777 -r @swc-node/register ./src/app.ts

Error message I am getting in 1.5.6: Error: Cannot find module '@root/properties'

Other dependencies:

Have you encountered similar issue or able to advise what may cause it?

Brooooooklyn commented 1 year ago

Maybe relate with: https://github.com/swc-project/swc/pull/6930

g-wozniak commented 1 year ago

@Brooooooklyn Sorry, forgot to mention, it's Mac OS, WebStorm.