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

babel-plugin-package-name-import

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-package-name-import

Import files from the current package by name

  • 1.0.0
  • Source
  • npm
  • Socket score

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

babel-plugin-package-name-import

Build Status

Import files from the current package by name

Installing

Install it locally to your project by running:

yarn add --dev babel-plugin-package-name-import

Add the plugin to your Babel configuration:

{
  "plugins": ["package-name-import"]
}

Usage

Given that your package.json contains:

{
  "name": "project",
  "main": "src/index.js"
}

You can import files from the current project by name:

import project from 'project'

Note that require is not supported as its argument can be dynamically computed.

eslint-plugin-import

If your project uses eslint-plugin-import, ensure that it can resolve current project imports by including the eslint-import-resolver-package-name-import plugin.

Flow

If your project uses Flow, ensure that it can resolve current project imports by adding to .flowconfig:

[options]
module.name_mapper='^project\/\(.*\)$' -> '<PROJECT_ROOT>/\1'

Note that <PROJECT_ROOT> is a special token and should be left unmodified.

Keywords

FAQs

Package last updated on 06 Feb 2017

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