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

Allow SWC Config Overrides #253

Closed
dgreif opened this issue Dec 12, 2024 · 2 comments
Closed

Allow SWC Config Overrides #253

dgreif opened this issue Dec 12, 2024 · 2 comments

Comments

@dgreif
Copy link

dgreif commented Dec 12, 2024

I'm working on switching from Webpack to Vite and would love to port over our full SWC config. I'm able to get fairly close simply by providing the plugins and tsDecorators options, but there are a few other options which I can't currently provide:

useDefineForClassFields - This plugin currently sets this to true with no way to override. It makes sense as this is more spec compliant, but we have a fair amount of code which breaks if this isn't false.

keepClassNames - This isn't an immediate problem for us as we are only using Vite for dev builds at the moment, but it would be blocking if we decide to use Vite for prod builds with SWC via this plugin.

For context, we need these options because we use Catalyst, which uses a few interesting patterns with decorators and uses class names to implicitly define custom element names.

My general question - is there a reason we can't override the config after the plugin applies all the default settings? e.g. a hook that gives you the config object just before transform is called (similar to the more limited parserConfig option)? It seems like this would be useful for many use cases, such as #86 where folks currently have to patch the package to get the desired options.

@ArnaudBarre
Copy link
Member

ArnaudBarre commented Dec 12, 2024

The reason is that this makes a barrier for people to continue using their tech debt and expect that this will be maintain forever. I love maintaining this plugin, but I don't want to have to deal with issues related to how 3 legacy flags used together create a bug. The SWC team decided they want do to that, but that's not my case.

In the same idea, this plugin will not be considered a main plugin when OXC is good enough for replacing the current usages, and I'm think the OXC did choose to not implement the old TS behavior for decorators.

I hope think the friction of creating a patch is for me good so that people know they are in a non supported zone, and hopefully this feels hacky enough so people start to look to migrate their lib to spec compliant alternatives or default cross bundler features.

@dgreif
Copy link
Author

dgreif commented Dec 12, 2024

@ArnaudBarre I appreciate the thoughtful and thorough answer. We'll continue using a patch for now, but look into migrating our decorator usage to use declare, which should work with the default settings.

@dgreif dgreif closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants