Home / File/ ssr-prod.js — svelte Source File

ssr-prod.js — svelte Source File

Architecture documentation for ssr-prod.js, a javascript file in the svelte codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  a5c8d449_637f_16c1_f795_6475457325a6["ssr-prod.js"]
  75c7e793_6831_91f3_b4b0_076c25691d90["./src/App.svelte"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> 75c7e793_6831_91f3_b4b0_076c25691d90
  6a72d479_c085_95c9_99b3_5218d1f2e854["ssr-common.js"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> 6a72d479_c085_95c9_99b3_5218d1f2e854
  f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> f596e027_a951_36c9_7695_83acc4f0d6b9
  f8929fbd_6327_2bb8_f43b_31a3db2e4d74["node:path"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> f8929fbd_6327_2bb8_f43b_31a3db2e4d74
  8115eea5_1702_b0c2_2ee3_fa496d322897["polka"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> 8115eea5_1702_b0c2_2ee3_fa496d322897
  19c4395f_f4bb_853e_9c49_a71d8228542e["server"]
  a5c8d449_637f_16c1_f795_6475457325a6 --> 19c4395f_f4bb_853e_9c49_a71d8228542e
  style a5c8d449_637f_16c1_f795_6475457325a6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs';
import path from 'node:path';
import polka from 'polka';
import { render } from 'svelte/server';
import App from './src/App.svelte';
import './ssr-common.js';

const { head, body } = await render(App);

const rendered = fs
	.readFileSync(path.resolve('./dist/client/index.html'), 'utf-8')
	.replace(`<!--ssr-body-->`, body)
	.replace(`<!--ssr-head-->`, head);

const types = {
	'.js': 'application/javascript',
	'.css': 'text/css'
};

polka()
	.use((req, res) => {
		if (req.url === '/') {
			res.writeHead(200, { 'content-type': 'text/html' });
			res.end(rendered);
			return;
		}

		const file = path.resolve('./dist/client' + req.url);

		if (fs.existsSync(file)) {
			const type = types[path.extname(req.url)] ?? 'application/octet-stream';
			res.writeHead(200, { 'content-type': type });
			fs.createReadStream(file).pipe(res);
			return;
		}

		res.writeHead(404);
		res.end('not found');
	})
	.listen('3000');

console.log('listening on http://localhost:3000');

Domain

Dependencies

Frequently Asked Questions

What does ssr-prod.js do?
ssr-prod.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain.
What does ssr-prod.js depend on?
ssr-prod.js imports 6 module(s): ./src/App.svelte, node:fs, node:path, polka, server, ssr-common.js.
Where is ssr-prod.js in the architecture?
ssr-prod.js is located at playgrounds/sandbox/ssr-prod.js (domain: Compiler, directory: playgrounds/sandbox).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free