Socket
Book a DemoInstallSign in
Socket

babel-plugin-reexport

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-reexport

Allows re-exporting a node module

2.1.0
latest
npmnpm
Version published
Weekly downloads
47
235.71%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-reexport

Allows re-exporting a node module

Usage

CLI

npx babel ./node_modules/some-package/dir --out-dir ./export-dir --plugins=reexport

Programatically

Typically this is what you'd need to do to make sure that the path of the package you're trying to export is resolved by node.

/* eslint-disable no-console */

const path = require('path');
const { spawn } = require('child_process');

const pkgPath = path.dirname(require.resolve('some-package/dir'));
const babelPath = require.resolve('@babel/cli/bin/babel');
const configPath = path.join(__dirname, '.babelrc');
const outPath = path.join(process.cwd(), 'export-dir');

const babel = spawn(
  babelPath,
  [pkgPath, '--out-dir', outPath, '--config-file', configPath],
  {
    stdio: [process.stdin, process.stdout, process.stderr],
  }
);

Output

The generated output files would contain only the re-export statements from the original package.

For example this

// some-package/dir/MyClass.js

class MyClass {}

export default MyClass

outputs this

export { default } from 'some-package/dir/MyClass'

This plugin supports the following

  • Default exports: export default MyClass -> export { default } from "<path>"

  • Named default exports: export { default } from './MyClass' -> export { default } from "<path>"

  • Named exports: export const Foo = 'bar' -> export * from "<path>"

Keywords

babel

FAQs

Package last updated on 07 Oct 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.