Replies: 2 comments 3 replies
-
It's merged by using |
Beta Was this translation helpful? Give feedback.
-
@kdy1 Some more examples https://github.com/tomdracz/swc-test/tree/test2 Seems like setting Also, does using jsx/tsx implies:
That's what the output is matching up. Bit confused as defaults at https://swc.rs/docs/configuration/compilation suggest Should I open up issue for this one? |
Beta Was this translation helpful? Give feedback.
-
Trying to figure this out but cannot quite make rhyme or reason of the behaviour. With example app here https://github.com/tomdracz/swc-test
.swcrc:
and swcOptions defined inline
Calling
swc.transform
at https://github.com/tomdracz/swc-test/blob/main/index.js#L15 processing file that has got both TSX and decorators works fine but how is the config resolution done?For decorators and tsx properties I've noticed that:
.swcrc
and inline options are present, it will be processed if at least one file defines it astrue
true
false
So the behaviour suggests no way to override one config with another, right? I cannot have
.swcrc
defined and use programmatic config inswc.transform
that changes some of the defaults. Neither does it work the other way around.Now let's see how this works for non-booleans. Let's say I've got transformation defined as
and
The generated code includes
fromInlineConfig
- looks like this one wins in case of duplication. If it's only defined in one place, wherever it's defined it's applied. So for (at least) some string values, I can override.swcrc
with inline config. Neat! But inconsistent!For fun what if I try and define:
in one place or another?
It doesn't work! If
syntax: ecmascript
is set in.swcrc
it errors out when encountering decorator. If set inline, it errors out on ts syntax. I needsyntax: typescript
in both places for it to work. I cannot skip setting syntax in.swcrc
as I get config load error and if I skip it in my inline config, TS is not processed (falling back toecmascript
?)So... sometimes config is seemingly overridden, sometimes it's merged, sometimes it's not. I cannot quite see a clear pattern of what works when.
Has anybody got good explanation about how is this behaviour implemented? I'm curious about inconsistencies but neither have enough Rust know-how or the knowledge of the project to know where to look. Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions