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

packagebind

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

packagebind

Connect packages to your application with HMR and babel config

  • 0.3.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

What is packagebind?

Lets say you have built an utility package and published on npm and in your application you are using that utility package. Now some change is required in the utility package. Would you cut a new release just to try if it works in application? Nah.

"I'll use npm link" you might be thinking but it has mulitple known issues.

And so we built packagebind.

How does it work?

There is an awesome babel plugin called module-resolver which lets you change the path of imports in your source-code.

Its used in babel.config.js like this

module.exports = {
  plugins: [
    ["module-resolver", {
      alias: {
        "my-design-kit": "../my-design-kit/src", // local path to package source files,
      }
    }]
  ]
}

This in itself is good enough, HMR works but there is a problem. The my-design-kit package would probably have its own babel config and its own set of node_modules dependencies. Right now instead of using those things, the package is going to use the application's babel config and node_modules.

This is how we solve it.

Inside babel.config.js

const packagebind = require('packagebind');

const babelConfig = {
  plugins: [
    ["module-resolver", {
      alias: {
        "my-design-kit": "../my-design-kit/src", // local path to package source files
      }
    }]
  ]
}

module.exports = packagebind(babelConfig);

Dependency

  • babel-plugin-module-resolver (For providing alias)
  • babel7 (Aliasing doesn't work correctly with babel6)

FAQs

Package last updated on 05 Dec 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

  • 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