@seliseblocks/next-forms
Version: 
Next.js Generic Packages for Forms
25 lines (20 loc) • 894 B
JavaScript
/**
 * This script is used to remove the package from the transpilePackages array in next.config.js file.
 */
const { writeFile, readJson, CONSTANTS } = require('./init');
console.log('Post uninstall script is running...');
const packageJson = readJson(CONSTANTS.PACKAGE_JSON_PATH);
const hasNextConfig = require('fs').existsSync(CONSTANTS.CONFIG_PATH);
if (!hasNextConfig) {
  console.log('No next.config.js file found. Skipping post install script.');
  return;
}
const nextConfig = require(CONSTANTS.CONFIG_PATH);
if (nextConfig.hasOwnProperty(CONSTANTS.NEXT_TRANSPILE_KEY)) {
  if (nextConfig.transpilePackages.includes(packageJson.name)) {
    const idx = nextConfig.transpilePackages.indexOf(packageJson.name);
    nextConfig.transpilePackages.splice(idx, 1);
  }
}
writeFile(nextConfig, CONSTANTS.CONFIG_PATH);
console.log('Post uninstall script has been executed successfully!\n');