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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ node_modules/

# Volta binaries (when using direnv/.envrc)
.volta

smoke-test/generated
3 changes: 3 additions & 0 deletions packages/server/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*
# Include the package.json files that give us deep imports.
!**/package.json
node_modules/**/*
!src/**/*
src/**/__tests__/**
!dist/**/*
Expand Down
43 changes: 23 additions & 20 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,59 @@
"version": "3.6.7",
"description": "Core engine for Apollo GraphQL server",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"exports": {
".": {
"types": "./dist/esm/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts"
"require": "./dist/cjs/index.js"
},
"./standalone": {
"types": "./dist/esm/standalone/index.d.ts",
"import": "./dist/esm/standalone/index.js",
"require": "./dist/cjs/standalone/index.js",
"types": "./dist/cjs/standalone/index.d.ts"
"require": "./dist/cjs/standalone/index.js"
},
"./plugin/cacheControl": {
"types": "./dist/esm/plugin/cacheControl/index.d.ts",
"import": "./dist/esm/plugin/cacheControl/index.js",
"require": "./dist/cjs/plugin/cacheControl/index.js",
"types": "./dist/cjs/plugin/cacheControl/index.d.ts"
"require": "./dist/cjs/plugin/cacheControl/index.js"
},
"./plugin/disabled": {
"types": "./dist/esm/plugin/disabled.d.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna make the index change here for consistency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it looks like you did make that file move so I think this needs an update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and maybe we need to smoke test these paths since presumably this is in a broken state without CI knowing.

"import": "./dist/esm/plugin/disabled.js",
"require": "./dist/cjs/plugin/disabled.js",
"types": "./dist/cjs/plugin/disabled.d.ts"
"require": "./dist/cjs/plugin/disabled.js"
},
"./plugin/drainHttpServer": {
"types": "./dist/esm/plugin/drainHttpServer/index.d.ts",
"import": "./dist/esm/plugin/drainHttpServer/index.js",
"require": "./dist/cjs/plugin/drainHttpServer/index.js",
"types": "./dist/cjs/plugin/drainHttpServer/index.d.ts"
"require": "./dist/cjs/plugin/drainHttpServer/index.js"
},
"./plugin/inlineTrace": {
"types": "./dist/esm/plugin/inlineTrace/index.d.ts",
"import": "./dist/esm/plugin/inlineTrace/index.js",
"require": "./dist/cjs/plugin/inlineTrace/index.js",
"types": "./dist/cjs/plugin/inlineTrace/index.d.ts"
"require": "./dist/cjs/plugin/inlineTrace/index.js"
},
"./plugin/landingPage/default": {
"types": "./dist/esm/plugin/landingPage/default/index.d.ts",
"import": "./dist/esm/plugin/landingPage/default/index.js",
"require": "./dist/cjs/plugin/landingPage/default/index.js",
"types": "./dist/cjs/plugin/landingPage/default/index.d.ts"
"require": "./dist/cjs/plugin/landingPage/default/index.js"
},
"./plugin/landingPage/graphqlPlayground": {
"types": "./dist/esm/plugin/landingPage/graphqlPlayground/index.d.ts",
"import": "./dist/esm/plugin/landingPage/graphqlPlayground/index.js",
"require": "./dist/cjs/plugin/landingPage/graphqlPlayground/index.js",
"types": "./dist/cjs/plugin/landingPage/graphqlPlayground/index.d.ts"
"require": "./dist/cjs/plugin/landingPage/graphqlPlayground/index.js"
},
"./plugin/schemaReporting": {
"types": "./dist/esm/plugin/schemaReporting/index.d.ts",
"import": "./dist/esm/plugin/schemaReporting/index.js",
"require": "./dist/cjs/plugin/schemaReporting/index.js",
"types": "./dist/cjs/plugin/schemaReporting/index.d.ts"
"require": "./dist/cjs/plugin/schemaReporting/index.js"
},
"./plugin/usageReporting": {
"types": "./dist/esm/plugin/usageReporting/index.d.ts",
"import": "./dist/esm/plugin/usageReporting/index.js",
"require": "./dist/cjs/plugin/usageReporting/index.js",
"types": "./dist/cjs/plugin/usageReporting/index.d.ts"
"require": "./dist/cjs/plugin/usageReporting/index.js"
}
},
"repository": {
Expand Down
8 changes: 8 additions & 0 deletions packages/server/plugin/cacheControl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/cacheControl",
"type": "module",
"main": "../dist/cjs/plugin/cacheControl/index.js",
"module": "../dist/esm/plugin/cacheControl/index.js",
"types": "../dist/esm/plugin/cacheControl/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/disabled/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/disabled",
"type": "module",
"main": "../dist/cjs/plugin/disabled/index.js",
"module": "../dist/esm/plugin/disabled/index.js",
"types": "../dist/esm/plugin/disabled/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/drainHttpServer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/drainHttpServer",
"type": "module",
"main": "../dist/cjs/plugin/drainHttpServer/index.js",
"module": "../dist/esm/plugin/drainHttpServer/index.js",
"types": "../dist/esm/plugin/drainHttpServer/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/inlineTrace/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/inlineTrace",
"type": "module",
"main": "../dist/cjs/plugin/inlineTrace/index.js",
"module": "../dist/esm/plugin/inlineTrace/index.js",
"types": "../dist/esm/plugin/inlineTrace/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/landingPage/default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/landingPage/default",
"type": "module",
"main": "../dist/cjs/plugin/landingPage/default/index.js",
"module": "../dist/esm/plugin/landingPage/default/index.js",
"types": "../dist/esm/plugin/landingPage/default/index.d.ts",
"sideEffects": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/landingPage/graphqlPlayground",
"type": "module",
"main": "../dist/cjs/plugin/landingPage/graphqlPlayground/index.js",
"module": "../dist/esm/plugin/landingPage/graphqlPlayground/index.js",
"types": "../dist/esm/plugin/landingPage/graphqlPlayground/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/schemaReporting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/schemaReporting",
"type": "module",
"main": "../dist/cjs/plugin/schemaReporting/index.js",
"module": "../dist/esm/plugin/schemaReporting/index.js",
"types": "../dist/esm/plugin/schemaReporting/index.d.ts",
"sideEffects": false
}
8 changes: 8 additions & 0 deletions packages/server/plugin/usageReporting/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/plugin/usageReporting",
"type": "module",
"main": "../dist/cjs/plugin/usageReporting/index.js",
"module": "../dist/esm/plugin/usageReporting/index.js",
"types": "../dist/esm/plugin/usageReporting/index.d.ts",
"sideEffects": false
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// TODO(AS4): Document this file
// TODO(AS4): Decide where it is imported from.
import type { BaseContext, ApolloServerPlugin } from '..';
import type { BaseContext, ApolloServerPlugin } from '../..';
import type {
InternalApolloServerPlugin,
InternalPluginId,
} from '../internalPlugin';
} from '../../internalPlugin';

function disabledPlugin<TContext extends BaseContext>(
id: InternalPluginId,
Expand Down
8 changes: 8 additions & 0 deletions packages/server/standalone/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@apollo/server/standalone",
"type": "module",
"main": "../dist/cjs/standalone/index.js",
"module": "../dist/esm/standalone/index.js",
"types": "../dist/esm/standalone/index.d.ts",
"sideEffects": false
}
3 changes: 2 additions & 1 deletion scripts/postcompile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import path from 'path';
import { writeFileSync } from 'fs';
import rimraf from 'rimraf';

// Tell Node what kinds of files the ".js" files in these subdirectories are.
writeFileSync(
path.join('packages', 'server', 'dist', 'esm', 'package.json'),
JSON.stringify({ type: 'module' }),
Expand All @@ -20,5 +21,5 @@ writeFileSync(
JSON.stringify({ type: 'commonjs' }),
);

// Remove CJS .d.ts files.
// Remove CJS .d.ts files: we don't need two copies!
rimraf.sync('packages/server/dist/cjs/**/*.d.ts');
1 change: 1 addition & 0 deletions smoke-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.3.0",
"@types/make-fetch-happen": "9.0.2",
"rollup": "2.75.7"
}
}
2 changes: 1 addition & 1 deletion smoke-test/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm pack --pack-destination="$TARBALL_DIR" --workspaces=true

# Install node_modules in the smoke-test directory
cd smoke-test
rm -rf node_modules package-lock.json
rm -rf node_modules package-lock.json generated
# First install normal dependencies
npm i
# Now install the tarballs we made (but don't write their paths to package.json)
Expand Down
39 changes: 39 additions & 0 deletions smoke-test/smoke-test.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import fetch from 'make-fetch-happen';
import assert from 'assert';

async function smokeTest() {
const s = new ApolloServer({
typeDefs: 'type Query {hello:String}',
resolvers: {
Query: {
hello() {
return 'world';
},
},
},
});
const { url } = await startStandaloneServer(s, { listen: { port: 0 } });

const response = await fetch(url, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ query: '{hello}' }),
});
const body = await response.json();

assert.strictEqual(body.data.hello, 'world');

await s.stop();
}

smokeTest()
.then(() => {
console.log('TS-CJS smoke test passed!');
process.exit(0);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
39 changes: 39 additions & 0 deletions smoke-test/smoke-test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import fetch from 'make-fetch-happen';
import assert from 'assert';

async function smokeTest() {
const s = new ApolloServer({
typeDefs: 'type Query {hello:String}',
resolvers: {
Query: {
hello() {
return 'world';
},
},
},
});
const { url } = await startStandaloneServer(s, { listen: { port: 0 } });

const response = await fetch(url, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ query: '{hello}' }),
});
const body = await response.json();

assert.strictEqual(body.data.hello, 'world');

await s.stop();
}

smokeTest()
.then(() => {
console.log('TS-ESM smoke test passed!');
process.exit(0);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
5 changes: 5 additions & 0 deletions smoke-test/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ npx rollup smoke-test-no-express.mjs --config rollup.config.js --silent --file "
grep 'function createApplication' "$ROLLUP_OUT_DIR"/bundle.mjs
# ... and that the one that doesn't, doesn't.
! grep 'function createApplication' "$ROLLUP_OUT_DIR"/bundle-no-express.mjs

# Ensure basic TypeScript builds work.
tsc --build tsconfig.{esm,cjs}.json
node generated/tsc/smoke-test.cjs
node generated/tsc/smoke-test.mjs
12 changes: 12 additions & 0 deletions smoke-test/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
"smoke-test.cts",
],
"compilerOptions": {
"outDir": "generated/tsc",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
},
}
12 changes: 12 additions & 0 deletions smoke-test/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files": [
"smoke-test.mts",
],
"compilerOptions": {
"outDir": "generated/tsc",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
},
}