Skip to content

Commit d74c6c6

Browse files
committed
Merge branch '16.x.x' into maxintfields-16
2 parents 294f199 + c40e054 commit d74c6c6

File tree

8 files changed

+150
-7
lines changed

8 files changed

+150
-7
lines changed

cspell.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ overrides:
1919
- clsx
2020
- infima
2121
- noopener
22+
- Vite
23+
- craco
24+
- esbuild
25+
- swcrc
2226
- noreferrer
2327
- xlink
2428

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql",
3-
"version": "16.8.1",
3+
"version": "16.8.2",
44
"description": "A Query Language and Runtime which can target any service.",
55
"license": "MIT",
66
"private": true,
@@ -30,7 +30,7 @@
3030
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
3131
},
3232
"scripts": {
33-
"preversion": ". ./resources/checkgit.sh && npm ci --ignore-scripts",
33+
"preversion": "bash -c '. ./resources/checkgit.sh && npm ci --ignore-scripts'",
3434
"version": "node resources/gen-version.js && npm test && git add src/version.ts",
3535
"fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts",
3636
"changelog": "node resources/gen-changelog.js",

resources/checkgit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Exit immediately if any subcommand terminated
2+
set -e
23
trap "exit 1" ERR
34

45
#

src/jsutils/instanceOf.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { inspect } from './inspect';
22

3+
/* c8 ignore next 3 */
4+
const isProduction =
5+
globalThis.process &&
6+
// eslint-disable-next-line no-undef
7+
process.env.NODE_ENV === 'production';
8+
39
/**
410
* A replacement for instanceof which includes an error warning when multi-realm
511
* constructors are detected.
@@ -9,7 +15,7 @@ import { inspect } from './inspect';
915
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
1016
/* c8 ignore next 6 */
1117
// FIXME: https://github.com/graphql/graphql-js/issues/2317
12-
globalThis.process && globalThis.process.env.NODE_ENV === 'production'
18+
isProduction
1319
? function instanceOf(value: unknown, constructor: Constructor): boolean {
1420
return value instanceof constructor;
1521
}

src/version.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/**
55
* A string containing the version of the GraphQL.js library
66
*/
7-
export const version = '16.8.1' as string;
7+
export const version = '16.8.2' as string;
88

99
/**
1010
* An object containing the components of the GraphQL.js version string
1111
*/
1212
export const versionInfo = Object.freeze({
1313
major: 16 as number,
1414
minor: 8 as number,
15-
patch: 1 as number,
15+
patch: 2 as number,
1616
preReleaseTag: null as string | null,
1717
});
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Going to production
3+
category: FAQ
4+
---
5+
6+
GraphQL.JS contains a few development checks which in production will cause slower performance and
7+
an increase in bundle-size. Every bundler goes about these changes different, in here we'll list
8+
out the most popular ones.
9+
10+
## Bundler-specific configuration
11+
12+
Here are some bundler-specific suggestions for configuring your bundler to remove `globalThis.process` and `process.env.NODE_ENV` on build time.
13+
14+
### Vite
15+
16+
```js
17+
export default defineConfig({
18+
// ...
19+
define: {
20+
'globalThis.process': JSON.stringify(true),
21+
'process.env.NODE_ENV': JSON.stringify('production'),
22+
},
23+
});
24+
```
25+
26+
### Next.js
27+
28+
```js
29+
// ...
30+
/** @type {import('next').NextConfig} */
31+
const nextConfig = {
32+
webpack(config, { webpack }) {
33+
config.plugins.push(
34+
new webpack.DefinePlugin({
35+
'globalThis.process': JSON.stringify(true),
36+
'process.env.NODE_ENV': JSON.stringify('production'),
37+
}),
38+
);
39+
return config;
40+
},
41+
};
42+
43+
module.exports = nextConfig;
44+
```
45+
46+
### create-react-app
47+
48+
With `create-react-app`, you need to use a third-party package like [`craco`](https://craco.js.org/) to modify the bundler configuration.
49+
50+
```js
51+
const webpack = require('webpack');
52+
module.exports = {
53+
webpack: {
54+
plugins: [
55+
new webpack.DefinePlugin({
56+
'globalThis.process': JSON.stringify(true),
57+
'process.env.NODE_ENV': JSON.stringify('production'),
58+
}),
59+
],
60+
},
61+
};
62+
```
63+
64+
### esbuild
65+
66+
```json
67+
{
68+
"define": {
69+
"globalThis.process": true,
70+
"process.env.NODE_ENV": "production"
71+
}
72+
}
73+
```
74+
75+
### Webpack
76+
77+
```js
78+
config.plugins.push(
79+
new webpack.DefinePlugin({
80+
'globalThis.process': JSON.stringify(true),
81+
'process.env.NODE_ENV': JSON.stringify('production'),
82+
}),
83+
);
84+
```
85+
86+
### Rollup
87+
88+
```js
89+
export default [
90+
{
91+
// ... input, output, etc.
92+
plugins: [
93+
minify({
94+
mangle: {
95+
toplevel: true,
96+
},
97+
compress: {
98+
toplevel: true,
99+
global_defs: {
100+
'@globalThis.process': JSON.stringify(true),
101+
'@process.env.NODE_ENV': JSON.stringify('production'),
102+
},
103+
},
104+
}),
105+
],
106+
},
107+
];
108+
```
109+
110+
### SWC
111+
112+
```json title=".swcrc"
113+
{
114+
"jsc": {
115+
"transform": {
116+
"optimizer": {
117+
"globals": {
118+
"vars": {
119+
"globalThis.process": true,
120+
"process.env.NODE_ENV": "production"
121+
}
122+
}
123+
}
124+
}
125+
}
126+
}
127+
```

website/sidebars.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ module.exports = {
1515
label: 'Advanced',
1616
items: ['tutorials/constructing-types'],
1717
},
18+
{
19+
type: 'category',
20+
label: 'FAQ',
21+
items: ['tutorials/going-to-production'],
22+
},
1823
'tutorials/express-graphql',
1924
],
2025
};

0 commit comments

Comments
 (0)