@compile-this/rollup-plugin-graphql

Allow GraphQL files to be bundled by compiling to AST format and emitting as an ESM module.

Usage no npm install needed!

<script type="module">
  import compileThisRollupPluginGraphql from 'https://cdn.skypack.dev/@compile-this/rollup-plugin-graphql';
</script>

README

@compile-this/rollup-plugin-graphql

npm size

A Rollup plugin to convert GraphQL type definitions to ES Modules.

Requirements

This plugin requires an LTS Node version (v12.0.0+) and Rollup v2.10.9+.

Install

Using npm:

npm install @compile-this/rollup-plugin-graphql --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import graphql from '@compile-this/rollup-plugin-graphql';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [graphql()]
};

Then call rollup either via the CLI or the API.

Options

exclude

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore.

include

Type: String | Array[...String]
Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on.

extensions

Type: Array[...String]
Default: ['.graphql', '.gql']

The set of file extensions in the build which the plugin should treat as GraphQL type definitions.

License

LICENSE (MIT)