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

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

Closed
MohamedLamineAllal opened this issue Sep 30, 2022 · 4 comments · Fixed by #6054
Labels
Milestone

Comments

@MohamedLamineAllal
Copy link
Contributor

MohamedLamineAllal commented Sep 30, 2022

Describe the bug

npx swc src --out-dir "some dist" -C "exclude=.*.spec.ts$"

Doesn't work.

While exclude: [".*.spec.ts$"] works if used in .swcrc.

Expected behavior

Should work just like it does with .swcrc

Version

@swc/cli: 0.1.57, @swc/core: 1.3.1

@MohamedLamineAllal
Copy link
Contributor Author

MohamedLamineAllal commented Oct 1, 2022

I analyzed the code a bit. To get a better understanding.

And basically, 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():

   // 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)?;
   // .....

Should fix that. Before read_config, to avoid reading the configurations. If the file is to be excluded.

@MohamedLamineAllal
Copy link
Contributor Author

MohamedLamineAllal commented Oct 1, 2022

Another question,

Why the src files are read before exclusion and matching?

bindings/binding_core_node/src/transform.rs#L67

      Input::File(ref path) => {
          let fm = self.c.cm.load_file(path).context("failed to load file")?;
          self.c.process_js_file(fm, handler, &options)
      }

@MohamedLamineAllal
Copy link
Contributor Author

Here a draft PR #6054

@kdy1 kdy1 added this to the Planned milestone Oct 6, 2022
@kdy1 kdy1 closed this as completed in #6054 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 issue 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-bot
Copy link
Collaborator

swc-bot commented Nov 5, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@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
Development

Successfully merging a pull request may close this issue.

3 participants