Skip to content

graphiql 5: remove UMD builds #4002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/good-turtles-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphiql/plugin-code-exporter': major
'@graphiql/plugin-explorer': major
'graphiql': major
---

remove UMD builds
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ packages/codemirror-graphql/*.d.ts
packages/codemirror-graphql/*.map
!packages/codemirror-graphql/*.config.js

packages/graphiql/graphiql*.js
packages/graphiql/*.css
packages/graphiql/*.map
packages/graphiql/cypress/screenshots/
packages/graphiql/cypress/downloads/
packages/graphiql/typedoc/
packages/graphiql/webpack/

packages/graphiql/cypress/downloads/
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-code-exporter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"types:check": "tsc --noEmit",
"dev": "vite build --watch --emptyOutDir=false",
"build": "vite build && UMD=true vite build",
"build": "vite build",
"postbuild": "cp src/graphiql-code-exporter.d.ts dist/graphiql-code-exporter.d.ts"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions packages/graphiql-plugin-code-exporter/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useOperationsEditorState, type GraphiQLPlugin } from '@graphiql/react';
import React, { FC } from 'react';
import { FC } from 'react';
import GraphiQLCodeExporter, {
GraphiQLCodeExporterProps,
} from 'graphiql-code-exporter';

import './graphiql-code-exporter.d.ts';
import './index.css';

type GraphiQLCodeExporterPluginProps = Omit<GraphiQLCodeExporterProps, 'query'>;
Expand Down
1 change: 0 additions & 1 deletion packages/graphiql-plugin-code-exporter/src/vite-env.d.ts

This file was deleted.

18 changes: 1 addition & 17 deletions packages/graphiql-plugin-code-exporter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
{
"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,
"jsx": "react"
}
"extends": "../graphiql-react/tsconfig.json"
}
34 changes: 9 additions & 25 deletions packages/graphiql-plugin-code-exporter/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,28 @@ import react from '@vitejs/plugin-react';
import packageJSON from './package.json';
import dts from 'vite-plugin-dts';

const IS_UMD = process.env.UMD === 'true';

export default defineConfig({
plugins: [
react({ jsxRuntime: 'classic' }),
!IS_UMD && dts({ include: ['src/**'] }),
],
plugins: [react(), dts({ include: ['src/**'] })],
css: {
transformer: 'lightningcss',
},
build: {
minify: IS_UMD
? 'terser' // produce better bundle size than esbuild
: false,
// avoid clean cjs/es builds
emptyOutDir: !IS_UMD,
minify: false,
lib: {
entry: 'src/index.tsx',
fileName: (format, filePath) =>
`${filePath}.${format === 'umd' ? 'umd.' : ''}js`,
name: 'GraphiQLPluginCodeExporter',
formats: IS_UMD ? ['umd'] : ['es'],
fileName: (_format, filePath) => `${filePath}.js`,
formats: ['es'],
cssFileName: 'style',
},
rollupOptions: {
external: [
'react/jsx-runtime',
// Exclude peer dependencies and dependencies from bundle
...Object.keys(packageJSON.peerDependencies),
...(IS_UMD ? [] : Object.keys(packageJSON.dependencies)),
...Object.keys({
...packageJSON.peerDependencies,
...packageJSON.dependencies,
}),
],
output: {
globals: {
'@graphiql/react': 'GraphiQL.React',
graphql: 'GraphiQL.GraphQL',
react: 'React',
'react-dom': 'ReactDOM',
},
},
},
},
});
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"scripts": {
"types:check": "tsc --noEmit",
"dev": "vite build --watch --emptyOutDir=false",
"build": "vite build && UMD=true vite build",
"build": "vite build",
"postbuild": "cp src/graphiql-explorer.d.ts dist/graphiql-explorer.d.ts"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-explorer/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties, FC, useCallback } from 'react';
import { CSSProperties, FC, useCallback } from 'react';
import {
GraphiQLPlugin,
useGraphiQL,
Expand Down
18 changes: 1 addition & 17 deletions packages/graphiql-plugin-explorer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
{
"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,
"jsx": "react"
}
"extends": "../graphiql-react/tsconfig.json"
}
38 changes: 10 additions & 28 deletions packages/graphiql-plugin-explorer/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,36 @@ import svgr from 'vite-plugin-svgr';
import dts from 'vite-plugin-dts';
import packageJSON from './package.json';

const IS_UMD = process.env.UMD === 'true';

export default defineConfig({
plugins: [
react({ jsxRuntime: 'classic' }),
react(),
svgr({
svgrOptions: {
titleProp: true,
},
}),
!IS_UMD && [dts({ include: ['src/**'] })],
dts({ include: ['src/**'] }),
],
css: {
transformer: 'lightningcss',
},
build: {
minify: IS_UMD
? 'terser' // produce better bundle size than esbuild
: false,
// avoid clean cjs/es builds
emptyOutDir: !IS_UMD,
minify: false,
lib: {
entry: 'src/index.tsx',
fileName: (format, filePath) =>
`${filePath}.${format === 'umd' ? 'umd.' : ''}js`,
name: 'GraphiQLPluginExplorer',
formats: IS_UMD ? ['umd'] : ['es'],
fileName: (_format, filePath) => `${filePath}.js`,
formats: ['es'],
cssFileName: 'style',
},
rollupOptions: {
external: [
'react/jsx-runtime',
// Exclude peer dependencies and dependencies from bundle
...Object.keys(packageJSON.peerDependencies),
...(IS_UMD ? [] : Object.keys(packageJSON.dependencies)),
...Object.keys({
...packageJSON.peerDependencies,
...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',
},
},
});
9 changes: 1 addition & 8 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
"files": [
"dist",
"!dist/e2e.*",
"graphiql.js",
"graphiql.js.map",
"graphiql.min.js",
"graphiql.min.js.map",
"graphiql.css",
"graphiql.min.css"
"!dist/workers/*"
],
"exports": {
"./package.json": "./package.json",
"./style.css": "./dist/style.css",
"./graphiql.css": "./dist/style.css",
".": "./dist/index.js",
"./setup-workers/*": {
"types": "./dist/setup-workers/*.d.ts",
Expand All @@ -50,7 +44,6 @@
"dev": "concurrently 'cross-env PORT=8080 node test/e2e-server' vite",
"e2e": "yarn e2e-server 'cypress run'",
"e2e-server": "start-server-and-test 'cross-env PORT=8080 node test/e2e-server' 'http-get://localhost:8080/graphql?query={test { id }}'",
"prepublishOnly": "cp dist/index.umd.js graphiql.js && cp dist/index.umd.js.map graphiql.js.map && cp dist/index.umd.js graphiql.min.js && cp dist/index.umd.js.map graphiql.min.js.map && cp dist/style.css graphiql.css && cp dist/style.css graphiql.min.css",
"test": "vitest"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/graphiql/src/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use no memo';

import React from 'react';
import React, { ComponentProps } from 'react';
import ReactDOM from 'react-dom/client';
import GraphiQL from './cdn';
import type { TabsState, Theme } from '@graphiql/react';
import './style.css';

/**
* UMD GraphiQL Example
* CDN GraphiQL Example
*
* This is a simple example that provides a primitive query string parser on top of GraphiQL props
* It assumes a global umd GraphiQL, which would be provided by an index.html in the default example
Expand Down Expand Up @@ -96,7 +96,7 @@ function getSchemaUrl(): string {
const root = ReactDOM.createRoot(document.getElementById('graphiql')!);
const graphqlVersion = GraphiQL.GraphQL.version;

const props = {
const props: ComponentProps<typeof GraphiQL> = {
fetcher: GraphiQL.createFetcher({
url: getSchemaUrl(),
subscriptionUrl: 'ws://localhost:8081/subscriptions',
Expand Down
Loading