-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
swc-node/register does not pick up swcrc correctly #701
Comments
Not to be "that guy" but it works for me even without
This causes a whole bunch of extra debug to be printed when I run with |
Oh interesting. But it doesn't work if I'm using |
Aren't you supposed to use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
There does not seem to be a way to run something along the lines of this, and have it pick up the
.swcrc
file:Even the suggested
SWCRC
environment variable doesn't work:Configuration
Create a simple project which uses decorators, which are not enabled by default in swc. (There's nothing special about decorators, just that they are something which requires enabling explicitly in the config.)
.swcrc
Note decorators are enabled here.
package.json
Note that this includes ts-node as a way to show the expected behavior.
tsconfig.json
src/cached.ts
The decorator implementation — a really simple memoizer. Again, the details here don't actually matter, but I wanted something working.
src/color.ts
This is where the problems will happen, as it's where the decorator is used.
src/test.ts
The script which will actually be run.
Steps to reproduce
Run:
npm run swc-cli
. Note that it compiles just fine:Temporarily rename
.swcrc
to something else and retry that previous step. Note the expected failure, as swc doesn't like decorators but can no longer see the config:Rename the config file back to
.swcrc
and ensure the cli can compile successfully again.Run
npm run ts-node
. Note that it runs just fine:Run
npm run swc-node
. Note that it fails with the above error. (This is poor developer experience, based on how swc-cli picks up the config correctly, but y'all do you.)Run
npm run swc-node:withConfig
, which uses the documentedSWCRC
environment variable. Note that it still fails.Expected behavior
Personally, I'd prefer if register did the intuitive thing and picked up the
.swcrc
file. Barring that, I'd be happy if theSWCRC
environment variable worked as documented. That's a bit awful, as it means all my scripts which look likenode -r @swc-node/register ...
will now needSWCRC=1
prefixed to them ... but that's not the end of the world.Or, if there is some other way to make register see the
.swcrc
, I'm all ears.The text was updated successfully, but these errors were encountered: