Comments (12)
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.
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.
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,
},
],
},
// ---
from cli.
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.
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.
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.
I this is now supported by swcrc, "exclude": "(tests|mocks)", should we pass this options via cli as well ? @kdy1
from cli.
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.
--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):
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.
Same error for vitest.
Error: cannot process file because it's ignored by .swcrc
from cli.
Same problem. Neither "exclude" nor "ignore" options are working properly yet.
from cli.
@josteph Are you still willing to open a PR? If not, I'll work on it
from cli.
Related Issues (20)
- Chokidar watch options
- `spack` - Panic on arrays with 64 or more numbers
- Support for ESM in spack HOT 2
- Can Spack cli support watch mode
- Outdated dependencies causes 'vulnerabilities found' warnings HOT 5
- Currently not working on arm64, but easy to workaround/fix HOT 2
- spack size limitations
- `--ignore` and `--only` do not work HOT 10
- swc_ecma_lints E0554 `#![feature]` may not be used on the stable release channel HOT 6
- bin-wrapper uses bin-check (6 years old now) which uses execa 0.x that has security issues HOT 1
- Config output path name property does not work
- There is no reliable way to include/exclude files HOT 3
- It is recommended to redirect all messages to stderr HOT 1
- Add an option to process files in parallel with worker processes HOT 1
- NestJS SWC v0.1.64 Compile Error: 'Cannot read properties of undefined (reading 'length')' HOT 1
- Changed output directory structure in 0.2.2 HOT 9
- (Bug?) Outdir adds "baseUrl" to directory structure as of V0.3.0 HOT 3
- Feature Request: Provide CLI options via file
- Cannot read properties of undefined (reading 'stripLeadingPaths') HOT 1
- Verison `0.3.3` generates files with the `.undefined` extension HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.