@depack/detect

1.1.0 • Public • Published

@depack/detect

npm version

@depack/detect Detects Dependencies In The Source File.

yarn add -E @depack/detect

Table Of Contents

API

The package is available by importing its default function:

import detect from '@depack/detect'

detect(
  source: string,
): Array<string>

Returns the paths or names of packages that are imported in the source code.

For example, for the given source file

import test from 'test'
import test2, * as test3 from 'test2'
import 'test3'
export { default as Test } from 'test4'

It will produce the following output

/* yarn example/ */
import detect from '@depack/detect'
import read from '@wrote/read'

(async () => {
  const source = await read('example/source.js')
  const res = detect(source)
  console.log(res)
})()
[ 'test', 'test2', 'test3', 'test4' ]

Copyright

Art Deco © Art Deco for Depack 2019 Tech Nation Visa Tech Nation Visa Sucks

Readme

Keywords

Package Sidebar

Install

npm i @depack/detect

Weekly Downloads

67

Version

1.1.0

License

MIT

Unpacked Size

6.79 kB

Total Files

9

Last publish

Collaborators

  • zvr