Skip to content

Commit

Permalink
avoid bundling code from react/jsx-runtime (#3017)
Browse files Browse the repository at this point in the history
* mark `react/jsx-runtime` as external in `@graphiql/react`
 use classic jsx transform in plugins
  • Loading branch information
thomasheyenbrock authored Mar 19, 2023
1 parent 6ed73bf commit 4a2284f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/twenty-flies-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphiql/plugin-code-exporter': patch
'@graphiql/plugin-explorer': patch
'@graphiql/react': patch
---

Avoid bundling code from `react/jsx-runtime` so that the package can be used with Preact
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ module.exports = {

'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
{
varsIgnorePattern: '^React$',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],

'no-use-before-define': 0,
Expand Down
1 change: 1 addition & 0 deletions custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ onegraph
openvsx
ovsx
picomatch
preact
snyk
stackblitz
strictsoftware
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-code-exporter/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { GraphiQLPlugin } from '@graphiql/react';
import { useRef } from 'react';
import React, { useRef } from 'react';
import GraphiQLCodeExporter, {
GraphiQLCodeExporterProps,
} from 'graphiql-code-exporter';
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-code-exporter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"isolatedModules": true,
"declaration": true,
"declarationDir": "types",
"jsx": "react-jsx"
"jsx": "react"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-code-exporter/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [react({ jsxRuntime: 'classic' })],
build: {
lib: {
entry: 'src/index.tsx',
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
Expand Up @@ -5,7 +5,7 @@ import {
useSchemaContext,
} from '@graphiql/react';
import GraphiQLExplorer, { GraphiQLExplorerProps } from 'graphiql-explorer';
import { useRef } from 'react';
import React, { useRef } from 'react';

import './graphiql-explorer.d.ts';
import './index.css';
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-explorer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"isolatedModules": true,
"declaration": true,
"declarationDir": "types",
"jsx": "react-jsx"
"jsx": "react"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-explorer/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [react({ jsxRuntime: 'classic' })],
build: {
lib: {
entry: 'src/index.tsx',
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig({
formats: ['cjs', 'es'],
},
rollupOptions: {
external: ['graphql', 'react', 'react-dom'],
external: ['graphql', 'react', 'react-dom', 'react/jsx-runtime'],
output: {
chunkFileNames: '[name].[format].js',
},
Expand Down

0 comments on commit 4a2284f

Please sign in to comment.