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,
'class-methods-use-this': 0,
'jsdoc/require-returns': 0,
'jsdoc/tag-lines': 0,
'import/extensions': [
'error',
'ignorePackages',

View file

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

View file

@ -1,7 +1,13 @@
/* eslint-disable vars-on-top */
import cron from 'node-cron';
import fs from 'fs-extra';
import { Logger } from '../Logger';
declare global {
// eslint-disable-next-line no-var
var EventDispatcher: EventDispatcher | undefined;
}
export const EVENT_TYPES = {
// System events
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;
nextApp = new NextServer({ hostname: 'localhost', dev, port, customServer: true, conf });
} else {
const next = require('next').default;
const next = require('next');
nextApp = next({ dev, hostname, port });
}