Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Hajime-san committed Feb 8, 2023
1 parent 8a3f5a5 commit 881981c
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
# ntd
# module-specifier-resolver
This tool transforms your local TypeScript code that gives you to rewrite file extension of `module specifier` automatically.

# command
`deno run --allow-env --allow-read src/mod.ts -b=./examples/repo/src -c=./examples/repo/tsconfig.json`
## examples
```ts
export { foo } from "./foo"
transform to
export { foo } from "./foo.(ts|tsx|d.ts)"
```

# tsconfig.json
```ts
import { bar } from "./bar"
transform to
import { bar } from "./bar.(ts|tsx|d.ts)"
```

## limitation
- Can't resolve `paths` alias of TypeScript compiler options.
- Can't resolve `import()` syntax, commonly called `dynamic import`.
- Can't keep `newline` of original source code.

## command
- `deno task bin-dry`
- `deno task bin`

### arguments
| key | description | type | default |
|-----|-----|-----|-----|
| -b | local of base directory | `string` | `./` |
| -c | local of base `tsconfig.json` | `string` | `./tsconfig.json` |
| -d | dry run | `boolean` | `false` |

## tips
After you ran `bin.ts`, you should run `npx tsc --noEmit` due to check correctness of transformation by this tool.
- `tsconfig.json` example
```json
{
"compilerOptions": {
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"noEmit": true
}
}
```

## License
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

0 comments on commit 881981c

Please sign in to comment.