Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blacha/codeshift
Shift
https://github.com/blacha/codeshift
Last synced: about 18 hours ago
JSON representation
Shift
- Host: GitHub
- URL: https://github.com/blacha/codeshift
- Owner: blacha
- Created: 2021-09-12T23:35:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-04T17:23:16.000Z (over 1 year ago)
- Last Synced: 2024-05-28T22:01:00.920Z (8 months ago)
- Language: JavaScript
- Size: 159 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jscodeshift transformers
Usage
```
jscodeshift --transform=src/ts-import-add-ext.js --parser ts :pathToTypescriptFiles
```## src/ts-import-add-ext.js
Converts Typescript files that use `import {foo} from './bar'` into ESM module imports `import {foo} from './bar.js'`
Examples
Before:
```typescript
import { Foo } from './bar';
export { Bar } from './bar';
export * from './baz';
```After:
```typescript
import { Foo } from './bar.js';
export { Bar } from './bar.js';
export * from './baz.js';
```## src/ts-dirname.js
Converts `__dirname` and `__filename` into ESM module constants
```typescript
import path from 'node:path';
import url from 'node:url';const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const __filename = url.fileURLToPath(import.meta.url);
```## src/ospec-to-node-test.js