fix(server): require next server

This commit is contained in:
Nicolas Meienberger 2023-05-21 08:25:26 +02:00
parent 15f63551e7
commit fee9f0f39b
4 changed files with 13 additions and 4 deletions

View file

@ -36,6 +36,7 @@ module.exports = {
'arrow-body-style': 0, 'arrow-body-style': 0,
'class-methods-use-this': 0, 'class-methods-use-this': 0,
'jsdoc/require-returns': 0, 'jsdoc/require-returns': 0,
'jsdoc/tag-lines': 0,
'import/extensions': [ 'import/extensions': [
'error', 'error',
'ignorePackages', 'ignorePackages',

View file

@ -29,11 +29,11 @@ esbuild
external, external,
define: { 'process.env.NODE_ENV': `"${process.env.NODE_ENV}"` }, define: { 'process.env.NODE_ENV': `"${process.env.NODE_ENV}"` },
platform: 'node', platform: 'node',
target: 'node14', target: 'node18',
outfile: 'dist/index.js', outfile: 'dist/index.js',
tsconfig: 'tsconfig.json', tsconfig: 'tsconfig.json',
bundle: true, bundle: true,
minify: isDev, minify: true,
sourcemap: isDev, sourcemap: isDev,
watch: false, watch: false,
}) })

View file

@ -1,7 +1,13 @@
/* eslint-disable vars-on-top */
import cron from 'node-cron'; import cron from 'node-cron';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { Logger } from '../Logger'; import { Logger } from '../Logger';
declare global {
// eslint-disable-next-line no-var
var EventDispatcher: EventDispatcher | undefined;
}
export const EVENT_TYPES = { export const EVENT_TYPES = {
// System events // System events
RESTART: 'restart', RESTART: 'restart',
@ -250,4 +256,6 @@ class EventDispatcher {
} }
} }
export const EventDispatcherInstance = EventDispatcher.getInstance(); export const EventDispatcherInstance = global.EventDispatcher || EventDispatcher.getInstance();
global.EventDispatcher = EventDispatcherInstance;

View file

@ -25,7 +25,7 @@ if (!dev) {
conf = require('./.next/required-server-files.json').config; conf = require('./.next/required-server-files.json').config;
nextApp = new NextServer({ hostname: 'localhost', dev, port, customServer: true, conf }); nextApp = new NextServer({ hostname: 'localhost', dev, port, customServer: true, conf });
} else { } else {
const next = require('next').default; const next = require('next');
nextApp = next({ dev, hostname, port }); nextApp = next({ dev, hostname, port });
} }