Skip to content
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
5 changes: 4 additions & 1 deletion cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ words:
- deno
- denoland
- hashbang
- Rspack
- vitest
- Rollup
- Rspack
- Rsbuild
- Turbopack

# Website tech
- Nextra
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The `conditions` subdirectory contains tests that verify the conditional exports

### Verifying Development Mode Tests

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

### Verifying Production Mode Tests

Expand Down
2 changes: 1 addition & 1 deletion integrationTests/dev-bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "graphql-js development mode should work with Bun",
"private": true,
"scripts": {
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun test.js"
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun --conditions=development test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/dev-deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "graphql-js development mode should work with Deno",
"private": true,
"scripts": {
"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"
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run --conditions=development test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/dev-deno/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GraphQLObjectType {
try {
isObjectType(new GraphQLObjectType());
throw new Error(
'Expected isObjectType to throw an error in Deno implicit dev mode.',
'Expected isObjectType to throw an error in Deno development mode.',
);
} catch (error) {
if (!error.message.includes('from another module or realm')) {
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/dev-esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm",
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm --conditions=development",
"test": "npm run build && node dist/bundle.js"
},
"dependencies": {
Expand Down
11 changes: 11 additions & 0 deletions integrationTests/dev-explicit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": "graphql-js explicit development mode should work",
"private": true,
"type": "module",
"scripts": {
"test": "node test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
}
}
20 changes: 20 additions & 0 deletions integrationTests/dev-explicit/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { enableDevMode, isObjectType } from 'graphql';

enableDevMode();

class GraphQLObjectType {
get [Symbol.toStringTag]() {
return 'GraphQLObjectType';
}
}

try {
isObjectType(new GraphQLObjectType());
throw new Error(
'Expected isObjectType to throw an error in Node.js development mode.',
);
} catch (error) {
if (!error.message.includes('from another module or realm')) {
throw error;
}
}
2 changes: 1 addition & 1 deletion integrationTests/dev-jest/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FakeGraphQLObjectType {
}
}

describe('Jest with SWC development mode tests', () => {
describe('Jest development mode tests', () => {
test('isObjectType should throw in development mode for instances from another realm/module', () => {
expect(() => isObjectType(new FakeGraphQLObjectType())).toThrowError(
/from another module or realm/,
Expand Down
8 changes: 8 additions & 0 deletions integrationTests/dev-jest/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const jestConfig = {
testEnvironmentOptions: {
customExportConditions: ['development'],
},
};

// eslint-disable-next-line no-restricted-exports, import/no-default-export
export default jestConfig;
2 changes: 1 addition & 1 deletion integrationTests/dev-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"test": "node test.js"
"test": "node --conditions=development test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/dev-node/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GraphQLObjectType {
try {
isObjectType(new GraphQLObjectType());
throw new Error(
'Expected isObjectType to throw an error in Node.js implicit dev mode.',
'Expected isObjectType to throw an error in Node.js development mode.',
);
} catch (error) {
if (!error.message.includes('from another module or realm')) {
Expand Down
3 changes: 2 additions & 1 deletion integrationTests/dev-rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"rollup": "^4.0.0"
"rollup": "^4.0.0",
"@rollup/plugin-node-resolve": "^15.0.0"
}
}
8 changes: 8 additions & 0 deletions integrationTests/dev-rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// eslint-disable-next-line n/no-missing-import
import resolve from '@rollup/plugin-node-resolve';

const rollupConfig = {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'es',
},
plugins: [
resolve({
exportConditions: ['development'],
}),
],
};

// eslint-disable-next-line no-restricted-exports, import/no-default-export
Expand Down
3 changes: 3 additions & 0 deletions integrationTests/dev-rspack/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const rspack = {
},
mode: 'development',
target: 'node',
resolve: {
conditionNames: ['development'],
},
};

// eslint-disable-next-line no-restricted-exports, import/no-default-export
Expand Down
4 changes: 3 additions & 1 deletion integrationTests/dev-swc/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { isObjectType } from 'graphql';
import { enableDevMode, isObjectType } from 'graphql';

enableDevMode();

class GraphQLObjectType {
get [Symbol.toStringTag]() {
Expand Down
3 changes: 3 additions & 0 deletions integrationTests/dev-vitest/vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import { defineConfig } from 'vitest/config';

const vitestConfig = defineConfig({
resolve: {
conditions: ['development'],
},
test: {
include: ['**/*.test.js'],
},
Expand Down
3 changes: 3 additions & 0 deletions integrationTests/dev-webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const webpackConfig = {
},
mode: 'development',
target: 'node',
resolve: {
conditionNames: ['development'],
},
};

// eslint-disable-next-line no-restricted-exports, import/no-default-export
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/prod-bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "graphql-js production mode should work with Bun",
"private": true,
"scripts": {
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun --define process.env.NODE_ENV='\"production\"' test.js"
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
4 changes: 0 additions & 4 deletions integrationTests/prod-deno/env-shim.js

This file was deleted.

2 changes: 1 addition & 1 deletion integrationTests/prod-deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "graphql-js production mode should work with Deno",
"private": true,
"scripts": {
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run --allow-env --preload env-shim.js test.js"
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app denoland/deno:alpine-\"$DENO_VERSION\" deno run test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/prod-esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm --define:process.env.NODE_ENV='\"production\"'",
"build": "esbuild index.js --bundle --outfile=dist/bundle.js --format=esm",
"test": "npm run build && node dist/bundle.js"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/prod-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"test": "NODE_ENV=production node test.js"
"test": "node test.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz"
Expand Down
4 changes: 1 addition & 3 deletions integrationTests/prod-rollup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"rollup": "^4.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-replace": "^5.0.0"
"rollup": "^4.0.0"
}
}
13 changes: 0 additions & 13 deletions integrationTests/prod-rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
// eslint-disable-next-line n/no-missing-import
import resolve from '@rollup/plugin-node-resolve';
// eslint-disable-next-line n/no-missing-import
import replace from '@rollup/plugin-replace';

const rollupConfig = {
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'es',
},
plugins: [
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
include: ['node_modules/graphql/**'],
}),
resolve(),
],
};

// eslint-disable-next-line no-restricted-exports, import/no-default-export
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/prod-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"build": "swc index.js -d dist",
"test": "npm run build && NODE_ENV=production node dist/index.js"
"test": "npm run build && node dist/index.js"
},
"dependencies": {
"graphql": "file:../graphql.tgz",
Expand Down
Loading
Loading