Skip to content

Commit a732e3d

Browse files
committed
use enableDevMode() or development condition instead of NODE_ENV
1 parent 8642016 commit a732e3d

File tree

41 files changed

+515
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+515
-220
lines changed

cspell.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ words:
6868
- deno
6969
- denoland
7070
- hashbang
71-
- Rspack
7271
- Rollup
72+
- Rspack
73+
- Rsbuild
74+
- Turbopack
7375

7476
# Website tech
7577
- Nextra

integrationTests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `conditions` subdirectory contains tests that verify the conditional exports
2020

2121
### Verifying Development Mode Tests
2222

23-
Each subdirectory represents a different environment/bundler demonstrating enabling development mode by setting the environment variable `NODE_ENV` to `development`.
23+
Each subdirectory represents a different platform/bundler demonstrating enabling development mode by enabling the `development` condition or by calling `enableDevMode()`.
2424

2525
### Verifying Production Mode Tests
2626

integrationTests/dev-bun/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "graphql-js development mode should work with Bun",
33
"private": true,
44
"scripts": {
5-
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun test.js"
5+
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun --conditions=development test.js"
66
},
77
"dependencies": {
88
"graphql": "file:../graphql.tgz"

integrationTests/dev-bun/test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { isObjectType } from 'graphql';
1+
import { enableDevMode, isObjectType } from 'graphql';
2+
3+
enableDevMode();
24

35
class GraphQLObjectType {
46
get [Symbol.toStringTag]() {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js condition-based development mode should work with Deno",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:latest deno run --conditions=development --allow-env=NODE_ENV test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}

integrationTests/dev-deno/test.js renamed to integrationTests/dev-deno-condition-based/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class GraphQLObjectType {
99
try {
1010
isObjectType(new GraphQLObjectType());
1111
throw new Error(
12-
'Expected isObjectType to throw an error in Deno implicit dev mode.',
12+
'Expected isObjectType to throw an error in Deno condition-based development mode.',
1313
);
1414
} catch (error) {
1515
if (!error.message.includes('from another module or realm')) {

integrationTests/dev-deno/package.json renamed to integrationTests/dev-deno-explicit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"description": "graphql-js development mode should work with Deno",
2+
"description": "graphql-js explicit development mode should work with Deno",
33
"private": true,
44
"scripts": {
55
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run --allow-env=NODE_ENV test.js"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { enableDevMode, isObjectType } from 'graphql';
2+
3+
enableDevMode();
4+
5+
class GraphQLObjectType {
6+
get [Symbol.toStringTag]() {
7+
return 'GraphQLObjectType';
8+
}
9+
}
10+
11+
try {
12+
isObjectType(new GraphQLObjectType());
13+
throw new Error(
14+
'Expected isObjectType to throw an error in Deno explicit development mode.',
15+
);
16+
} catch (error) {
17+
if (!error.message.includes('from another module or realm')) {
18+
throw error;
19+
}
20+
}

integrationTests/dev-esbuild/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm",
6+
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm --conditions=development",
77
"test": "npm run build && node dist/bundle.js"
88
},
99
"dependencies": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const jestConfig = {
2+
testEnvironment: 'node',
3+
4+
testEnvironmentOptions: {
5+
customExportConditions: ['development'],
6+
},
7+
8+
transform: {
9+
'^.+\\.(t|j)sx?$': ['@swc/jest'],
10+
},
11+
12+
transformIgnorePatterns: [
13+
// Allow 'graphql' to be transformed, ignore all other node_modules.
14+
// This regex means: "match /node_modules/ unless it's followed by graphql/"
15+
'/node_modules/(?!graphql/)',
16+
// Keep Jest's default for .pnp.js files if using Yarn PnP
17+
'\\.pnp\\.[^\\/]+$',
18+
],
19+
};
20+
21+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
22+
export default jestConfig;

0 commit comments

Comments
 (0)