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'])
})

Readme

Keywords

none

Package Sidebar

Install

npm i babylon-module-definitons

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • reggi