babylon-module-definitons

1.0.0 • Public • Published

babylonModuleDefinitions

npm i babylon-module-definitons --save

Why

Needed way of getting deps from a file with the babel syntax. Specifically because acorn does not support async / await.

Usage

Pass in code (sync):

let code = `
import * as one from 'one'
import "two"
import three from "three"
require('four')
let five = require('five')
`

let val = babylonModuleDefinitions({code})
assert.deepEqual(val, ['one', 'two', 'three', 'four', 'five'])

Pass in file (async - returns promise):

let file = './test/index.js'
babylonModuleDefinitions({file}).then(val => {
  assert.deepEqual(val, ['../src/index', 'assert'])
})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.00

Package Sidebar

Install

npm i babylon-module-definitons

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • reggi