Giter VIP home page Giter VIP logo

Comments (12)

craigmiller160 avatar craigmiller160 commented on July 17, 2024 7

The above solution is not a "solution". SWC's configuration leaves a LOT to be desired, which is unfortunate since it is otherwise such an exceptional tool.

The ability to specify which files should be included & excluded is a basic requirement of configuration. It shouldn't be this hard to do. There shouldn't be this many broken configuration options in the CLI or SWCRC.

I sincerely hope this gets resolved.

from cli.

chyzwar avatar chyzwar commented on July 17, 2024 4

Once problem with using exclude in swcrc is that it would break in jest tests. If I add above exclude then @swc/jest will error in jest with

cannot process file because it's ignored by .swcrc

see this build https://github.com/swc-project/cli/pull/32/checks?check_run_id=2713136059

from cli.

caseykhuc avatar caseykhuc commented on July 17, 2024 4

The following solution should work. Summary: Override swc config for files that require @swc/jest.

const swcConfig = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, "utf-8"));

// ---
  transform: {
    ".+\\.ts$": [
      "@swc/jest",
      {
        ...swcConfig,
        exclude: [],
        swcrc: false,
      },
    ],
  },
// ---

swc-project/jest#62

Document

from cli.

tangye1234 avatar tangye1234 commented on July 17, 2024 3

Any update? Now I can only have 2 swcrc for build and test. I have just turned my oss into swc based but now frustrated for this.

from cli.

Naoto-Ida avatar Naoto-Ida commented on July 17, 2024 2

I'll also mention that the --ignore option isn't working for us (on latest 0.1.57).
A workaround is to have 2 .swcrc, but this is not ideal :p

Our repo looks like:

📁 src
  📁 __tests__
  📁 components

And we're running swc ./src/ -d lib --ignore src/**/__tests__/*.tsx. The tests get transpiled to lib despite the --ignore.

from cli.

r-guerin avatar r-guerin commented on July 17, 2024 1

Hi guys, is there any update on the subject ? I am still struggling to ignore files through the --ignore arg using the 0.1.57.

from cli.

chyzwar avatar chyzwar commented on July 17, 2024

I this is now supported by swcrc, "exclude": "(tests|mocks)", should we pass this options via cli as well ? @kdy1

from cli.

coffee377 avatar coffee377 commented on July 17, 2024

This issue was fixed in 0.1.54(#90), but still exists in 0.1.55.
In version 0.1.54, copying non-compilable files was not work(ignored files were not copied)

from cli.

MohamedLamineAllal avatar MohamedLamineAllal commented on July 17, 2024

--ignore, --only are not supported at all.

Dir command compilation

https://github.dev/swc-project/cli/blob/ec9a985ba8ce0fa89c395a12c129a34d235e35e2/src/swc/dir.ts#L291

File command compilation

https://github.dev/swc-project/cli/blob/ec9a985ba8ce0fa89c395a12c129a34d235e35e2/src/swc/file.ts#L10

And cli options that are consumed by the code (program):

https://github.dev/swc-project/cli/blob/ec9a985ba8ce0fa89c395a12c129a34d235e35e2/src/swc/options.ts#L248

  const cliOptions: CliOptions = {
    outDir: opts.outDir,
    outFile: opts.outFile,
    filename: opts.filename,
    filenames,
    sync: !!opts.sync,
    sourceMapTarget: opts.sourceMapTarget,
    extensions: opts.extensions || DEFAULT_EXTENSIONS,
    watch: !!opts.watch,
    copyFiles: !!opts.copyFiles,
    includeDotfiles: !!opts.includeDotfiles,
    deleteDirOnStart: Boolean(opts.deleteDirOnStart),
    quiet: !!opts.quiet,
  };

I guess the API is not stable yet. And things may change in the future.

I guess also for testing. One as like with many tools and tsconfig. One can make different config files for different purposes. And hence separating the testing one from the main one.

from cli.

Mnigos avatar Mnigos commented on July 17, 2024

Same error for vitest.

Error: cannot process file because it's ignored by .swcrc

from cli.

cilvet avatar cilvet commented on July 17, 2024

Same problem. Neither "exclude" nor "ignore" options are working properly yet.

from cli.

kdy1 avatar kdy1 commented on July 17, 2024

@josteph Are you still willing to open a PR? If not, I'll work on it

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.