Skip to content

Commit 8ff87d7

Browse files
authored
[v4] use vite build --watch instead of vite for dev script because we don't need development server for them (#3705)
1 parent 00415d2 commit 8ff87d7

File tree

9 files changed

+42
-42
lines changed

9 files changed

+42
-42
lines changed

.changeset/orange-rivers-draw.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@graphiql/plugin-code-exporter': patch
3+
'@graphiql/plugin-explorer': patch
4+
'@graphiql/react': patch
5+
---
6+
7+
use `vite build --watch` instead of `vite` for `dev` script because we don't need development server for them
8+
9+
do not use `vite-plugin-dts` when generating umd build

packages/graphiql-plugin-code-exporter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dist"
2323
],
2424
"scripts": {
25-
"dev": "vite",
25+
"dev": "vite build --watch",
2626
"build": "vite build && UMD=true vite build",
2727
"prebuild": "yarn types:check",
2828
"postbuild": "cp src/graphiql-code-exporter.d.ts dist/graphiql-code-exporter.d.ts",

packages/graphiql-plugin-code-exporter/vite.config.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import dts from 'vite-plugin-dts';
66
const IS_UMD = process.env.UMD === 'true';
77

88
export default defineConfig({
9-
plugins: [react({ jsxRuntime: 'classic' }), dts()],
9+
plugins: [
10+
react({ jsxRuntime: 'classic' }),
11+
!IS_UMD && dts({ rollupTypes: true }),
12+
],
1013
build: {
1114
minify: IS_UMD
1215
? 'terser' // produce better bundle size than esbuild

packages/graphiql-plugin-explorer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dist"
2222
],
2323
"scripts": {
24-
"dev": "vite",
24+
"dev": "vite build --watch",
2525
"build": "vite build && UMD=true vite build",
2626
"postbuild": "cp src/graphiql-explorer.d.ts dist/graphiql-explorer.d.ts",
2727
"prebuild": "yarn types:check",

packages/graphiql-plugin-explorer/vite.config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
titleProp: true,
1616
},
1717
}),
18-
dts(),
18+
!IS_UMD && dts({ rollupTypes: true }),
1919
],
2020
build: {
2121
minify: IS_UMD

packages/graphiql-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"font"
3737
],
3838
"scripts": {
39-
"dev": "vite",
39+
"dev": "vite build --watch",
4040
"build": "vite build",
4141
"prebuild": "yarn types:check",
4242
"types:check": "tsc --noEmit"

packages/graphiql-react/src/editor/hooks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ export function useAutoCompleteLeafs({
333333
}, [getDefaultFieldNames, queryEditor, schema]);
334334
}
335335

336-
export type InitialState = string | (() => string);
337-
338336
// https://react.dev/learn/you-might-not-need-an-effect
339337

340338
export const useEditorState = (editor: 'query' | 'variable' | 'header') => {

packages/graphiql/src/cdn.ts

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,28 @@ import { createGraphiQLFetcher, createLocalStorage } from '@graphiql/toolkit';
99
import * as GraphQL from 'graphql';
1010
import { GraphiQL } from './components/GraphiQL';
1111

12-
import '@graphiql/react/font/roboto.css';
13-
import '@graphiql/react/font/fira-code.css';
14-
import '@graphiql/react/dist/style.css';
15-
import './style.css';
16-
1712
/**
1813
* For the CDN bundle we add some static properties to the component function
1914
* so that they can be accessed in the inline-script in the HTML file.
2015
*/
21-
22-
/**
23-
* This function is needed in order to easily create a fetcher function.
24-
*/
25-
// @ts-expect-error
26-
GraphiQL.createFetcher = createGraphiQLFetcher;
27-
28-
/**
29-
* This function is needed in order to easily generate a custom storage namespace
30-
*/
31-
// @ts-expect-error
32-
GraphiQL.createLocalStorage = createLocalStorage;
33-
34-
/**
35-
* We also add the complete `graphiql-js` exports so that this instance of
36-
* `graphiql-js` can be reused from plugin CDN bundles.
37-
*/
38-
// @ts-expect-error
39-
GraphiQL.GraphQL = GraphQL;
40-
41-
/**
42-
* We also add the complete `@graphiql/react` exports. These will be included
43-
* in the bundle anyway since they make up the `GraphiQL` component, so by
44-
* doing this we can reuse them from plugin CDN bundles.
45-
*/
46-
// @ts-expect-error
47-
GraphiQL.React = GraphiQLReact;
48-
49-
export default GraphiQL;
16+
export default Object.assign(GraphiQL, {
17+
/**
18+
* This function is needed in order to easily create a fetcher function.
19+
*/
20+
createFetcher: createGraphiQLFetcher,
21+
/**
22+
* This function is needed in order to easily generate a custom storage namespace
23+
*/
24+
createLocalStorage,
25+
/**
26+
* We also add the complete `graphiql-js` exports so that this instance of
27+
* `graphiql-js` can be reused from plugin CDN bundles.
28+
*/
29+
GraphQL,
30+
/**
31+
* We also add the complete `@graphiql/react` exports. These will be included
32+
* in the bundle anyway since they make up the `GraphiQL` component, so by
33+
* doing this we can reuse them from plugin CDN bundles.
34+
*/
35+
React: GraphiQLReact,
36+
});

packages/graphiql/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
import '@graphiql/react/font/roboto.css';
8+
import '@graphiql/react/font/fira-code.css';
9+
import '@graphiql/react/dist/style.css';
10+
import './style.css';
711

812
/**
913
* GraphiQL
1014
*/
11-
1215
export { GraphiQLProvider } from '@graphiql/react';
1316

1417
/**

0 commit comments

Comments
 (0)