Files
workers-graphql-server/webpack.config.js
Jesse Rosenberger c979d3c652 Upgrade to apollo-server-cloudflare@2.21 and mock 'tls' and 'net' modules.
This upgrades to Apollo Server 2.21 and makes a Webpack configuration change
to make it possible to bundle that new version.

Per the comment added within the Webpack configuration which aliases the
'tls' and 'net' modules in the resulting bundle to empty modules:

The 'net' and 'tls' Node.js built-in usage within Apollo Server is merely to
run `instanceof` checks against an existing, user-supplied "server" instance
when subscriptions are desired to be bound to an already-created server.
For the purposes of Cloudflare, where none of these Node.js builtins exist,
this instanceof check is irrelevant because such a class could not exist.

This is necessary as of the introduction of those `instanceof` checks in
https://github.com/apollographql/apollo-server/commit/8ab0e90724d8d35ad.
2021-03-03 09:10:47 +00:00

25 lines
768 B
JavaScript

const path = require('path')
module.exports = {
target: 'webworker',
resolve: {
alias: {
fs: path.resolve(__dirname, './null.js'),
// The 'net' and 'tls' Node.js built-in usage within Apollo Server
// is merely to run `instanceof` checks against an existing,
// user-supplied "server" instance when subscriptions are desired to
// be bound to an already-created server. For the purposes of
// Cloudflare, where none of these Node.js builtins exist, this
// instanceof check is irrelevant because such a class could not
// exist.
net: path.resolve(__dirname, './null.js'),
tls: path.resolve(__dirname, './null.js'),
},
},
mode: 'production',
optimization: {
usedExports: true,
},
}