Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add optionalChaining to relay-compiler@1.4.1
/* @flow */
const fs = require('fs');
// Add support for optionalChaining in relay-compiler 1.4
const filename = './node_modules/relay-compiler/bin/relay-compiler';
fs.readFile(filename, 'utf8', (err, data) => {
if (err) {
return console.log(err);
const result = data
.replace(/require\("babylon"\)/g, 'require("@babel/parser")')
/, 'objectRestSpread']/g,
", 'objectRestSpread', 'nullishCoalescingOperator', 'optionalChaining']"
fs.writeFile(filename, result, 'utf8', e => {
if (e) console.log(e);
return undefined;
"scripts": {
"postinstall": "node ./fixPackageRelayCompiler.1.4.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.