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

Implement swcx compile to feature parity to @swc/cli #4017

Open
14 of 16 tasks
kwonoj opened this issue Mar 15, 2022 · 25 comments
Open
14 of 16 tasks

Implement swcx compile to feature parity to @swc/cli #4017

kwonoj opened this issue Mar 15, 2022 · 25 comments

Comments

@kwonoj
Copy link
Member

kwonoj commented Mar 15, 2022

Describe the feature

Related with #3859.

We want to establish initial feature parity to existing @swc/cli to plan out migration with possible breaking changes.

These are initial flags we'd like to have.

Babel plugin or link to the feature description

No response

Additional context

No response

@kwonoj kwonoj changed the title Implement swcx compile to feature parity to @swc/cli Implement swcx compile to feature parity to @swc/cli Mar 15, 2022
@RiESAEX
Copy link
Contributor

RiESAEX commented Apr 28, 2022

just found filename is Implemented in #4016

@Bruce-Hopkins
Copy link

I'm looking to contribute to this project, but it seems all the flags here have already been implemented according to the docs.

@kwonoj
Copy link
Member Author

kwonoj commented Oct 9, 2022

It is not, please see above list with checkboxes.

@Bruce-Hopkins
Copy link

It is not, please see above list with checkboxes.

Oh, I'm sorry, I got confused with the JS cli tool. I will open a PR hopefully soon to add one of these.

@realtimetodie
Copy link
Contributor

  • source_maps
  • source_maps_target

were resolved in #6708

@realtimetodie
Copy link
Contributor

I'm working on the implementation of the --config option.

@alexeagle
Copy link
Contributor

Another TODO item: document the CLI options on the docsite somewhere. Right now tools like Bazel have to recommend that users run swcx --help to see how to use it.

@Aghassi
Copy link

Aghassi commented Feb 8, 2023

+1 on the documentation. I see the --config option was implemented, but when I run it I get an error with the old syntax

~/Downloads/swc-darwin-arm64 compile --config=jsc.transform.react.importSource=@emotion/core
error: Invalid value "jsc.transform" for '--config <CONFIG>': expected value at line 1 column 1

@realtimetodie Would you be able to explain the changes here? I see this just came out in 1.3.34 so no worries, I know it's fairly new.

@realtimetodie
Copy link
Contributor

#6835

@alexeagle
Copy link
Contributor

We document that in a user example now too: aspect-build/rules_swc@8db4ee5

@Aghassi
Copy link

Aghassi commented Feb 10, 2023

Thanks @alexeagle and @realtimetodie . So it looks like the --config now takes a json object instead of a dot notation object when switching between the node and rust based cli(s)

@alexeagle
Copy link
Contributor

FWIW I suspect that's not intentional. @titanous when you added the --config support, did you mean for the syntax to be different from @swc/cli ?

@kdy1
Copy link
Member

kdy1 commented Feb 10, 2023

Should we revert it for now? Maybe it should be another name...
cc @kwonoj

@titanous
Copy link
Contributor

Ah, I didn't know that it was already implemented in @swc/cli. Maybe we should rename to --config-json? I don't really feel like implementing a custom parser for whatever syntax was previously used.

@kdy1
Copy link
Member

kdy1 commented Feb 10, 2023

I think so, we should rename it

@titanous
Copy link
Contributor

Renamed in #6932.

@Klaitos
Copy link

Klaitos commented Feb 15, 2023

Hello, is adding the --copy-files flag planned aswell ?

@realtimetodie
Copy link
Contributor

  • source_file_name
  • source_root

were resolved in #6973

@hopefullToo
Copy link

I work on an Apple M1 machine. arch: arm64.
The problem described occurs regardless of whether swc_cli is also available as a binary installed by cargo.

As described here (https://swc.rs/docs/getting-started) I installed @swc/cli and @swc/core.

Then when I call npx swc --help it shows the help,
When I call npx swcx --help I get this error message:

Error: No binary found matching your system. It's probably not supported.
at BinWrapper.download (/....../swc_cli/node_modules/@mole-inc/bin-wrapper/index.cjs:33675:10)
at BinWrapper.findExisting (/....../swc_cli/node_modules/@mole-inc/bin-wrapper/index.cjs:33658:17)
at async BinWrapper.run (/........./swc_cli/node_modules/@mole-inc/bin-wrapper/index.cjs:33619:3)
at async executeBinary (/......../swc_cli/node_modules/@swc/cli/lib/swcx/index.js:145:5)

swcx is available at node_modules/.bin/.

The swc.darwin-arm64.node file is located in the node_modules/@swc/core-darwin-arm64/ directory. I tentatively made swc.darwin-arm64.node executable with chmod 755. But I can't run it stand alone. This error message appears:
zsh: exec format error: ./swc.darwin-arm64.node

@hopefullToo
Copy link

Should I open a new issue?

@Klaitos
Copy link

Klaitos commented Apr 13, 2023

There is a difference in output directory structure when using swcx cli vs classic swc.

npx swcx compile src --out-dir dist will generate :

➜  swc tree dist     
dist
└── src
    └── index.js

Capture d’écran 2023-04-13 à 12 26 46

npx swc src --out-dir dist will generate :

➜  swc tree dist                  
dist
└── index.js

1 directory, 1 file

Capture d’écran 2023-04-13 à 12 26 33

The src folder is kept in new version of the cli.

Is that a expected behavior ?
It gives me some issues when uploading source-map to Sentry because I have to manipulate some path

Thanks !

@giraffesyo
Copy link

giraffesyo commented Jan 29, 2024

Was trying this out but two issues (already mentioned) are blockers for using the new version:

@theoludwig
Copy link

@Klaitos @giraffesyo

Output directory changes to include top level directory in output structure. i.e. src folder is included. I doubt this is intentional?

The workaround for this, is to use the --strip-leading-paths CLI flag.
Build command could be the following: swc ./src --out-dir ./build --strip-leading-paths --delete-dir-on-start.

sarayourfriend referenced this issue in WordPress/openverse Feb 6, 2024
* Update @openverse/eslint-plugin

* Fix postinstall script

* Update swc build for https://github.com/swc-project/swc/issues/4017\#issuecomment-1506730719

---------

Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
@jwalton
Copy link

jwalton commented Feb 23, 2024

The workaround for this, is to use the --strip-leading-paths CLI flag.

Is there a way to specify this in the config file?

@jfhbrook
Copy link

jfhbrook commented Oct 4, 2024

I can +1 the arm mac issue. This is on 0.4.1-nightly.30340914.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests