Skip to content

Commit 746cd68

Browse files
committed
Publish as ESM-only
Require Node v20.19 (which enables require(esm) support by default). This new package is supposed to be compatible with Apollo Server 4 which does an elaborate dance to publish as both CJS and ESM, but we already decided it was OK for this package itself to require Node v20. Turns out CJS-only plays poorly with the AS4-style dual build: apollographql/apollo-server#8069 And we're likely to go ESM-only with AS5 because newer Node makes this easier. So let's do that here too. Making tests work requires: - Tweaking ts-jest to some new presets. - Passing an experimental option to Node (and disabling the warning about it). - Upgrading the integration test suite to a version that is dual-built instead of CJS-only (otherwise we end up with different ApolloServers from the `@apollo/server` we load directly (ESM) and via the integration test suite (CJS)).
1 parent bfa8775 commit 746cd68

File tree

5 files changed

+40
-36
lines changed

5 files changed

+40
-36
lines changed

.changeset/modern-kiwis-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@as-integrations/express5': major
3+
---
4+
5+
Publish as ESM-only, and require Node v20.19 (which enables require(esm) support by default).

jest.config.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import type { Config } from '@jest/types';
1+
import type { Config } from 'jest';
2+
import { createDefaultEsmPreset } from 'ts-jest';
23

3-
const config: Config.InitialOptions = {
4-
preset: 'ts-jest',
5-
testEnvironment: 'node',
6-
roots: ['src'],
7-
transform: {
8-
'/__tests__/.*.test.ts$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
9-
},
10-
testRegex: '/__tests__/.*.test.ts$',
11-
verbose: true,
12-
};
4+
const presetConfig = createDefaultEsmPreset({
5+
tsconfig: 'tsconfig.test.json',
6+
});
137

14-
export default config;
8+
export default {
9+
...presetConfig,
10+
testRegex: '/__tests__/.*.test.ts$',
11+
} satisfies Config;

package-lock.json

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

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
"bugs": {
1313
"url": "https://github.com/apollo-server-integrations/apollo-server-integration-express5/issues"
1414
},
15-
"main": "dist/index.js",
16-
"types": "dist/index.d.ts",
15+
"type": "module",
16+
"exports": {
17+
".": "./dist/index.js"
18+
},
1719
"engines": {
18-
"node": ">=20"
20+
"node": ">=20.19"
1921
},
2022
"scripts": {
2123
"build": "tsc --build tsconfig.build.json",
@@ -27,14 +29,14 @@
2729
"changeset-check": "changeset status --verbose --since=origin/main",
2830
"changeset-version": "changeset version && npm i",
2931
"spell-check": "cspell lint '**' --no-progress || (echo 'Add any real words to cspell-dict.txt.'; exit 1)",
30-
"test": "jest",
31-
"test:ci": "jest --coverage --ci --maxWorkers=2 --reporters=default --reporters=jest-junit",
32+
"test": "NODE_OPTIONS=\"--experimental-vm-modules --disable-warning=ExperimentalWarning\" jest",
33+
"test:ci": "npm run test --coverage --ci --maxWorkers=2 --reporters=default --reporters=jest-junit",
3234
"watch": "tsc --build --watch",
3335
"lint": "eslint ."
3436
},
3537
"devDependencies": {
36-
"@apollo/server": "4.12.0",
37-
"@apollo/server-integration-testsuite": "4.12.0",
38+
"@apollo/server": "4.12.2",
39+
"@apollo/server-integration-testsuite": "4.12.2",
3840
"@apollo/utils.withrequired": "3.0.0",
3941
"@changesets/changelog-github": "0.5.1",
4042
"@changesets/cli": "2.29.3",

tsconfig.base.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"compilerOptions": {
33
"rootDir": "./src",
44
"outDir": "./dist",
5-
"target": "es2020",
6-
"module": "commonjs",
7-
"moduleResolution": "node",
5+
"target": "ESNext",
6+
"module": "NodeNext",
87
"esModuleInterop": true,
8+
"isolatedModules": true,
99
"sourceMap": true,
1010
"declaration": true,
1111
"declarationMap": true,

0 commit comments

Comments
 (0)