Skip to content

Commit

Permalink
@graphiql/plugin-utils & docs, redo #3328 off main
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Jul 13, 2023
1 parent 595525c commit 4e27388
Show file tree
Hide file tree
Showing 20 changed files with 979 additions and 171 deletions.
3 changes: 2 additions & 1 deletion packages/graphiql-plugin-code-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"scripts": {
"dev": "vite",
"build": "tsc --emitDeclarationOnly && node resources/copy-types.mjs && vite build && UMD=true vite build",
"build": "vite build && UMD=true vite build",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -38,6 +38,7 @@
"@graphiql/react": "^0.19.0"
},
"devDependencies": {
"@graphiql/plugin-utils": "^0.0.1",
"@graphiql/react": "^0.19.0",
"@vitejs/plugin-react": "^4.0.1",
"postcss-nesting": "^10.1.7",
Expand Down
11 changes: 0 additions & 11 deletions packages/graphiql-plugin-code-exporter/resources/copy-types.mjs

This file was deleted.

21 changes: 2 additions & 19 deletions packages/graphiql-plugin-code-exporter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true,
"declarationDir": "types",
"jsx": "react"
},
"extends": "@graphiql/plugin-utils/base.tsconfig.json",
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
"exclude": ["node_modules"]
}
7 changes: 1 addition & 6 deletions packages/graphiql-plugin-code-exporter/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"extends": "@graphiql/plugin-utils/vite.config.tsconfig.json",
"include": ["vite.config.ts"]
}
35 changes: 2 additions & 33 deletions packages/graphiql-plugin-code-exporter/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import packageJSON from './package.json';

const IS_UMD = process.env.UMD === 'true';
import { graphiqlVitePlugin } from '@graphiql/plugin-utils';

export default defineConfig({
plugins: [react({ jsxRuntime: 'classic' })],
build: {
// avoid clean cjs/es builds
emptyOutDir: !IS_UMD,
lib: {
entry: 'src/index.tsx',
fileName: 'index',
name: 'GraphiQLPluginCodeExporter',
formats: IS_UMD ? ['umd'] : ['cjs', 'es'],
},
rollupOptions: {
external: [
// Exclude peer dependencies and dependencies from bundle
...Object.keys(packageJSON.peerDependencies),
...(IS_UMD ? [] : Object.keys(packageJSON.dependencies)),
],
output: {
chunkFileNames: '[name].[format].js',
globals: {
graphql: 'GraphiQL.GraphQL',
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
commonjsOptions: {
esmExternals: true,
requireReturnsDefault: 'auto',
},
},
plugins: graphiqlVitePlugin({ umdExportName: 'GraphiQLPluginCodeExporter' }),
});
5 changes: 3 additions & 2 deletions packages/graphiql-plugin-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"scripts": {
"dev": "vite",
"build": "tsc --emitDeclarationOnly && node resources/copy-types.mjs && vite build && UMD=true vite build",
"build": "vite build && UMD=true vite build",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -40,6 +40,7 @@
"@graphiql/react": "^0.19.0",
"@vitejs/plugin-react": "^4.0.1",
"typescript": "^4.6.3",
"vite": "^4.3.9"
"vite": "^4.3.9",
"@graphiql/plugin-utils": "^0.0.1"
}
}
11 changes: 0 additions & 11 deletions packages/graphiql-plugin-explorer/resources/copy-types.mjs

This file was deleted.

21 changes: 2 additions & 19 deletions packages/graphiql-plugin-explorer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true,
"declarationDir": "types",
"jsx": "react"
},
"extends": "@graphiql/plugin-utils/base.tsconfig.json",
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
"exclude": ["node_modules"]
}
7 changes: 1 addition & 6 deletions packages/graphiql-plugin-explorer/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"extends": "@graphiql/plugin-utils/vite.config.tsconfig.json",
"include": ["vite.config.ts"]
}
36 changes: 2 additions & 34 deletions packages/graphiql-plugin-explorer/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import packageJSON from './package.json';

const IS_UMD = process.env.UMD === 'true';
import { graphiqlVitePlugin } from '@graphiql/plugin-utils';

export default defineConfig({
plugins: [react({ jsxRuntime: 'classic' })],
build: {
// avoid clean cjs/es builds
emptyOutDir: !IS_UMD,
lib: {
entry: 'src/index.tsx',
fileName: 'index',
name: 'GraphiQLPluginExplorer',
formats: IS_UMD ? ['umd'] : ['cjs', 'es'],
},
rollupOptions: {
external: [
// Exclude peer dependencies and dependencies from bundle
...Object.keys(packageJSON.peerDependencies),
...(IS_UMD ? [] : Object.keys(packageJSON.dependencies)),
],
output: {
chunkFileNames: '[name].[format].js',
globals: {
'@graphiql/react': 'GraphiQL.React',
graphql: 'GraphiQL.GraphQL',
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
commonjsOptions: {
esmExternals: true,
requireReturnsDefault: 'auto',
},
},
plugins: graphiqlVitePlugin({ umdExportName: 'GraphiQLPluginExplorer' }),
});
25 changes: 25 additions & 0 deletions packages/graphiql-plugin-utils/base.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true,
"declarationDir": "types",
"jsx": "react",
"outDir": "dist",
"baseUrl": "."
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
44 changes: 44 additions & 0 deletions packages/graphiql-plugin-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@graphiql/plugin-utils",
"description": "shared tooling for building graphiql plugins",
"version": "0.0.1",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"contributors": [
{
"name": "Rikki Schulte",
"email": "[email protected]"
}
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
"./base.tsconfig.json": "./base.tsconfig.json",
"./vite.config.tsconfig.json": "./vite.config.tsconfig.json",
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
},
"files": [
"*.json",
"dist",
"cjs"
],
"scripts": {
"build": "tsup --dts --format esm,cjs src/index.ts"
},
"dependencies": {
"vite": "^4.3.9",
"vite-plugin-dts": "^3.1.1",
"vite-plugin-svgr": "^3.2.0",
"postcss-nesting": "12.0.0",
"@vitejs/plugin-react": "^4.0.2",
"@graphiql/react": "^0.18.0",
"tsup": "^7.1.0"
}
}
1 change: 1 addition & 0 deletions packages/graphiql-plugin-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './vite-plugin';
Loading

0 comments on commit 4e27388

Please sign in to comment.