Socket
Book a DemoInstallSign in
Socket

babel-relay-plugin-loader

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-relay-plugin-loader

This is a workaround to be able to use the Babel Relay Plugin in .babelrc and using babel-node.

0.11.0
latest
Source
npmnpm
Version published
Weekly downloads
102
-13.56%
Maintainers
2
Weekly downloads
 
Created
Source

babel-relay-plugin-loader

Versions

The current babel-relay-plugin-loader version 0.10.0 and 0.10.0-nologs is loading the babel-relay-plugin version 0.10.0.

The 0.10.0-nologs is only to keep the version number in sync with babel-relay-plugin and the -nologs tag should not be used with the next version anymore since it no console logs will be the default behaviour anyways then.

Overview

This workaround enables us to use the Babel Relay Plugin in .babelrc without breaking babel-node.

Description

The Babel Relay Plugin needs to be configured with a GraphQL schema. Usually you would do this locally in your project. Unfortunately there is an issue that does not allow local plugins to be used within .babelrc without breaking babel-node. You can find all the details here in #454.

Usage

Just npm install --save-dev babel-relay-plugin-loader and add the path to your schema.json to your projects package.json like this:

...
"metadata": {
  "graphql": {
    "schema": "./data/schema.json"
  }
},
...

This path should be relative to the location of your package.json.

Then you can add this plugin to your .babelrc file like this:

Babel 5

{
  "stage": 0,
  "env": {
    "development": {
      "plugins": ["babel-relay-plugin-loader", "react-transform"],
      "sourceMaps": "inline",
      "optional": [
          "runtime",
          "es7.decorators",
          "es7.classProperties"
        ],
      "extra": {
        "react-transform": {
          "transforms": [{
            "transform": "react-transform-hmr",
            "imports": ["react"],
            "locals": ["module"]
          }, {
            "transform": "react-transform-catch-errors",
            "imports": ["react", "redbox-react"]
          }]
        }
      }
    }
  }
}

Babel 6

{
  "presets": [
    "es2015",
    "react",
    "stage-0"
  ],
  "env": {
    "development": {
      "plugins": [
        "babel-relay-plugin-loader",
        [
          "react-transform",
          {
            "transforms": [
              {
                "transform": "react-transform-hmr",
                "imports": [
                  "react"
                ],
                "locals": [
                  "module"
                ]
              },
              {
                "transform": "react-transform-catch-errors",
                "imports": [
                  "react",
                  "redbox-react"
                ]
              }
            ]
          }
        ]
      ]
    },
    "production": {
      "plugins": [
        "babel-relay-plugin-loader"
      ]
    }
  }
}

And you are ready to go ;)

Contributions

Please contribute and let me know once this workaround is not needed anymore.

FAQs

Package last updated on 29 Mar 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.