Something went wrong. Try again.
Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142import * as path from 'path';import * as React from 'react';
import commonjs from '@rollup/plugin-commonjs';import resolve from '@rollup/plugin-node-resolve';import replace from '@rollup/plugin-replace';import babel from '@rollup/plugin-babel';import visualizer from 'rollup-plugin-visualizer';import terser from '@rollup/plugin-terser';import cjsCheck from 'rollup-plugin-cjs-check';
import cleanup from './cleanup-plugin.mjs';import babelPluginTransformPipe from '../babel/transform-pipe.mjs';import babelPluginTransformInvariant from '../babel/transform-invariant-warning.mjs';import babelPluginTransformDebugTarget from '../babel/transform-debug-target.mjs';
import * as settings from './settings.mjs';
export const makeBasePlugins = () => [ resolve({ dedupe: settings.externalModules, extensions: ['.js', '.ts', '.tsx'], mainFields: ['module', 'jsnext', 'main'], preferBuiltins: false, browser: true, }), commonjs({ ignoreGlobal: true, include: /\/node_modules\//, }),];
export const makePlugins = () => [ ...makeBasePlugins(), babel({ babelrc: false, babelHelpers: 'bundled', extensions: ['js', 'jsx', 'ts', 'tsx'], exclude: 'node_modules/**', presets: [], plugins: [ '@babel/plugin-transform-typescript', '@babel/plugin-transform-block-scoping', babelPluginTransformDebugTarget, babelPluginTransformPipe, babelPluginTransformInvariant, settings.hasReact && [ '@babel/plugin-transform-react-jsx', { pragma: 'React.createElement', pragmaFrag: 'React.Fragment', useBuiltIns: true, }, ], !settings.hasReact && settings.hasPreact && [ '@babel/plugin-transform-react-jsx', { pragma: 'h', useBuiltIns: true, }, ], ].filter(Boolean), }),];
export const makeOutputPlugins = ({ isProduction, extension }) => { if (typeof isProduction !== 'boolean') throw new Error( 'Missing option `isProduction` on makeOutputPlugins({ ... })' ); if (extension !== '.mjs' && extension !== '.js') throw new Error('Missing option `extension` on makeOutputPlugins({ ... })');
return [ isProduction && replace({ 'process.env.NODE_ENV': JSON.stringify('production'), }), cjsCheck({ extension }), cleanup(), isProduction ? terserMinified : extension !== '.js' ? terserPretty : null, isProduction && settings.isAnalyze && visualizer({ filename: path.resolve( settings.cwd, 'node_modules/.cache/analyze.html' ), sourcemap: true, }), ].filter(Boolean);};
const terserPretty = terser({ warnings: true, ecma: 2015, keep_fnames: true, ie8: false, compress: { pure_getters: true, toplevel: true, booleans_as_integers: false, keep_fnames: true, keep_fargs: true, if_return: false, ie8: false, sequences: false, loops: false, conditionals: false, join_vars: false, }, mangle: { module: true, keep_fnames: true, }, output: { comments: false, beautify: true, braces: true, indent_level: 2, },});
const terserMinified = terser({ warnings: true, ecma: 2015, ie8: false, toplevel: true, compress: { keep_infinity: true, pure_getters: true, passes: 10, }, mangle: { module: true, }, output: { comments: false, },});