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,
};