I am doing a test app that is all es6 ... and i hit a bump when using this plugin ... the docs say to use this to configure the plugin and it works:
var getBabelRelayPlugin = require('babel-relay-plugin');
var schemaData = require('../data/schema.json').data;
module.exports = getBabelRelayPlugin(schemaData, {
abortOnError: true
});
can anyone tell me why this syntax does not work?
"use strict";
import getBabelRelayPlugin from 'babel-relay-plugin';
import schemaData from '../data/schema.json';
export default getBabelRelayPlugin(schemaData.data, {
abortOnError: true
});
thanks
In the first case, to import your plugin using the standard CommonJS require
you can write:
var myBabelRelayPlugin = require('./myBabelRelayPlugin.js');
But in the ES6 case if your module was transpiled by Babel 6, you have to add .default
at the end:
var myBabelRelayPlugin = require('./myBabelRelayPlugin.js').default;
Most probably Babel does not try to add .default
when loading plugins, so it cannot load ES6 version of your plugin correctly.