MCPcopy Index your code
hub / github.com/sveltejs/kit / write_server

Function write_server

packages/kit/src/core/sync/write_server.js:101–137  ·  view source on GitHub ↗
(config, output)

Source from the content-addressed store, hash-verified

99 * @param {string} output
100 */
101export function write_server(config, output) {
102 const server_hooks_file = resolve_entry(config.kit.files.hooks.server);
103 const universal_hooks_file = resolve_entry(config.kit.files.hooks.universal);
104
105 const typo = resolve_entry('src/+hooks.server');
106 if (typo) {
107 console.log(
108 colors
109 .bold()
110 .yellow(
111 `Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` +
112 ` at ${path.resolve(typo)}`
113 )
114 );
115 }
116
117 /** @param {string} file */
118 function relative(file) {
119 return posixify(path.relative(`${output}/server`, file));
120 }
121
122 // Contains the stringified version of
123 /** @type {import('types').SSROptions} */
124 write_if_changed(
125 `${output}/server/internal.js`,
126 server_template({
127 config,
128 server_hooks: server_hooks_file ? relative(server_hooks_file) : null,
129 universal_hooks: universal_hooks_file ? relative(universal_hooks_file) : null,
130 has_service_worker:
131 config.kit.serviceWorker.register && !!resolve_entry(config.kit.files.serviceWorker),
132 runtime_directory: relative(runtime_directory),
133 template: load_template(process.cwd(), config),
134 error_page: load_error_page(config)
135 })
136 );
137}

Callers 2

createFunction · 0.90
serverFunction · 0.90

Calls 6

resolve_entryFunction · 0.90
write_if_changedFunction · 0.90
load_templateFunction · 0.90
load_error_pageFunction · 0.90
server_templateFunction · 0.85
relativeFunction · 0.85

Tested by

no test coverage detected