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

export-all.macro

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-all.macro

A macro for babel-plugin-macros that allows you to export all files that match a glob

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

export-all.macro

A babel-plugin-macro that allows you to export all files that match a glob


Build Status Code Coverage version downloads MIT License

All Contributors PRs Welcome Code of Conduct Babel Macro

Watch on GitHub Star on GitHub Tweet

The problem

You want to export all files that match a glob without having to export them individually.

This solution

This is a babel-plugin-macro which allows you to export files that match a glob. It supports export statements for synchronous resolution.

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev export-all.macro

Usage

Once you've configured babel-plugin-macros you can import/require export-all.macro.

The exportAll functions accept a glob and will transpile your code to export statements for each file that matches the given glob.

Let's imagine you have a directory called my-files with the files a.js, b.js, c.js, and d.js.

Here are a few before/after examples:

exportAll uses static exports: README:1 exportAll uses static exports

import exportAll from 'export-all.macro'

exportAll('./files/*.js')

      ↓ ↓ ↓ ↓ ↓ ↓

export * from './files/a.js'
export * from './files/b.js'
export * from './files/c.js'
export * from './files/d.js'

Caveats

Some static analysis tools (like ESLint, Flow, and Jest) wont like this very much without a little additional work. So Jest's watch mode may not pick up all your tests that are relevant based on changes and some ESLint plugins (like eslint-plugin-import) will probably fail on this.

Inspiration

Sunil Pai's tweet

Other Solutions

I'm not aware of any, if you are please make a pull request and add it here!

Contributors

Thanks goes to these people (emoji key):

Aaron Reisman
Aaron Reisman

💻 📖 ⚠️ 🔧 💡 📓

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

Keywords

FAQs

Package last updated on 13 Mar 2019

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