-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a3f5a5
commit 881981c
Showing
1 changed file
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |