Skip to content

swc-compile function deepMerge didn't handle array type properly #2160

@powerfulyang

Description

@powerfulyang

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

If I delacre paths in .swcrc and tsconfig.json at the same time, the deepMerge function in https://github.com/nestjs/nest-cli/blob/1b9ab2641a2e46427bb5e54b5f0f6feda4a65276/lib/compiler/swc/swc-compiler.ts#L205C13-L205C13 will convert source code below:

{
    "paths": [
          "@/*": ["src/*"]
    ]
}

to

{
    "paths": {
      "@/*": {
        "0": "src/*"
      }
    }

}

Due to the above issue, @swc/cli fails to start with an error 'invalid type: map, expected a sequence at line 1 column 560'.

Minimum reproduction code

https://github.com/powerfulyang/api.powerfulyang.com

Steps to reproduce

  1. pnpm i
  2. pnpm run build

Expected behavior

build successfully.

Package version

10.1.7

NestJS version

10.0.5

Node.js version

18.16.1

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

This BUG fisrt appear in [@nestjs/cli@10.0.4](feat: auto-populate tsc paths in swc config)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions