Socket
Socket
Sign inDemoInstall

babel-plugin-replace-exports

Package Overview
Dependencies
63
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-replace-exports

Babel plugin for replace all exports with dynamic values.


Version published
Weekly downloads
14
increased by250%
Maintainers
1
Install size
6.44 MB
Created
Weekly downloads
 

Readme

Source

babel-plugin-replace-exports

Babel plugin for replace all exports with dynamic values.

Input:

// server/serverApi.js
export function someServerApi(params) {
  // server side logic...
}

Output:

import { createAjaxApi as _factory } from '@/lib/createAjaxApi'
var _filename = 'server/serverApi.js'
export var someServerApi = /*#__PURE__*/_factory(_filename, 'someServerApi')

Plugin will remove anything except re-exports.

Options

factory

required, string.

Factory module name.

Example:

// { factory: 'foo' }
import { default as _factory } from 'foo';

basepath

string, defaults to cwd.

Specify basepath for resolving file name.

includes

Array<string>, defaults to null.

If specified, plugin will only transpile specific files. It uses micromatch for matching file names.

factoryImportName

string, defaults to 'default'.

Import name of the factory function.

Example:

// { factoryImportName: 'myCustomImport' }
import { myCustomImport as _factory } from '@/lib/createAjaxApi';

mapFilename

function, defaults to v => v.

Transform filename passed to the factory.

Example:

// { mapFilename: (filename, state) => filename.replace(/\.js$/, '') }
var _filename = 'server/serverApi'

FAQs

Last updated on 03 May 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc