Skip to content

Commit

Permalink
feat: rename env vars to use TSX prefix (#372)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Rename env vars prefix from `ESBK_` to `TSX_`
  • Loading branch information
privatenumber committed Nov 9, 2023
1 parent f8a8540 commit a06da32
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ To set a custom path, use the `--tsconfig` flag:
tsx --tsconfig ./path/to/tsconfig.custom.json ./file.ts
```

Alternatively, use the `ESBK_TSCONFIG_PATH` environment variable:
Alternatively, use the `TSX_TSCONFIG_PATH` environment variable:

```sh
ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json tsx ./file.ts
TSX_TSCONFIG_PATH=./path/to/tsconfig.custom.json tsx ./file.ts
```

### Watch mode
Expand Down Expand Up @@ -147,6 +147,12 @@ Set the `--no-cache` flag to disable the cache:
tsx --no-cache ./file.ts
```

Alternatively, use the `TSX_DISABLE_CACHE` environment variable:

```sh
TSX_DISABLE_CACHE=1 tsx ./file.ts
```

### Node.js Loader

`tsx` is a standalone binary designed to be used in place of `node`, but sometimes you'll want to use `node` directly. For example, when adding TypeScript & ESM support to npm-installed binaries.
Expand Down
6 changes: 3 additions & 3 deletions src/cjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const isTsFilePatten = /\.[cm]?tsx?$/;
const nodeModulesPath = `${path.sep}node_modules${path.sep}`;

const tsconfig = (
process.env.ESBK_TSCONFIG_PATH
process.env.TSX_TSCONFIG_PATH
? {
path: path.resolve(process.env.ESBK_TSCONFIG_PATH),
config: parseTsconfig(process.env.ESBK_TSCONFIG_PATH),
path: path.resolve(process.env.TSX_TSCONFIG_PATH),
config: parseTsconfig(process.env.TSX_TSCONFIG_PATH),
}
: getTsconfig()
);
Expand Down
6 changes: 3 additions & 3 deletions src/esm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { getPackageType } from './package-json.js';
export const applySourceMap = installSourceMapSupport();

const tsconfig = (
process.env.ESBK_TSCONFIG_PATH
process.env.TSX_TSCONFIG_PATH
? {
path: path.resolve(process.env.ESBK_TSCONFIG_PATH),
config: parseTsconfig(process.env.ESBK_TSCONFIG_PATH),
path: path.resolve(process.env.TSX_TSCONFIG_PATH),
config: parseTsconfig(process.env.TSX_TSCONFIG_PATH),
}
: getTsconfig()
);
Expand Down
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function run(

if (options) {
if (options.noCache) {
environment.ESBK_DISABLE_CACHE = '1';
environment.TSX_DISABLE_CACHE = '1';
}

if (options.tsconfigPath) {
environment.ESBK_TSCONFIG_PATH = options.tsconfigPath;
environment.TSX_TSCONFIG_PATH = options.tsconfigPath;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/transform/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class FileCache<ReturnType> extends Map<string, ReturnType> {
}

export default (
process.env.ESBK_DISABLE_CACHE
process.env.TSX_DISABLE_CACHE
? new Map<string, Transformed>()
: new FileCache<Transformed>()
);
4 changes: 2 additions & 2 deletions tests/utils/tsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const tsx = (
options.args,
{
env: {
ESBK_DISABLE_CACHE: '1',
TSX_DISABLE_CACHE: '1',
DEBUG: '1',
},
nodePath: options.nodePath,
Expand Down Expand Up @@ -51,7 +51,7 @@ export const createNode = async (
{
cwd,
env: {
ESBK_DISABLE_CACHE: '1',
TSX_DISABLE_CACHE: '1',
DEBUG: '1',
},
nodePath: node.path,
Expand Down

0 comments on commit a06da32

Please sign in to comment.