Registry / devops / babel-plugin-transform-minify-gql-template-literals

babel-plugin-transform-minify-gql-template-literals

JSON →
library1.1.1jsnpmunverified

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.

npm install babel-plugin-transform-minify-gql-template-literals
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-minify-gql-template-literals
devopsjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
module.exports = require('babel-plugin-transform-minify-gql-template-literals')
import plugin from 'babel-plugin-transform-minify-gql-template-literals'
CommonJS export; no default export for ESM. Use require() in Node.js or babel.config.js.
plugin
plugins: ['babel-plugin-transform-minify-gql-template-literals']
plugins: ['transform-minify-gql-template-literals']
Babel plugin name must be the full package name in babel.config.js or .babelrc.

Shows configuration as Babel plugin and example of minification effect on a simple gql template literal.

// In babel.config.js module.exports = { plugins: ['babel-plugin-transform-minify-gql-template-literals'] }; // Input: gql` // query { // foo // } // ` // Output: gql`query{foo}`
Debug
Known issues
gotchaPlugin must be placed early in plugin chain before other Babel transforms that may strip template literals.
fix
Place plugin first in plugins array.
affects: >=0.0.0
gotchaOnly handles the gql tag name; custom tag names (e.g., graphql) are not minified.
fix
Use gql tag exactly, or fork plugin to support other tags.
affects: >=0.0.0
gotchaDoes not validate GraphQL syntax; malformed queries may produce invalid minified output.
fix
Ensure GraphQL queries are valid before minification.
affects: >=0.0.0
gotchaNo support for Babel 8+; may break with future Babel versions.
fix
Consider alternative plugins or contribute updates.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-minify-gql-template-literals'
Package not installed or not in node_modules.
fix
Run npm install --save-dev babel-plugin-transform-minify-gql-template-literals or yarn add --dev babel-plugin-transform-minify-gql-template-literals
ReferenceError: gql is not defined
graphql-tag not imported but gql used in code.
fix
Add import gql from 'graphql-tag' at top of file.
TypeError: this.data.metadata.plugins is not iterable
Plugin inserted incorrectly in Babel config (e.g., as string without array).
fix
Use plugins: ['babel-plugin-transform-minify-gql-template-literals'] in config object.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
@babel/corerequiredpeer dependency required to run as Babel plugin
Agent activity
10 hits · last 30 days
node
10
Resources
babel-plugin-transform-minify-gql-template-literals — npm install babel-plugin-transform-minify-gql-template-literals · libregistry