Skip to content

Backport dual-build (and CI improvements) from express5 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
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: 5 additions & 0 deletions .changeset/tame-carpets-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@as-integrations/express4': minor
---

The package is now built for both CJS and ESM, instead of only for CJS; this is the same build approach taken by `@apollo/server`. This provides better compatibility with ESM-based build systems.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: CI

on:
pull_request
pull_request:
types:
- opened
- reopened
- synchronize
# So you can add a label to make it run, including no-changeset-needed
- labeled
- unlabeled

jobs:
build-and-test:
Expand Down Expand Up @@ -61,11 +68,11 @@ jobs:
changeset:
runs-on: ubuntu-latest
name: Changesets
if: ${{ (! startsWith(github.head_ref, 'changeset-release/')) && (!contains(github.event.pull_request.labels.*.name, 'no-changeset-needed')) }}
steps:
- uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- uses: ./.github/actions/node
- run: npm run changeset-check
if: ${{ ! startsWith(github.head_ref, 'changeset-release/') }}
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,31 @@
"bugs": {
"url": "https://github.com/apollo-server-integrations/apollo-server-integration-express4/issues"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
".": {
"types": {
"require": "./dist/cjs/index.d.ts",
"default": "./dist/esm/index.d.ts"
},
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"engines": {
"node": ">=20"
},
"scripts": {
"build": "tsc --build tsconfig.build.json",
"compile": "tsc --build tsconfig.build.json",
"postcompile": "echo '{\"type\":\"module\"}' > dist/esm/package.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
"clean": "git clean -dfqX",
"prepack": "npm run build",
"prepack": "npm run compile",
"prettier-check": "prettier --check .",
"prettier-fix": "prettier --write .",
"changeset-publish": "npm run build && changeset publish",
"changeset-publish": "npm run compile && changeset publish",
"changeset-check": "changeset status --verbose --since=origin/main",
"changeset-version": "changeset version && npm i",
"spell-check": "cspell lint '**' --no-progress || (echo 'Add any real words to cspell-dict.txt.'; exit 1)",
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"compilerOptions": {
"composite": true,
"rootDir": "./src",
"outDir": "./dist",
"outDir": "./dist/esm",
"target": "es2020",
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.build.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.build.esm.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "./dist/cjs"
}
}
5 changes: 5 additions & 0 deletions tsconfig.build.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.base.json",
"include": ["src/**/*"],
"exclude": ["**/__tests__"]
}
12 changes: 9 additions & 3 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"extends": "./tsconfig.base.json",
"include": ["src/**/*"],
"exclude": ["**/__tests__"],
"compilerOptions": {
"composite": true
},
"files": [],
"include": [],
"references": [
{ "path": "./tsconfig.build.esm.json" },
{ "path": "./tsconfig.build.cjs.json" }
]
}
Loading