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
There does not seem to be a way to run something along the lines of this, and have it pick up the .swcrc file:
node -r @swc-node/register src/test.ts
Even the suggested SWCRC environment variable doesn't work:
SWCRC=1 node -r @swc-node/register src/test.ts
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.)
Run: npm run swc-cli. Note that it compiles just fine:
Successfully compiled: 3 files with swc (7.2ms)
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:
rgb(102, 51, 153)
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 documented SWCRC 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 the SWCRC environment variable worked as documented. That's a bit awful, as it means all my scripts which look like node -r @swc-node/register ... will now need SWCRC=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:
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: