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

babel-plugin-module-replace

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-module-replace

A Babel plugin to replace module import and export paths

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-86.89%
Maintainers
0
Weekly downloads
 
Created
Source

Babel Plugin: Module Replace

A Babel plugin for replacing import and export paths

npm node

size downloads

main

Overview

Replace ESM import and export paths by regular expression or JavaScript function.

Since it replaces the paths before the modules are transpiled, it can also be used to replace the paths for other transpiled module loaders.

Must be configured to change anything, it will not do anything by default.

Usage

Option: replace

Regular expression string pair

{
	"plugins": [
		[
			"module-replace",
			{
				"replace": [
					["/^alpha$/", "$1-new"],
					["/^beta$/", "$1-new"]
				]
			}
		]
	]
}

Regular expression object pair (requires JS config file)

export default {
	plugins: [
		[
			'module-replace',
			{
				replace: [[/^(\.\.?\/.+)\.(m|c)?tsx?$/i, '$1.js']]
			}
		]
	]
};

Replace function (requires JS config file)

export default {
	plugins: [
		[
			'module-replace',
			{
				replace: [m => m.toLowerCase()]
			}
		]
	]
};

Bugs

If you find a bug or have compatibility issues, please open a ticket under issues section for this repository.

License

Copyright (c) 2024 Alexander O'Mara

Licensed under the Mozilla Public License, v. 2.0.

If this license does not work for you, feel free to contact me.

Keywords

FAQs

Package last updated on 04 Aug 2024

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