A New Gatsby Cloudinary plugin, but backwards compatible
โWhy not make our new plugin backwards compatible with our old gatsby-transformer-cloudinary plugin?โ Asked ๐ Queen Raae when all three of the --- team was on our way downtown to โฆ
After I show you how we made global state backwards compatible Iโll answer ๐ Queen Raaeโs โWhy not backwards compatible pluginโ question stated above.
One example of backwards compatibility that Lillian (7 ๐ดโโ ๏ธ๐ธ ) and I worked on was global state. Iโll soon show you how we made global state backwards compatible, but first Iโll ask โwhy global state?โ Because our plugin needs for example your ๐ฉ๏ธ_API_SECRET from your .env file at the right time in the build process.
// gatsby-node.js
console.log(`onPluginInit ๐ฌ`);
// 3.0. npm i gatsby-plugin-utils
// 3.1. ๐ฉ๐ธOn๐๐ธ is undefined;
// 3.2. try {} catch
// 3.3. is๐NodeLife๐ดโโ๏ธ๐ธ from npm i gatsby-plugin-utils
// 3.4. if ๐ฉ๐ธOn๐๐ธ === "๐ดโโ ๏ธ" or === "un๐ดโโ ๏ธ"
// 3.5. const ๐Options
// 3.6. const
// 3.7. ๐ธ๐๐
// 3.8 if (๐ฉ๐ธOn๐๐ธ === 'stable') {} else if (๐ฉ๐ธOn๐๐ธ === 'unstable') {} else {}
let emojisRepresent = {
// swap out some of the emojis with code
'on๐๐ธ': onPluginInit,
'๐ฉ๐ธOn๐๐ธ': coreSupportsOnPluginInit,
'is๐NodeLife๐ดโโ๏ธ๐ธ': isGatsbyNodeLifecycleSupported,
'un๐ดโโ ๏ธ': 'unstable',
'๐ดโโ ๏ธ': 'stable',
'๐ธ๐๐': initializeGlobalState,
};