From 881981c1e664f598a2ebdc8e122476fc9ae5eb3a Mon Sep 17 00:00:00 2001 From: Hajime-san Date: Wed, 8 Feb 2023 23:41:07 +0900 Subject: [PATCH] update readme --- README.md | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 52996c7..933ee61 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,39 @@ -# 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", @@ -11,3 +41,7 @@ "noEmit": true } } +``` + +## License +- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)