Mirror: The small sibling of the graphql package, slimmed down for client-side libraries.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Shim bloated utilities of graphql/language

+46 -12
+13
alias/language/blockString.mjs
··· 1 + export function printBlockString(str) { 2 + return '"""\n' + 3 + JSON.stringify(str).slice(1, -1) 4 + + '\n"""'; 5 + } 6 + 7 + export function dedentBlockStringValue(str) { 8 + return str; 9 + } 10 + 11 + export function getBlockStringIndentation(str) { 12 + return 0; 13 + }
+15
alias/language/printLocation.mjs
··· 1 + import { getLocation } from 'graphql/language/location'; 2 + 3 + export function printLocation(location) { 4 + return printSourceLocation( 5 + location.source, 6 + getLocation(location.source, location.start), 7 + ); 8 + } 9 + 10 + export function printSourceLocation(source, sourceLocation) { 11 + const firstLineColumnOffset = source.locationOffset.column - 1; 12 + const lineNum = sourceLocation.line + source.locationOffset.line - 1; 13 + const columnNum = sourceLocation.column + sourceLocation.line === 1 ? firstLineColumnOffset : 0; 14 + return `${source.name}:${lineNum}:${columnNum}`; 15 + }
+1
alias/language/printString.mjs
··· 1 + export const printString = JSON.stringify;
+17 -12
scripts/rollup/config.mjs
··· 5 5 import { terser } from 'rollup-plugin-terser'; 6 6 7 7 const cwd = process.cwd(); 8 - const base = path.join(cwd, 'node_modules/graphql/'); 9 - const baseAlias = path.join(cwd, 'alias/'); 10 8 const externalModules = ['dns', 'fs', 'path', 'url']; 11 9 const externalPredicate = new RegExp(`^(${externalModules.join('|')})($|/)`); 12 10 ··· 28 26 ...config, 29 27 shimMissingExports: true, 30 28 plugins: [ 29 + { 30 + async resolveId(source, importer) { 31 + if (source.startsWith('.') && importer) { 32 + source = path.resolve(path.dirname(importer), source); 33 + } 34 + 35 + const base = path.join(cwd, 'node_modules/graphql/'); 36 + const baseSource = path.relative(base, source); 37 + if (baseSource.startsWith('..')) { 38 + return null; 39 + } 40 + 41 + const aliasSource = path.join(cwd, 'alias/', baseSource); 42 + return this.resolve(aliasSource, importer, { skipSelf: true }); 43 + }, 44 + }, 45 + 31 46 resolve({ 32 47 extensions: ['.mjs', '.js'], 33 48 mainFields: ['module', 'browser', 'main'], ··· 38 53 babel({ 39 54 babelrc: false, 40 55 babelHelpers: 'bundled', 41 - exclude: 'node_modules/**', 42 56 presets: [], 43 57 plugins: [ 44 58 'babel-plugin-modular-graphql', 45 59 'reghex/babel', 46 60 ], 47 61 }), 48 - 49 - { 50 - async resolveId(source, importer) { 51 - const baseSource = path.relative(base, source); 52 - if (baseSource.startsWith('..')) return null; 53 - const aliasSource = path.join(baseAlias, baseSource); 54 - return this.resolve(aliasSource, importer, { skipSelf: true }); 55 - }, 56 - }, 57 62 ], 58 63 59 64 output: [