mirror of
https://github.com/zhigang1992/workers-graphql-server.git
synced 2026-05-28 14:27:33 +08:00
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.
25 lines
768 B
JavaScript
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,
|
|
},
|
|
}
|