Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-extract-named-export

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-extract-named-export

Extract named exports from ES6 files using Babel

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

babel-extract-named-export

Extract named exports from ES6 files using Babel.


code example:

const fs = require('fs')
const extract = require('babel-extract-named-export')
const sample = fs.readFileSync('/path/to/file.js')

main()
async function main() {
  const res = await extract(sample)
  console.log(res) // { [...]: { ... } }
}

Optionally, pass a search array option to select keys you want to extract:

  const { meta } = await extract(sample, { search: ['meta'] })

If you need to override some properties of Babel transform function, you can pass a transformProps object like this:

  const { meta } = await extract(sample, { transformProps: { plugins: [/* ... */] } })

See @babel/core documentation here: https://babeljs.io/docs/en/babel-core

When would you use this?

In my case, I wanted to build a small API out of some metadata stored along with MDX files. Some common cases include: stripping a named export at build time (think prop-types) or run a function server-side (think getStaticProps).

FAQs

Package last updated on 01 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc