swc icon indicating copy to clipboard operation
swc copied to clipboard

--out-dir drops the first directory when transpiling nested directories

Open binoche9 opened this issue 1 year ago • 6 comments

Describe the bug

When running swc on a set of files that have subdirectories, swc always drops the first nested directory in its outputs.

Input code

swc --no-swcrc a.ts b/b.ts c/c/c.ts --out-dir outputs

Config

No response

Playground link

No response

Expected behavior

Say that I have the following directory structure:

.
├── a.ts
├── b
│   └── b.ts
└── c
    └── c
        └── c.ts

I'd expect the following directory structure to be produced by swc:

outputs
├── a.js
├── b
│   └── b.js
└── c
    └── c
        └── c.js

Both the TypeScript compiler and Babel properly produce the expected directory structure.

Actual behavior

but the following is produced:

outputs
├── a.js
├── b.js
└── c
    └── c.js

Version

@swc/cli: 0.1.57, @swc/core: 1.2.129

Additional context

No response

binoche9 avatar Sep 21 '22 18:09 binoche9

dupe of https://github.com/swc-project/swc/issues/3028 I think

alexeagle avatar Sep 22 '22 12:09 alexeagle

Yeah looks like I'm reporting the same behavior, but what we expect the flag to do is different (I expect to keep the directory structure whereas that issue expects to completely flatten it)

binoche9 avatar Sep 22 '22 21:09 binoche9

Same problems !

AlbanMinassian avatar Nov 23 '22 08:11 AlbanMinassian

+1 here. This is the only thing stopping me from adopting swc.

@swc/cli: 0.1.59, @swc/core: 1.3.26

Caluminus avatar Jan 16 '23 13:01 Caluminus

also experiencing this issue and also having this be the only blocker from my adoption of SWC

@swc/core v1.3.61,@swc/cli v0.1.62

elijaholmos avatar Jul 05 '23 21:07 elijaholmos

This is especially a problem when c/c/c.ts has import from '../../a', because then the import has an extra ../ making it import from the source rather than the outputs directory.

soryy708 avatar Nov 27 '23 14:11 soryy708