Skip to content

Commit

Permalink
Added SWCRC env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
candunaj committed Nov 29, 2022
1 parent ef8f5b1 commit 07968e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -19,6 +19,11 @@ npm i -D @swc-node/register
node -r @swc-node/register script.ts
```

Set environment variable SWCRC=true when you would like to load .swcrc file
```bash
SWCRC=true node -r @swc-node/register script.ts
```

## Support matrix

| | node10 | node12 | node14 | node16 |
Expand Down
9 changes: 8 additions & 1 deletion packages/register/register.ts
Expand Up @@ -41,7 +41,14 @@ export function compile(
}
return outputText
} else {
const { code, map } = transformSync(sourcecode, filename, tsCompilerOptionsToSwcConfig(options, filename))
const swcRegisterConfig = tsCompilerOptionsToSwcConfig(options, filename)
if (process.env.SWCRC === 'true') {
// when SWCRC environment variable is set to true it will use swcrc file
swcRegisterConfig.swc = {
swcrc: true,
}
}
const { code, map } = transformSync(sourcecode, filename, swcRegisterConfig)
// in case of map is undefined
if (map) {
SourcemapMap.set(filename, map)
Expand Down

0 comments on commit 07968e0

Please sign in to comment.