Open axyz opened 3 years ago
It appears to only be checking for .swcrc
files:
https://github.com/swc-project/swc/blob/6dc6d8a8474f17a1064a9da2d7744bf518f72660/src/lib.rs#L406-L427
I also have a similar issue with monorepos, can someone help to fix it?
Describe the bug
I'm trying to migrate to swc in a monorepo that uses lerna and yarn workspaces, as there are many nested packages in various level of subfolders, for the setup to work we need to be able to get configs from the root of the monorepo. The way this is achieved with babel (both for babelrc and other settings like browserlistrc) is to pass the
--root-mode upward
option when calling babel from a nested project folder.Trying to do the same with swc resulted on 3 main issues:
--root-mode
is not recognized as an option in the swc cli. The only way I found to pass the option is-C rootMode=upward
, this is a minor issue, but is hard to figure out from the documentation and--root-mode
should ideally work in order to be compatible with babel API.swcrc
files in parent folders are ignored. It seems that only the on in the current folder works, this makes the option useless and makes it impossible to use swc in a monorepo without duplicating the swcrc everywhere or rely on a known number of../../
to use.swc.config.js
as mentioned here: https://github.com/swc-project/swc/blob/master/node-swc/src/types.ts#L67 does not seem to work. That makes it harder to have dynamic config (e.g. using a different preset env for cjs and esm).Expected behavior
--root-mode
option should work on the cli--root-mode
is set toupward
swc should read theswcrc
as well as browserlist config (from rc file or package json) from the first parent package that defines themswc.config.js
to enable dynamic config, or alternative should be provided and documented (e.g. different keyed env fields in theswcrc
?)Version The version of @swc/core: latest (1.2.60)
Additional context See: https://github.com/swc-project/swc/discussions/178