@depack/detect
v1.1.0
Published
Detects Dependencies In The Source File.
Downloads
516
Readme
@depack/detect
@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' ]