You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my monorepo I have a project that consists of a couple of "root" folders that require transpiling. Using the example from the minimal reproduction repo, let's say these are the folders:
The goal is to transpile all 3 folders with a single command.
When you run tsc -b script in the workspace, it produces the .js output in an analogous structure of the workspace folder itself, just nested inside dist:
I want to achieve the same result with swc. But it turns out that swc . -d dist does not work at all. I tried to come up with various different ways that could work. I've listed them below.
Different approaches
swc . -d dist
❌ This is the most natural way of running the command, but it does not generate any output.
cd ..; swc backend -d backend/dist --config-file backend/.swcrc
✅ Generates correct output.
cd ..; swc $PWD -d $PWD/dist --config-file $PWD/.swcrc
✅ Generates correct output.
swc $PWD -d $PWD/dist
❌ Generates a malformed (flattened) directory structure.
The "outer" commands (requiring to move out of the directory) look like a hack. When working in a monorepo like this one, it is required to use the top-level swc packages, cause yarn will not let you run backend's copy of swc from an outer directory. This means that you cannot use the devDependency of a package to build it, you need to rely on external tools, which is not as portable as I'd like it to be.
The "inner" commands (those that are run inside the project's working directory) do not work correctly. The version with the dot (.) is what I'd suppose to be the correct usage of the CLI, but it does not produce any output. But even if I provide the same absolute paths as for the "outer absolute" command, it generates a different output when run inside the workspace folder.
Running 3 separate commands for each of the root folders provides a correct output, but it requires listing the folders manually. You cannot combine such script with a flag like --watch by appending the flag, because it will be only applied to the last command. You also need to update the command whenever one of the folder changes or you add another one.
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.
Describe the bug
In my monorepo I have a project that consists of a couple of "root" folders that require transpiling. Using the example from the minimal reproduction repo, let's say these are the folders:
integration-tests
generated
src
The goal is to transpile all 3 folders with a single command.
When you run
tsc -b
script in the workspace, it produces the.js
output in an analogous structure of the workspace folder itself, just nested insidedist
:I want to achieve the same result with swc. But it turns out that
swc . -d dist
does not work at all. I tried to come up with various different ways that could work. I've listed them below.Different approaches
swc . -d dist
❌ This is the most natural way of running the command, but it does not generate any output.
cd ..; swc backend -d backend/dist --config-file backend/.swcrc
✅ Generates correct output.
cd ..; swc $PWD -d $PWD/dist --config-file $PWD/.swcrc
✅ Generates correct output.
swc $PWD -d $PWD/dist
❌ Generates a malformed (flattened) directory structure.
swc src -d dist/src & swc generated -d dist/generated & swc integration-tests -d dist/integration-tests
✅ Generates correct output.
The "outer" commands (requiring to move out of the directory) look like a hack. When working in a monorepo like this one, it is required to use the top-level
swc
packages, causeyarn
will not let you run backend's copy ofswc
from an outer directory. This means that you cannot use thedevDependency
of a package to build it, you need to rely on external tools, which is not as portable as I'd like it to be.The "inner" commands (those that are run inside the project's working directory) do not work correctly. The version with the dot (
.
) is what I'd suppose to be the correct usage of the CLI, but it does not produce any output. But even if I provide the same absolute paths as for the "outer absolute" command, it generates a different output when run inside the workspace folder.Running 3 separate commands for each of the root folders provides a correct output, but it requires listing the folders manually. You cannot combine such script with a flag like
--watch
by appending the flag, because it will be only applied to the last command. You also need to update the command whenever one of the folder changes or you add another one.Input code
No response
Config
Playground link (or link to the minimal reproduction)
https://github.com/akwodkiewicz/swc-folders-bug
SWC Info output
$ npx -y swc-info@latest
Expected behavior
I'd expect one (or both) to work correctly:
swc . -d dist
swc $PWD -d $PWD/dist
Actual behavior
swc . -d dist
Does not generate any output
swc $PWD -d $PWD/dist
Generates malformed (flattened) directory structure
Version
cli: 0.1.62, core: 1.3.93
Additional context
No response
The text was updated successfully, but these errors were encountered: