diff --git a/package.json b/package.json index 6c29f73..0416176 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,15 @@ "thirty-two": "^1.0.2", "typeorm": "^0.3.7" }, + "runtimeDependencies": [ + "@nestjs/common", + "@nestjs/core", + "@nestjs/platform-fastify", + "@nestjs/serve-static", + "argon2", + "sqlite3", + "typeorm" + ], "devDependencies": { "@nestjs/cli": "^9.0.0", "@nestjs/schematics": "^9.0.1", diff --git a/tsconfig.json b/tsconfig.json index b6340d3..71e4661 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "outDir": "./dist", "baseUrl": "./", "incremental": true, - "skipLibCheck": true + "skipLibCheck": true, + "resolveJsonModule": true }, "exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"] } diff --git a/webpack.config.ts b/webpack.config.ts index 36cbefc..5608c2d 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -2,14 +2,21 @@ import { DefinePlugin } from 'webpack'; import * as nodeExternals from 'webpack-node-externals'; import * as copyPlugin from 'copy-webpack-plugin'; import { resolve } from 'path'; +import * as pkg from './package.json'; function transform_package(input: Buffer): string { const pkg = JSON.parse(input.toString()); - delete pkg['devDependencies']; - delete pkg['jest']; pkg['scripts'] = { start: 'node server.js' }; + pkg['dependencies'] = Object.fromEntries( + Object.entries(pkg['dependencies']).filter((dep) => + pkg['runtimeDependencies'].includes(dep[0]) + ) + ); + delete pkg['runtimeDependencies']; + delete pkg['devDependencies']; + delete pkg['jest']; return JSON.stringify(pkg); } @@ -25,10 +32,6 @@ export default { from: resolve(__dirname, 'package.json'), to: resolve(__dirname, 'dist', 'package.json'), transform: transform_package - }, - { - from: resolve(__dirname, 'yarn.lock'), - to: resolve(__dirname, 'dist', 'yarn.lock') } ] }) @@ -51,5 +54,13 @@ export default { filename: 'server.js', path: resolve(__dirname, 'dist') }, - externals: [nodeExternals()] + externals: [ + nodeExternals({ + allowlist: (dep) => !pkg.runtimeDependencies.includes(dep) + }) + ], + performance: { + maxEntrypointSize: 512 * 1024 * 1024, + maxAssetSize: 512 * 1024 * 1024 + } };