Skip to content

Commit 04535d2

Browse files
committed
add integration tests for Rspack
1 parent bfeb14b commit 04535d2

File tree

10 files changed

+104
-5
lines changed

10 files changed

+104
-5
lines changed

cspell.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ overrides:
3939
- URQL
4040
- tada
4141
- Graphile
42-
- precompiled
42+
- precompileds
4343
- Rollup
4444
- Turbopack
4545

@@ -68,6 +68,8 @@ words:
6868
# TODO: contribute upstream
6969
- deno
7070
- hashbang
71+
- Rspack
72+
- Rsbuild
7173

7274
# Website tech
7375
- Nextra

integrationTests/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Each subdirectory represents a different environment/bundler demonstrating enabl
2323
- `dev-deno-explicit`: via `import 'graphql/dev'`
2424
- `dev-node-implicit`: via `node --conditions=development test.js`
2525
- `dev-node-explicit`: via `import 'graphql/dev'`
26+
- `dev-webpack`: via `{resolve: { conditionNames: ['development'] } }`
27+
- `dev-rspack`: via `{resolve: { conditionNames: ['development'] } }`
2628
- `dev-esbuild`: via `esbuild --conditions=development test.js`
2729
- `dev-rollup`: via `@rollup/plugin-node-resolve` with `conditions: ['development']`
2830
- `dev-swc`: via `import 'graphql/dev'`
29-
- `dev-webpack`: via `{resolve: { conditionNames: ['development'] } }`
3031

3132
### Verifying Production Mode Tests
3233

@@ -35,7 +36,8 @@ Each subdirectory represents a different environment/bundler demonstrating produ
3536
- `prod-bun/`: via `bun test.js`
3637
- `prod-deno`: via `deno run test.js`
3738
- `prod-node`: via `node test.js`
39+
- `prod-webpack`: via default Webpack configuration
40+
- `prod-rspack`: via default Rspack configuration
3841
- `prod-esbuild`: via `esbuild test.js`
3942
- `prod-rollup`: via default Rollup configuration
4043
- `prod-swc`: via default SWC configuration
41-
- `prod-webpack`: via default Webpack configuration
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"description": "graphql-js development condition should work with Rspack",
3+
"private": true,
4+
"scripts": {
5+
"test": "rspack --mode=development && node dist/main.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz",
9+
"@rspack/core": "^1.0.0",
10+
"@rspack/cli": "^1.0.0"
11+
}
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { fileURLToPath } from 'node:url';
2+
3+
const rspack = {
4+
entry: './src/index.js',
5+
output: {
6+
filename: 'main.js',
7+
path: fileURLToPath(new URL('dist', import.meta.url)),
8+
library: {
9+
type: 'commonjs2',
10+
},
11+
},
12+
mode: 'development',
13+
target: 'node',
14+
resolve: {
15+
conditionNames: ['development', 'import', 'node'],
16+
},
17+
};
18+
19+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
20+
export default rspack;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
try {
10+
isObjectType(new GraphQLObjectType());
11+
throw new Error(
12+
'Expected isObjectType to throw an error in Deno explicit dev import mode.',
13+
);
14+
} catch (error) {
15+
if (!error.message.includes('from another module or realm')) {
16+
throw error;
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"description": "graphql-js production mode should work with Rspack",
3+
"private": true,
4+
"scripts": {
5+
"test": "rspack --mode=production && node dist/main.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz",
9+
"@rspack/core": "^1.0.0",
10+
"@rspack/cli": "^1.0.0"
11+
}
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { fileURLToPath } from 'node:url';
2+
3+
const rspackConfig = {
4+
entry: './src/index.js',
5+
output: {
6+
filename: 'main.js',
7+
path: fileURLToPath(new URL('dist', import.meta.url)),
8+
library: {
9+
type: 'commonjs2',
10+
},
11+
},
12+
mode: 'production',
13+
target: 'node',
14+
};
15+
16+
// eslint-disable-next-line no-restricted-exports, import/no-default-export
17+
export default rspackConfig;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { isObjectType } from 'graphql';
2+
3+
class GraphQLObjectType {
4+
get [Symbol.toStringTag]() {
5+
return 'GraphQLObjectType';
6+
}
7+
}
8+
9+
const result = isObjectType(new GraphQLObjectType());
10+
if (result !== false) {
11+
throw new Error(
12+
'isObjectType should return false in Webpack production mode.',
13+
);
14+
}

resources/integration-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('Integration Tests', () => {
4040
testOnNodeProject('dev-deno-explicit');
4141
testOnNodeProject('dev-bun');
4242
testOnNodeProject('dev-webpack');
43+
testOnNodeProject('dev-rspack');
4344
testOnNodeProject('dev-rollup');
4445
testOnNodeProject('dev-esbuild');
4546
testOnNodeProject('dev-swc');
@@ -49,6 +50,7 @@ describe('Integration Tests', () => {
4950
testOnNodeProject('prod-deno');
5051
testOnNodeProject('prod-bun');
5152
testOnNodeProject('prod-webpack');
53+
testOnNodeProject('dev-rspack');
5254
testOnNodeProject('prod-rollup');
5355
testOnNodeProject('prod-esbuild');
5456
testOnNodeProject('prod-swc');

website/pages/docs/development-mode.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ development mode. Rather, development mode is either enabled:
2020
2. implicitly, by setting the 'development' condition, which is possible only in
2121
environments that support `package.json` conditional exports and custom conditions.
2222

23-
Conditional exports are supported by: Node.js, Deno (canary), Bun, Webpack 5, Rollup
24-
(via the `node-resolve` plugin), esbuild, and Vite. create-react-app and Next.js
23+
Conditional exports are supported by: Node.js, Deno (canary), Bun, Webpack 5, Rspack,
24+
Rollup (via the `node-resolve` plugin), esbuild, Vite, and Rsbuild. create-react-app and Next.js
2525
support conditional exports when using Webpack 5 as their bundler.
2626

2727
Conditional exports are not supported by Deno (current), Webpack 4, Rollup (without

0 commit comments

Comments
 (0)