-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Config files fail with top-level array #5720
Comments
Alternative/real-world steps:
|
I gave it a quick go on this and found out top-level array of config was never consistently supported. In some part of swc consumes it, but mostly betrays what people assumes.
If
Fails to parse.
Fails to parse.
I think at this point it's safe to assume this feature is non-existent (or not working at all) and design interface again from scratch. Probably biggest question is how can we provide consistence between binding interfaces vs. cli, as well as should we perform single-input multiple-output transforms (which we never did & generally avoid). Or simply, we take this back and enforce .swcrc to not allow arrays. It's simple, but breaking changes, and possibly disappoint @jrieken 😅 . /cc @kdy1 for thought, as well as @jrieken if you can share some opinions. Specifically, how critical it is to have these features? I'm bit concerned this could be a major surgery to existing interfaces (`transform* and other bindings interfaces) and curious if we could achieve similar without those. |
I'm not sure how critical it is, but I prefer to fix the array config because we can avoid a breaking change. |
Is there a way to make non-breaking changes for this? for example, let's think about this
now becomes
if we'd like to allow multiple config input via configfile, unless we decide to omitting non-first config in the swcrc. In the opposite, if we decide to keep transform api as-is and cut off array support, it's also obvious breaking changes. |
The top-level array in See https://swc.rs/docs/configuration/compilation#multiple-entries So we don't need to change |
But patterns can be non-exclusive, in that case how will it works? if config A and B specifies both file, then we'll just take one? and should we calculate it per each transform? Also, I'd like to point out that's somewhat non-intuitive for some users, as they might expect (or misunderstood) like me to behave single-input to multiple outputs. So far, in my opinion this seems a source of confusion, including current design and implementation. |
Yeah, the first one is used. |
The way I understood was actually in this way, also @jrieken should double confirm but if you see vscode's config (https://github.com/microsoft/vscode/blob/joh/swc-array-config/build/lib/swc/.swcrc-amd / https://github.com/microsoft/vscode/blob/joh/swc-array-config/build/lib/swc/.swcrc-no-mod) it also aims similar. So at least I'd say this can confuse some amount of users. |
This is because of some other tools actually behave in multiple-emission way even though it's not 100% same. For example, https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations webpack emits multiple bundles based on multiple configuration inputs. (again, not 100% identical, but) |
My reasoning about the guess is that there's no way to specify name of output files, so the user should not expect it to emit multiple files. After all, it should emit output to same file. But well, I think this feature was a mistake. Maybe we need a more general dynamic configuration API like starlark |
Yes, my general impression so far is this is not a well-defined interface at least. I'd like to approach this in 2 perspective, first would like to confirm original issue's intent and provide possible workaround. And also attempt to remove this feature, prepare better way to support specific usecases. |
That's totally fine for me. Our challenge is the following: One file (might be more in the future) cannot be emitted with the AMD-stuff around it, because it is AMD bootstrap code. E.g it should be emitted as-is. That's why I originally filed #4989. I couldn't get this to work with a single config and therefore created two ones. Maybe I misunderstood #4989 (comment) and you can help to configure things in a single config file? |
Is using bindings api ( |
I had tried that in the past and for some reason didn't continue with it. I gave this another shot and I am happy to report success 🚀 . We now have A full transpile-run using SWC (VS Code and its built-in extension) takes 12s on our CI/CD machines. That is very awesome and improves our daily dev workflow significantly. Thanks btw - I don't mind if you close this issue without code changes |
Great to hear! Please let us know if there are something we can followup later.
Thanks for the confirmation. I think issue itself is still legit, even though we may not change things immediately we'll keep this for a while. |
@jrieken Did you use |
Describe the bug
According to the docs and this discussion it should be possible to have an array as config but SWC fails
Playground steps
Input code
;
Config
Playground link
No response
Expected behavior
SWC should pick up each element of the config-array as separate configuration
Actual behavior
It errors, playground crashes
Steps
Version
1.2.246
Additional context
No response
The text was updated successfully, but these errors were encountered: