0.0.5 • Published 6 years ago

dependit v0.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

dependit

Parse all the imported modules inside the file(Only ES Modules supported)

To install:

npm install dependit -S

Usage

import getDependency from 'dependit'

const filepath = '/path/to/your/file'
const result = getDependency(filepath)

API Documentation

getDependency(filepath)

  • filepath absolute path to your file

Returned object

The return value is an object with all the dependencies information. The object's structure is listed below using TypeScript.

interface Result {
  path: string,
  dependencies: Array<Dependency>
}

interface Dependency {
  source: string,
  imported: Array<ImportedItem>
}

interface ImportedItem {
  value: string,
  local: string,
  type: ImportType
}

enum ImportType {
  default = 'ImportDefault',
  import = 'Import',
  namespace = 'ImportNamespace'
}

Supported file types

Currently only 4 types are supported:

  • .js
  • .jsx
  • .ts
  • .vue