egoist / egoist/bundle-require

Allow `+` to be used in `compilerOptions.paths` via `tsconfig.json`

Open
#47 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
185
Forks
19
PR merge metrics
No merged PRs in 30d

Description

### Allow `+` to be used in `compilerOptions.paths` via `tsconfig.json`

The `tsconfigPathsToRegExp` function in `tsup` attempts to [convert](https://github.com/egoist/bundle-require/blob/main/src/index.ts#L132-L136) paths into a regex, but it fails with paths that include the `+` symbol.

This is a valid `tsconfig` paths configuration:

```json
...
"compilerOptions": {
"paths": {
"+@pro/*": [".pro/src/*"],
"+new/*": [".new/*"],
"$/*": ["./*"],
},
},
...
```

It fails with this error:

```bash
19:24:06 @pro/package: SyntaxError: Invalid regular expression: /^+@pro/.*$/: Nothing to repeat
```

```bash
19:24:06 @pro/another-package: SyntaxError: Invalid regular expression: /^+new/.*$/: Nothing to repeat
```

The `+` symbol should be escaped:

```ts
/^\+@pro/.*$/
```

```ts
/^\+new/.*$/
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.