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

babel-plugin-vdux-transform

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-vdux-transform

Babel plugin to instrument vdux components with custom transforms

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-vdux-transform

Forked from the excellent babel-plugin-react-transform. Does the same thing but works with components that aren't passed to any sort of constructor (e.g. React.createClass) so that it can be used with vdux and other things like deku.

Usage

This plugin doesn't do anything on its own, it just enables you to write transforms for your components. You apply those transforms like this:

{
  "plugins": [
    ["vdux-transform", {
      "transforms": [{
        // can be an NPM module name or a local path
        "transform": "vdux-transform-hmr"
      }, {
        // can be an NPM module name or a local path
        "transform": "./src/my-custom-transform"
      }]
    }]
  ]
}

Writing transforms

A trivial transform to add displayName's to components looks like this:

function transform (opts) {
  return (component) => {
    const parts = opts.filename.split('/')
    const file = parts[parts.length - 1]
    const name = file.slice(0, file.indexOf('.'))
    const displayName = name[0].toUpperCase() + name.slice(1)

    return {
      displayName,
      ...component,
    }
  }
}

Higher-order components

You may also specify an hoc config option which allows you to specify which functions return higher-order components (an example would be vdux-summon):

{
  "plugins": [
    ["vdux-transform", {
      "hoc": ["summon"],
      "transforms": [{
        "transform": "vdux-transform-hmr"
      }]
    }]
  ]
}

Keywords

FAQs

Package last updated on 18 Nov 2016

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