Skip to content

Commit

Permalink
feat: Disable Sucrase's keepUnusedImports setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Septh committed May 6, 2024
1 parent 8f0cbe5 commit 33b4c0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ Use the `.ts`, `.mts` or `.cts` extensions when importing modules. They are mand
import { something } from './utilities.ts'
```

Contrary to the TypeScript compiler or other tools like `ts-node`, `tsx` or `tsimp`, `ts-run` will not try and find a corresponding `.ts` file if you use a `.js` specifier.
Contrary to the TypeScript compiler or other tools like `ts-node`, `tsx` or `tsimp`, `ts-run` will *not* try and find a corresponding `.ts` file if you use a `.js` specifier. See the [authoring section](#authoring-your-scripts) for details on how to enable .ts extension imports.

### Type-only imports and exports
It is generally better to be explicit about type-only imports and exports by using TypeScript's `import type ...`, `import { type ...}` and `export type ...` syntax.

>New in 1.2.3:<br>However, because not everyone is willing to type the extra characters, `ts-run` will now automatically remove type-only imports and exports. (see [Sucrase documentation](https://github.com/alangpierce/sucrase#transforms) for more info).
### ESM vs CommonJS
`ts-run`'s sole role is to transpile TypeScript code to JavaScript code, no more, no less. It does not try to convert scripts from CommonJS to ESM or vice-versa, it does not try to optimize or minify your code and it does not downlevel nor polyfill JavaScript.
Expand Down
1 change: 0 additions & 1 deletion source/cjs-transform.cts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function transform(source: string, format: NodeJS.ModuleType, filePath: s
preserveDynamicImport: true,
disableESTransforms: true,
injectCreateRequireForImportRequire: true,
keepUnusedImports: true,
sourceMapOptions: {
compiledFilename: filePath
}
Expand Down

0 comments on commit 33b4c0d

Please sign in to comment.