1.0.0 • Published 7 months ago

imports-walk-ts v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

imports-walk-ts

Find import and re-export statements in typescript using babel parser.

Install

npm i imports-walk-ts

Usage

source.ts

import moduleA from './module-a';
import moduleB from './module-b';
import moduleC = require('./module-c');
export * from './module-d';

program.ts

import importsWalkTs from 'imports-walk-ts';
import fs from 'fs';
const source = fs.readFileSync('source.ts', 'utf8');

importsWalkTs(source); // <= ['./module-a', './module-b', './module-c', './module-d']

API

importsWalkTs(src, options?)

Looks for import and re-export statements.

src

Type: String Source, where import and re-export statements will be looked for.

options

Type: Object Options are the same as babel parser options.

Related

License

MIT 💖