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

(Bug?) Outdir adds "baseUrl" to directory structure as of V0.3.0 #282

Closed
baskager opened this issue Jan 25, 2024 · 3 comments
Closed

(Bug?) Outdir adds "baseUrl" to directory structure as of V0.3.0 #282

baskager opened this issue Jan 25, 2024 · 3 comments

Comments

@baskager
Copy link

When setting the baseUrl in .swcrc as such:

{
    "jsc": {
        "baseUrl": "./src"
    }
}

...And running swc with the outdir set like this:

npx swc --config-file .swcrc ./src -d dist

I end up with an extra /src/ in the outdir folder

image


Is this a breaking change for V0.0.3 or might this be a bug?

Comparison: V0.2.3 outputs vs V0.3.0 outputs

V0.2.3

image

V0.3.0 (wrapped in an additional src directory

Screenshot from 2024-01-25 18-37-57

@baskager baskager changed the title https://github.com/baskager(Bug?) Outdir adds "baseUrl" directory as of V0.3.0 (Bug?) Outdir adds "baseUrl" directory as of V0.3.0 Jan 25, 2024
@baskager baskager changed the title (Bug?) Outdir adds "baseUrl" directory as of V0.3.0 (Bug?) Outdir adds "baseUrl" to directory structure as of V0.3.0 Jan 25, 2024
@baskager
Copy link
Author

baskager commented Jan 25, 2024

If it is intended behavior it does deviate from tsc. This could cause issues for people. For instance: When one wants to generate type definitions (.d.ts files). This is not yet supported in SWC.

The above-mentioned issue was actually our exact case, the new types were able to be imported from our packages as expected but the .js files were still outdated. (see following command example).

e.g.

npx tsc --declaration --emitDeclarationOnly && npx swc --config-file .swcrc ./src -d dist

Would place the compiled .js files in /dist/src/ and the corresponding type definitions in /dist/.


Breaking changes such as this come as kind of a surprise and lead to strange behavior after an update of NPM packages. In addition there is little communication about the breaking change which then turns it into a bit of a "needle-in-a-haystack" situation. Would love to brainstorm and help out on this point if you're on board with that 👍

Thanks for taking the time reading my ramblings, much appreciated ☺️

@kdy1
Copy link
Member

kdy1 commented Jan 26, 2024

See #281

@kdy1
Copy link
Member

kdy1 commented Jan 26, 2024

Closing as fixed by #283.
You can use --strip-leading-paths to get the old behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants