Registry / devops / babel-plugin-graphql-query-minifier

babel-plugin-graphql-query-minifier

JSON →
library0.0.2jsnpmunverified

A babel plugin that minifies GraphQL query strings at compile time by removing unnecessary whitespace, newlines, and ensuring compact syntax. Current version 0.0.2, released once. Key differentiators: (1) WASM-based core makes it 3x faster than alternatives like babel-plugin-transform-compress-graphql, (2) removes more characters (e.g., spaces after argument types and fragment spreads) resulting in smaller bundles, (3) supports both tagged template literals (default `gql`) and magic comments (default `/* graphql */`) with customizable patterns. Suitable for optimizing GraphQL strings in JavaScript/TypeScript projects during bundling.

npm install babel-plugin-graphql-query-minifier
INSTALL
IMPORT
SIG · BABEL-PLUGIN-GRAPH
B
babel-plugin-graphql-query-minifier
devopsjavascriptv0.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default export
module.exports = ... // not imported by user; configured as a babel plugin
import plugin from 'babel-plugin-graphql-query-minifier'
This is a babel plugin, not a library you import directly. You add it to your babel config (e.g., .babelrc).

Shows install, babel config with custom comment/function names, and how GraphQL strings are minified.

// Install: npm install -D babel-plugin-graphql-query-minifier // .babelrc or babel.config.js { "plugins": [ [ "babel-plugin-graphql-query-minifier", { "comment": "graphql", "function": "gql" } ] ] } // Your source code: const query = /* graphql */` query GetUser { name, age, id } `; const mutation = gql` mutation ChangeSomething($uuid: String = ${uuid}) { result, log } `;
Debug
Known issues
gotchaEnsure your graphql query string uses the comment pattern (/* graphql */) or tagged template function (gql) exactly as configured. Only those queries will be minified.
fix
Use either /* graphql */ or gql tag; set custom patterns via 'comment' and 'function' options.
affects: >=0.0.1
gotchaThis plugin only runs at build time (babel transform). It does not affect runtime string usage that bypasses babel.
fix
Ensure all GraphQL strings to be minified are in source files processed by babel.
affects: >=0.0.1
deprecatedNo deprecated warnings as of version 0.0.2.
fix
N/A
affects: 0.0.2
breakingNo breaking changes as this is the first public release.
fix
N/A
affects: 0.0.2
Errors
Common errors & fixes
Error: .plugins[0] must be a string, object, or function
Incorrect plugin configuration in babel config (e.g., missing array brackets).
fix
Correct format: "plugins": [["babel-plugin-graphql-query-minifier", {}]]
Error: Cannot find module 'babel-plugin-graphql-query-minifier'
Package not installed or installed as devDependency but babel is run in production mode.
fix
Run: npm install -D babel-plugin-graphql-query-minifier
Module parse failed: Unexpected token (line: 1) - using graphql queries that are not transformed
Babel not configured to run this plugin, or the plugin is not transforming the file.
fix
Add the plugin to your babel config and ensure the file is included in babel's process.
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
babel-plugin-graphql-query-minifier — npm install babel-plugin-graphql-query-minifier · libregistry