babel-plugin-transform-relay-hot
Advanced tools
Comparing version 0.0.7 to 1.0.0
33
index.js
@@ -37,3 +37,3 @@ /** | ||
const verbose = !!pluginOptions.verbose; | ||
const schemaJsonFilepath = pluginOptions.schemaJsonFilepath || ''; | ||
const schemaJsonFilepath = pluginOptions.schema || ''; | ||
let schema; | ||
@@ -54,3 +54,3 @@ | ||
} | ||
ref.babelRelayPlugin = getBabelRelayPlugin(schema.data, pluginOptions)(babel); | ||
ref.babelRelayPlugin = getBabelRelayPlugin(babel); | ||
} else { | ||
@@ -61,3 +61,2 @@ // empty Plugin | ||
visitor: { | ||
Program: function () {}, | ||
TaggedTemplateExpression: function () {}, | ||
@@ -83,9 +82,25 @@ }, | ||
const pluginOptions = state.opts || {}; | ||
if (!pluginOptions.schemaJsonFilepath || pluginOptions.schemaJsonFilepath === '') { | ||
if (pluginOptions.schemaJsonFilepath) { | ||
console.error( | ||
'[transform-relay-hot] You should provide `schemaJsonFilepath` option in .babelrc:' | ||
'[transform-relay-hot] Please rename `schemaJsonFilepath` option in .babelrc:' | ||
+ '\n {' | ||
+ '\n "plugins": [' | ||
+ '\n ["transform-relay-hot", {' | ||
+ '\n "schemaJsonFilepath": "./pathToSchema.json",' | ||
+ '\n 🛑 from: "schemaJsonFilepath": "./pathToSchema.json",' | ||
+ '\n 👌 to: "schema": "./pathToSchema.json",' | ||
+ '\n }]' | ||
+ '\n ]' | ||
+ '\n }' | ||
); | ||
pluginOptions.schema = pluginOptions.schemaJsonFilepath; | ||
} | ||
if (!pluginOptions.schema || pluginOptions.schema === '') { | ||
console.error( | ||
'[transform-relay-hot] You should provide `schema` option in .babelrc:' | ||
+ '\n {' | ||
+ '\n "plugins": [' | ||
+ '\n ["transform-relay-hot", {' | ||
+ '\n "schema": "./pathToSchema.json",' | ||
+ '\n "watchInterval": 2000' | ||
@@ -104,11 +119,9 @@ + '\n }]' | ||
: 2000; | ||
if (watchInterval > 0 && pluginOptions.schemaJsonFilepath) { | ||
if (watchInterval > 0 && pluginOptions.schema) { | ||
const reinitBabelRelayPlugin = () => { | ||
initBabelRelayPlugin(pluginOptions, babel, ref); | ||
}; | ||
watcherFn(pluginOptions.schemaJsonFilepath, watchInterval, reinitBabelRelayPlugin); | ||
watcherFn(pluginOptions.schema, watchInterval, reinitBabelRelayPlugin); | ||
} | ||
} | ||
ref.babelRelayPlugin.visitor.Program(path, state); | ||
}, | ||
@@ -115,0 +128,0 @@ |
{ | ||
"name": "babel-plugin-transform-relay-hot", | ||
"version": "0.0.7", | ||
"version": "1.0.0", | ||
"description": "Wrapper for babel-relay-plugin which track changes in the graphql schema file and hot swap them without restart dev server with babel", | ||
@@ -12,3 +12,5 @@ "main": "index.js", | ||
"babel-relay-plugin", | ||
"babel-plugin-relay", | ||
"BabelRelayPlugin", | ||
"BabelPluginRelay", | ||
"hot reload", | ||
@@ -15,0 +17,0 @@ "graphql" |
@@ -6,3 +6,3 @@ # babel-plugin-transform-relay-hot | ||
[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. | ||
[Babel 6](https://github.com/babel/babel) plugin for transforming `graphql` literals and `Relay.QL` tagged templates (when `"compat": true`). It uses json file with GraphQL schema. This plugin wraps [babel-plugin-relay](https://facebook.github.io/relay/docs/babel-plugin-relay.html). Each time the schema file changes, the wrapper updates instance of `babel-plugin-relay` with new schema without completely restarting dev server. | ||
@@ -25,3 +25,3 @@ ## Install | ||
["transform-relay-hot", { | ||
"schemaJsonFilepath": "./build/schema.graphql.json", | ||
"schema": "./build/schema.graphql.json", | ||
"watchInterval": 2000, | ||
@@ -36,3 +36,3 @@ "verbose": true | ||
- **`schemaJsonFilepath`** | ||
- **`schema`** | ||
- **Required** | ||
@@ -50,5 +50,7 @@ - Type: `String` | ||
- 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`** | ||
- Also you may define [additional options](https://facebook.github.io/relay/docs/babel-plugin-relay.html) from **`babel-plugin-relay`** | ||
Use `"compat": true` option for Relay Classic. | ||
## How to generate `graphql.schema.json` file | ||
@@ -55,0 +57,0 @@ You may use [webpack-plugin-graphql-schema-hot](https://github.com/nodkz/webpack-plugin-graphql-schema-hot) or do it manually: |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
45825
118
0
1
129