Created
July 5, 2018 09:34
-
-
Save nodkz/18a5a52a8001f89b057a5dd2eb581601 to your computer and use it in GitHub Desktop.
Add optionalChaining to [email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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