swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.78k stars 75 forks source link

Added SWCRC env variable #678

Closed candunaj closed 1 year ago

candunaj commented 1 year ago

This PR adds the ability to load the .swcrc file when running the following command:

SWCRC=true node -r @swc-node/register index.ts

.swcrc file is needed in some scenarios, and there was no option to load it. For example, when you need to use a plugin, you need to use the following .swcrc file:

{
  "jsc": {
    "experimental": {
      "plugins": [
        [
          "SWC-plugin-formatjs",
          {
            "overrideIdFn": "[sha512:contenthash:base64:6]"
          }
        ]
      ]
    }
  }
}

I have chosen an environment variable because it was the simplest solution with minimal impact. I did not want to cause breaking change, so it is opt-in rather than opt-out. This way, it can be a minor version bump.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

mansona commented 1 year ago

Hey thanks for merging this @Brooooooklyn 🎉

Is there any chance we can get a release cut for it?

ibash commented 1 year ago

@mansona just published this at @ibash/swc-node-register if you still need it.