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

fix(swc): exclude option not processed from cli #6054

Conversation

MohamedLamineAllal
Copy link
Contributor

@MohamedLamineAllal MohamedLamineAllal commented Oct 5, 2022

Description:

First time contributing here. And big thanks too for all the great work.

A Draft that fixes the issue #6009.
Wrote a test too.

I wonder if I didn't miss anything.

From my understanding, it seems the only place where the exclude matching happens is through the RC.into_config() method. And in Compiler.read_config() method. The excluded value from opts is not used. And only the one read from files.

And i guess adding the bellow in Compiler.parse_js_as_input() before Compiler.read_config():

   // adding
   if let FileName::Real(ref path) = name {
       if !opts.config.matches(path)? {
           return Ok(None);
       }
   }
   // before read_config
   let config = self.read_config(opts, name)?;
   // .....

does fix the problem.

If cli options have no exclude in config. or test, the file would automatically match. Otherwise, the exclude would be run, And then test. And so the condition work in all cases.

read_config() in case .swcrc contains and exclude that match, would return to None. So for that, I run the match before it. And in case of a no matching, I returned None.

I run the tests through cargo test -p swc they pass well. I didn't test beyond that. Including building and running the binding against swc/cli.

BREAKING CHANGE:

None.

@CLAassistant
Copy link

CLAassistant commented Oct 5, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


reset ci


swc-bump:

  • swc

@kdy1 kdy1 enabled auto-merge (squash) October 6, 2022 01:51
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit 69da081 into swc-project:main Oct 6, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.5 Oct 6, 2022
MohamedLamineAllal added a commit to TheMagicianDev/swc-command that referenced this pull request Oct 30, 2022
- fix the problem with exclude not working in the cli as per the ISSUE that i created
swc-project/swc#6009.
And the FIX that i contributed PR
swc-project/swc#6054.
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

swc-cli: -C "exclude=.*\.spec\.ts" doesn't work from the cli, while it works ok from .swcrc file
4 participants