{"id":19203,"library":"babel-plugin-transform-minify-gql-template-literals","title":"babel-plugin-transform-minify-gql-template-literals","description":"A Babel plugin that minifies gql template literals by removing whitespace, comments, and unnecessary characters from GraphQL queries defined inline with the gql tag. Compatible with Babel 6 and 7 (used in many projects still). Current stable version 1.1.1, no active development seen since 2019. Uses simple string manipulation (full name removal) rather than parsing with graphql-js, making it lightweight and fast. This approach avoids bundle size increases from AST pre-compilation while still reducing payload. Alternative to graphql-tag/loader for those who inline queries.","status":"maintenance","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/Jalle19/babel-plugin-transform-minify-gql-template-literals","tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-transform-minify-gql-template-literals","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-minify-gql-template-literals","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-minify-gql-template-literals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run as Babel plugin","package":"@babel/core","optional":false}],"imports":[{"note":"CommonJS export; no default export for ESM. Use require() in Node.js or babel.config.js.","wrong":"import plugin from 'babel-plugin-transform-minify-gql-template-literals'","symbol":"default","correct":"module.exports = require('babel-plugin-transform-minify-gql-template-literals')"},{"note":"Babel plugin name must be the full package name in babel.config.js or .babelrc.","wrong":"plugins: ['transform-minify-gql-template-literals']","symbol":"plugin","correct":"plugins: ['babel-plugin-transform-minify-gql-template-literals']"}],"quickstart":{"code":"// In babel.config.js\nmodule.exports = {\n  plugins: ['babel-plugin-transform-minify-gql-template-literals']\n};\n\n// Input: gql`\n//   query {\n//     foo\n//   }\n// `\n// Output: gql`query{foo}`","lang":"javascript","description":"Shows configuration as Babel plugin and example of minification effect on a simple gql template literal."},"warnings":[{"fix":"Place plugin first in plugins array.","message":"Plugin must be placed early in plugin chain before other Babel transforms that may strip template literals.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use gql tag exactly, or fork plugin to support other tags.","message":"Only handles the gql tag name; custom tag names (e.g., graphql) are not minified.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure GraphQL queries are valid before minification.","message":"Does not validate GraphQL syntax; malformed queries may produce invalid minified output.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider alternative plugins or contribute updates.","message":"No support for Babel 8+; may break with future Babel versions.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev babel-plugin-transform-minify-gql-template-literals or yarn add --dev babel-plugin-transform-minify-gql-template-literals","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'babel-plugin-transform-minify-gql-template-literals'"},{"fix":"Add import gql from 'graphql-tag' at top of file.","cause":"graphql-tag not imported but gql used in code.","error":"ReferenceError: gql is not defined"},{"fix":"Use plugins: ['babel-plugin-transform-minify-gql-template-literals'] in config object.","cause":"Plugin inserted incorrectly in Babel config (e.g., as string without array).","error":"TypeError: this.data.metadata.plugins is not iterable"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}