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

transpiled directory structure is flattened and malformed #8358

Closed
Vin-it opened this issue Nov 29, 2023 · 3 comments
Closed

transpiled directory structure is flattened and malformed #8358

Vin-it opened this issue Nov 29, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@Vin-it
Copy link

Vin-it commented Nov 29, 2023

Describe the bug

  • I will reference this previous issue as it points out the issue I am pointing out here as well. Let's say we have this directory structure
➜  backend git:(master) ✗ tree -L 2 .
.
├── generated
│   └── some-api
├── integration-tests
│   └── one.ts
├── package-lock.json
├── package.json
├── src
│   ├── main.ts
│   ├── service-A
│   └── service-B
├── tsconfig-js.json
└── tsconfig.json

7 directories, 6 files
  • I would like the structure to be analogous to the workspace (which is what I get when I run tsc -b)
➜  dist git:(master) ✗ tree -L 2 .
.
├── generated
│   └── some-api
├── integration-tests
│   ├── one.d.ts
│   └── one.js
├── src
│   ├── main.d.ts
│   ├── main.js
│   ├── service-A
│   └── service-B
└── tsconfig.tsbuildinfo

7 directories, 5 files
  • But when I run swc . -d dist in this workspace, I get this structure (flattened one level and merged directories)
➜  dist git:(master) ✗ tree -L 2 .
.
├── main.js
├── main.js.map
├── one.js
├── one.js.map
├── service-A
│   ├── a.js
│   └── a.js.map
├── service-B
│   ├── b.js
│   └── b.js.map
└── some-api
    ├── api.js
    └── api.js.map

4 directories, 10 files
  • I can get the correct result by running swc separately like this
swc src -d dist/src & swc generated -d dist/generated & swc integration-tests -d dist/integration-tests

Input code

No response

Config

{
    "$schema": "https://json.schemastore.org/swcrc",
    "sourceMaps": true,
    "module": {
        "type": "commonjs",
        "strict": true
    },
    "jsc": {
        "target": "es2020",
        "parser": {
            "syntax": "typescript",
            "decorators": true,
            "dynamicImport": true
        },
        "paths": {
            "@generated/*": ["generated/*"],
            "@app/*": ["src/*"]
        },
        "baseUrl": ".",
        "transform": {
            "decoratorMetadata": true
        }
    },
    "exclude": ["node_modules", "./dist"]
}

Playground link (or link to the minimal reproduction)

https://github.com/akwodkiewicz/swc-folders-bug

SWC Info output

Operating System:
    Platform: darwin
    Arch: arm64
    Machine Type: arm64
    Version: Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000
    CPU: (10 cores)
        Models: Apple M1 Pro

Binaries:
    Node: 18.18.2
    npm: 9.8.1
    Yarn: 1.22.19
    pnpm: N/A

Relevant Packages:
    @swc/core: 1.3.99
    @swc/helpers: N/A
    @swc/types: 0.1.5


SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

I would expect

  • swc . -d dist
    to generate the following structure
➜  dist git:(master) ✗ tree -L 2 .
.
├── generated
│   └── some-api
├── integration-tests
│   ├── one.d.ts
│   └── one.js
├── src
│   ├── main.d.ts
│   ├── main.js
│   ├── service-A
│   └── service-B

7 directories, 5 files

Actual behavior

but I get

➜  dist git:(master) ✗ tree -L 2 .
.
├── main.js
├── main.js.map
├── one.js
├── one.js.map
├── service-A
│   ├── a.js
│   └── a.js.map
├── service-B
│   ├── b.js
│   └── b.js.map
└── some-api
    ├── api.js
    └── api.js.map

4 directories, 10 files

Version

cli: 0.1.63, core: 1.3.99

Additional context

No response

@Vin-it Vin-it added the C-bug label Nov 29, 2023
@kdy1 kdy1 added this to the Planned milestone Nov 30, 2023
@kdy1 kdy1 self-assigned this Nov 30, 2023
@kdy1
Copy link
Member

kdy1 commented Jan 21, 2024

"compile:swc:inner:relative" should work, thanks to swc-project/cli@ff87851

@kdy1
Copy link
Member

kdy1 commented Jan 24, 2024

swc/cli@0.2.2 fixes the issue. swc-project/cli@ebf23f7.

See https://github.com/kdy1/repro-swc-8358

@kdy1 kdy1 closed this as completed Jan 24, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.3.106 Jan 24, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 23, 2024

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants