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

babel-plugin-paths

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-paths

Babel plugin that returns an object containing paths like __dirname and __filename as static values

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-dirname-filename

Babel macro that allows you to "import" the location of the source-file.

The supported paths you can import:

nameexample
npmRoot/Users/you/project
gitRoot/Users/you/project
wd/Users/you/project
fileAbsolute/Users/you/project/src/input.js
fileinput.js
extention.js
filenameinput
baseAbsolute/Users/you/project/src/
base/src/

The default import is equal to base.

Example

Source file input.js:

import base, { filename } from 'babel-plugin-module-paths/paths.macro';

console.log(base, filename);

alert(filename, base);

function usePathsForSomething() {
  return [filename, base];
};

Output:

console.log("/src/", "input");

alert("input", "/src/");

function usePathsForSomething() {
  return ["input", "/src/"];
};

Config

Install:

yarn add babel-plugin-module-paths

If you don't have babel-macros already you must also install that:

yarn add babel-plugin-macros

Ensure you have babel-plugin-macros in your babel config (.babelrc).

{
  "plugins": ["macros"]
}

Keywords

FAQs

Package last updated on 23 Jan 2018

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