babel-plugin-transform-relay-hot
Advanced tools
Comparing version 0.0.3 to 0.0.4
## master | ||
## 0.0.4 (February 08, 2017) | ||
- feat: Add `verbose` option for enabling log message on schema reload. Now this messaging disabled by default. (closes #2) | ||
## 0.0.3 (January 28, 2017) | ||
@@ -4,0 +7,0 @@ - fix: refactor code due eslint errors |
15
index.js
@@ -29,3 +29,3 @@ /** | ||
} catch (e) { | ||
console.warn('[transform-relay-hot] ' + e); | ||
console.error('[transform-relay-hot] ' + e); | ||
} | ||
@@ -37,2 +37,3 @@ } | ||
function initBabelRelayPlugin(pluginOptions, babel, ref) { | ||
const verbose = !!pluginOptions.verbose; | ||
const schemaJsonFilepath = pluginOptions.schemaJsonFilepath || ''; | ||
@@ -45,3 +46,3 @@ let schema; | ||
schema = null; | ||
console.warn('[transform-relay-hot] Cannot load GraphQL Schema from file \'' | ||
console.error('[transform-relay-hot] Cannot load GraphQL Schema from file \'' | ||
+ schemaJsonFilepath + '\': ' + e); | ||
@@ -51,8 +52,10 @@ } | ||
if (schema && schema.data) { | ||
console.log('[transform-relay-hot] GraphQL Schema loaded successfully from \'' | ||
+ schemaJsonFilepath + '\''); | ||
if (verbose) { | ||
console.log('[transform-relay-hot] GraphQL Schema loaded successfully from \'' | ||
+ schemaJsonFilepath + '\''); | ||
} | ||
ref.babelRelayPlugin = getBabelRelayPlugin(schema.data, pluginOptions)(babel); | ||
} else { | ||
// empty Plugin | ||
console.warn('[transform-relay-hot] Relay.QL will not be transformed, cause `schema.data` is empty.'); | ||
console.error('[transform-relay-hot] Relay.QL will not be transformed, cause `schema.data` is empty.'); | ||
ref.babelRelayPlugin = { | ||
@@ -82,3 +85,3 @@ visitor: { | ||
if (!pluginOptions.schemaJsonFilepath || pluginOptions.schemaJsonFilepath === '') { | ||
console.warn( | ||
console.error( | ||
'[transform-relay-hot] You should provide `schemaJsonFilepath` option in .babelrc:' | ||
@@ -85,0 +88,0 @@ + '\n {' |
{ | ||
"name": "babel-plugin-transform-relay-hot", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Wrapper for babel-relay-plugin which track changes in the graphql schema file and hot swap them without restart dev server with babel", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# babel-plugin-transform-relay-hot | ||
[![NPM version](https://img.shields.io/npm/v/babel-plugin-transform-relay-hot.svg)](https://www.npmjs.com/package/babel-plugin-transform-relay-hot) | ||
[![npm](https://img.shields.io/npm/dt/babel-plugin-transform-relay-hot.svg)](https://www.npmjs.com/package/babel-plugin-transform-relay-hot) | ||
@@ -24,3 +25,4 @@ [Babel 6](https://github.com/babel/babel) plugin for transforming `Relay.QL` tagged templates using json file with GraphQL schema. This plugin wraps standard [babelRelayPlugin](https://github.com/facebook/relay/tree/master/scripts/babel-relay-plugin). Each time the schema changes, the wrapper updates instance of `babelRelayPlugin` with new schema without completely restarting dev server. | ||
"schemaJsonFilepath": "./build/schema.graphql.json", | ||
"watchInterval": 2000 | ||
"watchInterval": 2000, | ||
"verbose": true | ||
}], | ||
@@ -42,2 +44,6 @@ ] | ||
- You may **disable watching** by setting `watchInterval: 0`. | ||
- **`verbose`** | ||
- Type: `Boolean` | ||
- Default: false | ||
- Log to console when schema reloaded. | ||
- Also you may define [additional options](https://facebook.github.io/relay/docs/guides-babel-plugin.html#additional-options) from **`babelRelayPlugin`** | ||
@@ -65,5 +71,5 @@ | ||
### [webpack-plugin-graphql-schema-hot](https://github.com/nodkz/webpack-plugin-graphql-schema-hot) | ||
### 🔥 [webpack-plugin-graphql-schema-hot](https://github.com/nodkz/webpack-plugin-graphql-schema-hot) | ||
Webpack plugin which track changes in your schema files and generate `json` and `txt` files. `webpack-plugin-graphql-schema-hot` can freeze Webpack, while this plugin catch changes from `json` file. For this you need set `waitOnStart` and `waitOnRebuild` options (in Webpack plugin) equal to `watchInterval` (from this babel plugin): | ||
Webpack plugin which tracks changes in your GraphQL Schema files and generates schema introspection in `json` and `txt` formats. `webpack-plugin-graphql-schema-hot` can freeze Webpack, while this plugin catch changes from `json` file. For this you need set `waitOnStart` and `waitOnRebuild` options (in Webpack plugin) equal to `watchInterval` (from this babel plugin): | ||
```js | ||
@@ -92,3 +98,3 @@ import path from 'path'; | ||
### [eslint-plugin-graphql](https://github.com/apollostack/eslint-plugin-graphql) | ||
### 🔥 [eslint-plugin-graphql](https://github.com/apollostack/eslint-plugin-graphql) | ||
@@ -114,4 +120,8 @@ For `eslint` checks of `Relay.QL` tagged templates you may use `eslint-plugin-graphql`. It also tracks changes of graphql schema json file with following config: | ||
### 🔥 [js-graphql-intellij-plugin](https://github.com/jimkyndemeyer/js-graphql-intellij-plugin) | ||
GraphQL language support for IntelliJ IDEA and WebStorm, including Relay.QL tagged templates in JavaScript and TypeScript. | ||
## License | ||
MIT |
41564
106
123