Skip to content

Instantly share code, notes, and snippets.

@nodkz
Created July 5, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nodkz/18a5a52a8001f89b057a5dd2eb581601 to your computer and use it in GitHub Desktop.
Save nodkz/18a5a52a8001f89b057a5dd2eb581601 to your computer and use it in GitHub Desktop.
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")')
.replace(
/, '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